From f58bcac7cb6d320d20d72942bbc8c7ea7dd44316 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Fri, 26 Mar 2021 17:02:38 +0530 Subject: [PATCH] qa/cephfs: modify get_key_from_keyfile() in mount.py CephFSMount.get_key_from_keyfile() should raise an exception instead of returning None if key is not found in keyring file. Fixes: https://tracker.ceph.com/issues/50010 Signed-off-by: Rishabh Dave --- qa/tasks/cephfs/mount.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index bb27b61d687f5..f1691455a89e9 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -577,13 +577,17 @@ class CephFSMount(object): def get_key_from_keyfile(self): # XXX: don't call run_shell(), since CephFS might be unmounted. - keyring = self.client_remote.run( - args=['sudo', 'cat', self.client_keyring_path], stdout=StringIO(), - omit_sudo=False).stdout.getvalue() + keyring = self.client_remote.read_file(self.client_keyring_path).\ + decode() + for line in keyring.split('\n'): if line.find('key') != -1: return line[line.find('=') + 1 : ].strip() + raise RuntimeError('Key not found in keyring file ' + f'{self.client_keyring_path}. Its contents are -\n' + f'{keyring}') + @property def config_path(self): """ -- 2.39.5