Created
July 12, 2019 16:46
-
-
Save clayg/5cbb0bbb7949df1cacfe8a099491bdf8 to your computer and use it in GitHub Desktop.
find shard containers and make them resync their misplaced objects to the reconciler queue
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 python3 | |
import sys | |
import os | |
import errno | |
from argparse import ArgumentParser | |
from swift.container.backend import ContainerBroker | |
parser = ArgumentParser() | |
parser.add_argument('-v', '--verbose', help='line oriented output', | |
default=False, action='store_true') | |
parser.add_argument('devices', help='root of devices tree for node', | |
nargs='*', default=['/srv/node']) | |
DATADIR = 'containers' | |
def check_db(db_path): | |
broker = ContainerBroker(db_path) | |
print(f'Inspecting db for {broker.path}') | |
if broker.account.startswith('.shards_'): | |
existing_sync_point = broker.get_reconciler_sync() | |
print(f"Found {db_path} reset {existing_sync_point} to -1") | |
broker.update_reconciler_sync(-1) | |
def main(): | |
args = parser.parse_args() | |
for device_root in args.devices: | |
device_dirs = os.listdir(device_root) | |
for device_dir in device_dirs: | |
parts_dir = os.path.join(device_root, device_dir, DATADIR) | |
try: | |
parts = os.listdir(parts_dir) | |
except OSError as e: | |
if e.errno == errno.ENOENT: | |
continue | |
else: | |
raise | |
for part in parts: | |
if not part.isdigit(): | |
continue | |
suffs_dir = os.path.join(parts_dir, part) | |
try: | |
suffs = os.listdir(suffs_dir) | |
except OSError as e: | |
if e.errno == errno.ENOENT: | |
continue | |
else: | |
raise | |
for suff in suffs: | |
hashes_dir = os.path.join(suffs_dir, suff) | |
try: | |
hashes = os.listdir(hashes_dir) | |
except OSError as e: | |
if e.errno == errno.ENOENT: | |
continue | |
else: | |
raise | |
for hash_ in hashes: | |
db_path = os.path.join(hashes_dir, hash_, '%s.db' % hash_) | |
check_db(db_path) | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment