Last active
December 23, 2019 21:27
-
-
Save clayg/a01965d36ce0205a2b90364430802b62 to your computer and use it in GitHub Desktop.
make fresh tombstones over dark data fragments that can not be rebuilt (even if the container is deleted)
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 argparse import ArgumentParser | |
import sys | |
from swift.common.internal_client import InternalClient | |
from swift.common.wsgi import ConfigString | |
from swift.container.sync import ic_conf_body | |
from swift.proxy.controllers.base import Controller | |
parser = ArgumentParser() | |
parser.add_argument('account', help='the account name') | |
parser.add_argument('container', help='the container name') | |
parser.add_argument('object', help='the object name') | |
parser.add_argument('-P', '--policy-index', type=int, default=None, | |
help='override the container storage policy index') | |
def main(): | |
opts = parser.parse_args() | |
swift = InternalClient(ConfigString(ic_conf_body), | |
'internal-terminator', 1) | |
_orig_get_container_info = Controller.container_info | |
def fix_container_nodes(*args, **kwargs): | |
info = _orig_get_container_info(*args, **kwargs) | |
part, nodes = swift.container_ring.get_nodes( | |
opts.account, opts.container) | |
info['partition'] = part | |
info['nodes'] = nodes | |
return info | |
Controller.container_info = fix_container_nodes | |
headers = None | |
if opts.policy_index is not None: | |
headers = { | |
"X-Backend-Storage-Policy-Index": opts.policy_index, | |
} | |
swift.delete_object(opts.account, opts.container, opts.object, | |
headers=headers) | |
print('Hasta la vista, baby.') | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment