Skip to content

Commit

Permalink
Merge pull request ceph#47521 from adk3798/iscsi-ip-list
Browse files Browse the repository at this point in the history
mgr/cephadm: reconfig iscsi daemons if trusted_ip_list changes

Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Redouane Kachach <[email protected]>
  • Loading branch information
adk3798 authored Sep 13, 2022
2 parents 821e90e + 8a6e67c commit 2bdccfd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ceph.deployment.service_spec import \
ServiceSpec, PlacementSpec, \
HostPlacementSpec, IngressSpec, \
TunedProfileSpec, PrometheusSpec
TunedProfileSpec, PrometheusSpec, IscsiServiceSpec
from ceph.utils import str_to_datetime, datetime_to_str, datetime_now
from cephadm.serve import CephadmServe
from cephadm.services.cephadmservice import CephadmDaemonDeploySpec
Expand Down Expand Up @@ -587,6 +587,7 @@ def __init__(self, *args: Any, **kwargs: Any):

self.mgr_service: MgrService = cast(MgrService, self.cephadm_services['mgr'])
self.osd_service: OSDService = cast(OSDService, self.cephadm_services['osd'])
self.iscsi_service: IscsiService = cast(IscsiService, self.cephadm_services['iscsi'])

self.template = TemplateMgr(self)

Expand Down Expand Up @@ -2420,8 +2421,11 @@ def _calc_daemon_deps(self,
deps = sorted([self.get_mgr_ip(), server_port, root_cert,
str(self.device_enhanced_scan)])
elif daemon_type == 'iscsi':
deps = [self.get_mgr_ip()]

if spec:
iscsi_spec = cast(IscsiServiceSpec, spec)
deps = [self.iscsi_service.get_trusted_ips(iscsi_spec)]
else:
deps = [self.get_mgr_ip()]
elif daemon_type == 'prometheus':
# for prometheus we add the active mgr as an explicit dependency,
# this way we force a redeploy after a mgr failover
Expand Down
16 changes: 10 additions & 6 deletions src/pybind/mgr/cephadm/services/iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def config(self, spec: IscsiServiceSpec) -> None: # type: ignore
assert spec.pool
self.mgr._check_pool_exists(spec.pool, spec.service_name())

def get_trusted_ips(self, spec: IscsiServiceSpec) -> str:
# 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()
return trusted_ip_list

def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonDeploySpec:
assert self.TYPE == daemon_spec.daemon_type

Expand Down Expand Up @@ -58,11 +66,7 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
'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()
trusted_ip_list = self.get_trusted_ips(spec)

context = {
'client_name': '{}.{}'.format(utils.name_to_config_section('iscsi'), igw_id),
Expand All @@ -74,7 +78,7 @@ def prepare_create(self, daemon_spec: CephadmDaemonDeploySpec) -> CephadmDaemonD
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()]
daemon_spec.deps = [trusted_ip_list]
return daemon_spec

def config_dashboard(self, daemon_descrs: List[DaemonDescription]) -> None:
Expand Down

0 comments on commit 2bdccfd

Please sign in to comment.