]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: deploy pending_key when possible
authorSage Weil <sage@newdream.net>
Mon, 25 Oct 2021 20:00:42 +0000 (16:00 -0400)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 12 Sep 2022 17:03:17 +0000 (17:03 +0000)
Also, leave out the caps.

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/pybind/mgr/cephadm/services/cephadmservice.py
src/pybind/mgr/cephadm/tests/test_services.py

index ff9d926791701abc33677796f5e676cfbfa8016b..eac46f6c378a87802d0f1b14bce413aadd91847e 100644 (file)
@@ -244,7 +244,22 @@ class CephadmService(metaclass=ABCMeta):
                 'entity': entity,
             })
             if err:
-                self.mgr.log.warning(f"Unable to fetch keyring for {entity}")
+                raise OrchestratorError(f"Unable to fetch keyring for {entity}: {err}")
+
+        # strip down keyring
+        #  - don't include caps (auth get includes them; get-or-create does not)
+        #  - use pending key if present
+        key = None
+        for line in keyring.splitlines():
+            if ' = ' not in line:
+                continue
+            line = line.strip()
+            (ls, rs) = line.split(' = ', 1)
+            if ls == 'key' and not key:
+                key = rs
+            if ls == 'pending key':
+                key = rs
+        keyring = f'[{entity}]\nkey = {key}\n'
         return keyring
 
     def _inventory_get_fqdn(self, hostname: str) -> str:
index 22e58317af0d7b6d821c518ffaab67fa98526fde..1db3e91a24f9052e72774ea649006502fc59ddcd 100644 (file)
@@ -45,6 +45,8 @@ class FakeMgr:
         if prefix == 'set-cmd':
             self.config = cmd_dict.get('value')
             return 0, 'value set', ''
+        if prefix in ['auth get']:
+            return 0, '[foo]\nkeyring = asdf\n', ''
         return -1, '', 'error'
 
     def get_minimal_ceph_conf(self) -> str:
@@ -185,9 +187,12 @@ class TestISCSIService:
         expected_call2 = call({'prefix': 'auth caps',
                                'entity': 'client.iscsi.a',
                                'caps': expected_caps})
+        expected_call3 = call({'prefix': 'auth get',
+                               'entity': 'client.iscsi.a'})
 
         assert expected_call in self.mgr.mon_command.mock_calls
         assert expected_call2 in self.mgr.mon_command.mock_calls
+        assert expected_call3 in self.mgr.mon_command.mock_calls
 
     @patch('cephadm.utils.resolve_ip')
     def test_iscsi_dashboard_config(self, mock_resolve_ip):