From 2ddf76d118d77659c590ea076d34ce9a8e351a86 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Wed, 5 Feb 2020 06:01:16 +0100 Subject: [PATCH] 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 --- .../ceph_volume/devices/simple/scan.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/simple/scan.py b/src/ceph-volume/ceph_volume/devices/simple/scan.py index e9244d5b4e4..6e41f76ecb1 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) -- 2.39.5