]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm/iscsi: simplify the dashboard check
authorDimitri Savineau <dsavinea@redhat.com>
Fri, 23 Jul 2021 15:14:25 +0000 (11:14 -0400)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 10 Aug 2021 14:32:14 +0000 (16:32 +0200)
We don't need to run an extra command (mgr module ls) to obtain the mgr
modules list since we already have this information in the mgr_map.
This workflow is already done for the monitoring stack or for configuring
the iscsi integration within the dashboard (during creation) via the
config_dashboard method.

The mgr_map is mocked in the tests with the dashboard module enabled so we
don't need _mon_command_mock_mgr_module_ls anymore.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit a6808efca4535f10c5639ee0a6a517c110da3f44)

src/pybind/mgr/cephadm/services/iscsi.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index a36ad3bca16a6d40c9503ba8a280bcacfe21a038..3dd367b152862de119383bac846111a5e8efc36b 100644 (file)
@@ -8,7 +8,7 @@ from ipaddress import ip_address, IPv6Address
 from mgr_module import HandleCommandResult
 from ceph.deployment.service_spec import IscsiServiceSpec
 
-from orchestrator import DaemonDescription, DaemonDescriptionStatus, OrchestratorError
+from orchestrator import DaemonDescription, DaemonDescriptionStatus
 from .cephadmservice import CephadmDaemonDeploySpec, CephService
 from .. import utils
 
@@ -150,18 +150,7 @@ class IscsiService(CephService):
         """
         logger.debug(f'Post remove daemon {self.TYPE}.{daemon.daemon_id}')
 
-        ret, out, err = self.mgr.check_mon_command({
-            'prefix': 'mgr module ls',
-            'format': 'json',
-        })
-        try:
-            j = json.loads(out)
-        except ValueError:
-            msg = 'Failed to parse mgr module ls: Cannot decode JSON'
-            logger.exception('%s: \'%s\'' % (msg, out))
-            raise OrchestratorError('failed to parse mgr module ls')
-
-        if 'dashboard' in j['enabled_modules']:
+        if 'dashboard' in self.mgr.get('mgr_map')['modules']:
             # remove config for dashboard iscsi gateways
             ret, out, err = self.mgr.check_mon_command({
                 'prefix': 'dashboard iscsi-gateway-rm',
index 5b719063c1cd0c484ffb2446fda59d8a1e285441..d85e27ab9901f8209a5f36a24707021372507f86 100644 (file)
@@ -893,8 +893,6 @@ spec:
                 placement=ps)
             unmanaged_spec = ServiceSpec.from_json(spec.to_json())
             unmanaged_spec.unmanaged = True
-            cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({
-                                                                                      'enabled_modules': []})
             with with_service(cephadm_module, unmanaged_spec):
 
                 c = cephadm_module.add_daemon(spec)
@@ -1030,8 +1028,6 @@ spec:
     @mock.patch("subprocess.run", mock.MagicMock())
     def test_apply_save(self, spec: ServiceSpec, meth, cephadm_module: CephadmOrchestrator):
         with with_host(cephadm_module, 'test'):
-            cephadm_module._mon_command_mock_mgr_module_ls = lambda *args: json.dumps({
-                                                                                      'enabled_modules': []})
             with with_service(cephadm_module, spec, meth, 'test'):
                 pass