From cda82c98a32f51cb392fc51ba854bcae409567f8 Mon Sep 17 00:00:00 2001 From: Daniel Pivonka Date: Tue, 21 Sep 2021 16:04:51 -0400 Subject: [PATCH] mgr/cephadm: populate trusted_ip_list in iscsi-gateway.cfg with mgr ips Iscsi gateways do not show "UP" in dashboard without this fixes: https://tracker.ceph.com/issues/52692 Signed-off-by: Daniel Pivonka --- src/pybind/mgr/cephadm/module.py | 2 ++ src/pybind/mgr/cephadm/services/iscsi.py | 10 ++++++++-- .../templates/services/iscsi/iscsi-gateway.cfg.j2 | 2 +- src/pybind/mgr/cephadm/tests/test_cephadm.py | 1 + src/pybind/mgr/cephadm/tests/test_services.py | 3 +++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 5ddfa436f1a86..9bd4149ed3edf 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2270,6 +2270,8 @@ Then run the following: pass deps = sorted([self.get_mgr_ip(), self.inventory.get_addr(daemon_id), str(self.endpoint_port), root_cert, str(self.get_module_option('device_enhanced_scan'))]) + elif daemon_type == 'iscsi': + deps = [self.get_mgr_ip()] else: need = { 'prometheus': ['mgr', 'alertmanager', 'node-exporter', 'ingress'], diff --git a/src/pybind/mgr/cephadm/services/iscsi.py b/src/pybind/mgr/cephadm/services/iscsi.py index 750ed956f8532..fa54fa053a4f5 100644 --- a/src/pybind/mgr/cephadm/services/iscsi.py +++ b/src/pybind/mgr/cephadm/services/iscsi.py @@ -58,17 +58,23 @@ class IscsiService(CephService): 'val': key_data, }) + # add active mgr ip address to trusted list so dashboard can access + trusted_ip_list = spec.trusted_ip_list if spec.trusted_ip_list else '' + if trusted_ip_list: + trusted_ip_list += ',' + trusted_ip_list += self.mgr.get_mgr_ip() + context = { 'client_name': '{}.{}'.format(utils.name_to_config_section('iscsi'), igw_id), + 'trusted_ip_list': trusted_ip_list, 'spec': spec } igw_conf = self.mgr.template.render('services/iscsi/iscsi-gateway.cfg.j2', context) daemon_spec.keyring = keyring daemon_spec.extra_files = {'iscsi-gateway.cfg': igw_conf} - daemon_spec.final_config, daemon_spec.deps = self.generate_config(daemon_spec) - + daemon_spec.deps = [self.mgr.get_mgr_ip()] return daemon_spec def config_dashboard(self, daemon_descrs: List[DaemonDescription]) -> None: diff --git a/src/pybind/mgr/cephadm/templates/services/iscsi/iscsi-gateway.cfg.j2 b/src/pybind/mgr/cephadm/templates/services/iscsi/iscsi-gateway.cfg.j2 index 2bc13451d65d8..c2582ace7af35 100644 --- a/src/pybind/mgr/cephadm/templates/services/iscsi/iscsi-gateway.cfg.j2 +++ b/src/pybind/mgr/cephadm/templates/services/iscsi/iscsi-gateway.cfg.j2 @@ -2,7 +2,7 @@ [config] cluster_client_name = {{ client_name }} pool = {{ spec.pool }} -trusted_ip_list = {{ spec.trusted_ip_list|default("''", true) }} +trusted_ip_list = {{ trusted_ip_list|default("''", true) }} minimum_gateways = 1 api_port = {{ spec.api_port|default("''", true) }} api_user = {{ spec.api_user|default("''", true) }} diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 50628ca3f78b9..7d75ad59df32f 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -911,6 +911,7 @@ spec: @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) @mock.patch("subprocess.run", None) @mock.patch("cephadm.module.CephadmOrchestrator.rados", mock.MagicMock()) + @mock.patch("cephadm.module.CephadmOrchestrator.get_mgr_ip", lambda _: '1.2.3.4') def test_iscsi(self, cephadm_module): with with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) diff --git a/src/pybind/mgr/cephadm/tests/test_services.py b/src/pybind/mgr/cephadm/tests/test_services.py index 2c32dffd9738a..4f1bafafd01e2 100644 --- a/src/pybind/mgr/cephadm/tests/test_services.py +++ b/src/pybind/mgr/cephadm/tests/test_services.py @@ -42,6 +42,9 @@ class FakeMgr: def get_minimal_ceph_conf(self) -> str: return '' + def get_mgr_ip(self) -> str: + return '1.2.3.4' + class TestCephadmService: def test_set_service_url_on_dashboard(self): -- 2.39.5