From: Timothy Q Nguyen Date: Fri, 7 Nov 2025 02:11:30 +0000 (-0800) Subject: mgr/cephadm: mon public network updating X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=20990a0eb86ded1de655e4dc1089d86ca086b195;p=ceph.git 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 --- 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)