mgr/cephadm/iscsi: simplify the dashboard check

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>
This commit is contained in:
Dimitri Savineau 2021-07-23 11:14:25 -04:00
parent 9054b1a7f7
commit a6808efca4
2 changed files with 2 additions and 17 deletions

View 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',

View File

@ -891,8 +891,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)
@ -1026,8 +1024,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