Last active
April 30, 2020 21:35
-
-
Save clayg/c3d31a62eba590eebd5f5d257c24a297 to your computer and use it in GitHub Desktop.
priority updater can target/skip specific problematic containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@saio:~$ /vagrant/.scratch/priority-object-updater --help | |
Usage: priority-object-updater CONFIG [options] | |
Options: | |
-h, --help show this help message and exit | |
--container=FILTER_CONTAINERS | |
Only process specific AUTH_acct/container(s) | |
--skip=SKIP_CONTAINERS | |
Do not process skipped AUTH_acct/container(s) | |
-v, --verbose log to console | |
-o, --once only run one pass of daemon | |
/vagrant/.scratch/priority-object-updater --skip AUTH_test/test-5 --skip AUTH_test/test-4 -ov /etc/swift/object-server/2.conf.d/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from optparse import OptionParser | |
from swift.obj.updater import ObjectUpdater | |
from swift.common.utils import parse_options | |
from swift.common.daemon import run_daemon | |
import six.moves.cPickle as pickle | |
class PriorityObjectUpdater(ObjectUpdater): | |
filter_containers = set() | |
skip_containers = set() | |
def _iter_async_pendings(self, device): | |
ap_iter = super(PriorityObjectUpdater, | |
self)._iter_async_pendings(device) | |
for item in ap_iter: | |
update_path = item['path'] | |
try: | |
update = pickle.load(open(update_path, 'rb')) | |
except Exception: | |
self.logger.exception('ERROR Pickle problem, skipping %s', | |
update_path) | |
continue | |
update_name = '%s/%s' % (update['account'], update['container']) | |
if self.filter_containers and ( | |
update_name not in self.filter_containers): | |
continue | |
if self.skip_containers and ( | |
update_name in self.skip_containers): | |
continue | |
yield item | |
if __name__ == '__main__': | |
parser = OptionParser("%prog CONFIG [options]") | |
parser.add_option('--container', default=[], action='append', | |
dest='filter_containers', | |
help="Only process specific AUTH_acct/container(s)") | |
parser.add_option('--skip', default=[], action='append', | |
dest='skip_containers', | |
help="Do not process skipped AUTH_acct/container(s)") | |
conf_file, options = parse_options(parser=parser, once=True) | |
PriorityObjectUpdater.filter_containers = set( | |
options.pop('filter_containers')) | |
PriorityObjectUpdater.skip_containers = set( | |
options.pop('skip_containers')) | |
run_daemon(PriorityObjectUpdater, conf_file, | |
section_name='object-updater', **options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment