From: Jan Fajerski Date: Wed, 5 Feb 2020 05:01:16 +0000 (+0100) Subject: ceph-volume: strip _dmcrypt suffix in simple scan json output X-Git-Tag: v14.2.10~196^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33722%2Fhead;p=ceph.git ceph-volume: strip _dmcrypt suffix in simple scan json output LUKS encrypted OSDs name their block* files with a _dmcrypt suffix. activate fails on json files like this. Stripping this suffix in scan fixes this. Fixes: https://tracker.ceph.com/issues/43966 Signed-off-by: Jan Fajerski (cherry picked from commit 2ddf76d118d77659c590ea076d34ce9a8e351a86) --- diff --git a/src/ceph-volume/ceph_volume/devices/simple/scan.py b/src/ceph-volume/ceph_volume/devices/simple/scan.py index e9244d5b4e45..6e41f76ecb19 100644 --- a/src/ceph-volume/ceph_volume/devices/simple/scan.py +++ b/src/ceph-volume/ceph_volume/devices/simple/scan.py @@ -98,11 +98,16 @@ class Scan(object): raise RuntimeError( 'OSD files not found, required "keyring" file is not present at: %s' % path ) - for _file in os.listdir(path): - file_path = os.path.join(path, _file) + for file_ in os.listdir(path): + file_path = os.path.join(path, file_) + file_json_key = file_ + if file_.endswith('_dmcrypt'): + file_json_key = file_.rstrip('_dmcrypt') + logger.info(('reading file {}, stripping _dmcrypt', + 'suffix').format(file_)) if os.path.islink(file_path): if os.path.exists(file_path): - osd_metadata[_file] = self.scan_device(file_path) + osd_metadata[file_json_key] = self.scan_device(file_path) else: msg = 'broken symlink found %s -> %s' % (file_path, os.path.realpath(file_path)) terminal.warning(msg) @@ -126,9 +131,9 @@ class Scan(object): if 'keyring' in file_path: content = parse_keyring(content) try: - osd_metadata[_file] = int(content) + osd_metadata[file_json_key] = int(content) except ValueError: - osd_metadata[_file] = content + osd_metadata[file_json_key] = content # we must scan the paths again because this might be a temporary mount path_mounts = system.get_mounts(paths=True)