]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: modify get_key_from_keyfile() in mount.py 40434/head
authorRishabh Dave <ridave@redhat.com>
Fri, 26 Mar 2021 11:32:38 +0000 (17:02 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 3 Jun 2022 04:10:28 +0000 (09:40 +0530)
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 <ridave@redhat.com>
qa/tasks/cephfs/mount.py

index bb27b61d687f5462548c8a65ee03ab7f2e95691f..f1691455a89e9fb287eaf4b285005717733164fe 100644 (file)
@@ -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):
         """