From 20990a0eb86ded1de655e4dc1089d86ca086b195 Mon Sep 17 00:00:00 2001 From: Timothy Q Nguyen Date: Thu, 6 Nov 2025 18:11:30 -0800 Subject: [PATCH] mgr/cephadm: mon public network updating Currently when a new public network is set for mon daemons and the mon daemons are restarted, the new public network is still not applied. This is because the public network config doesn't update dynamically and it requires the mon daemon to be redeployed for the change to take effect. People assume that restarting the mon daemon should apply the change so my code adds a function to check if the mon daemon public network config has been changed and has not been applied yet. This function is then called in _daemon_action to reroute a restart request to the redeploy request process, essentially turning the restart into a redeploy to update the public network. Signed-off-by: Timothy Q Nguyen --- src/pybind/mgr/cephadm/module.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index c815bbb12879..3df2387cd433 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2666,6 +2666,36 @@ Then run the following: return f'Rotated key for {daemon_spec.name()}' + def _mon_public_network_changed(self, daemon_spec: CephadmDaemonDeploySpec) -> bool: + if daemon_spec.daemon_type != 'mon': + return False + + rc_get, out_get, err_get = self.mon_command({ + 'prefix': 'config get', + 'who': f'{daemon_spec.service_name}.{daemon_spec.daemon_id}', + 'key': 'public_network' + }) + + if rc_get: + self.log.error(f'cmd: config get failed with: {err_get}, (errno:{rc_get})') + return False + + rc_show, out_show, err_show = self.mon_command({ + 'prefix': 'config show', + 'who': f'{daemon_spec.service_name}.{daemon_spec.daemon_id}', + 'key': 'public_network' + }) + + if rc_show: + self.log.error(f'cmd: config get failed with: {err_show}, (errno:{rc_show})') + return False + + if out_get == out_show: + return False + + self.log.debug(f'{daemon_spec.service_name}.{daemon_spec.daemon_id} public network changed, redeploy instead of restart') + return True + def _daemon_action(self, daemon_spec: CephadmDaemonDeploySpec, action: str, @@ -2681,7 +2711,7 @@ Then run the following: if action == 'rotate-key': return self._rotate_daemon_key(daemon_spec) - if action == 'redeploy' or action == 'reconfig': + if action == 'redeploy' or action == 'reconfig' or (action == 'restart' and self._mon_public_network_changed(daemon_spec)): if daemon_spec.daemon_type != 'osd': daemon_spec = service_registry.get_service(daemon_type_to_service( daemon_spec.daemon_type)).prepare_create(daemon_spec) -- 2.47.3