]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: mon public network updating
authorTimothy Q Nguyen <timqn22@gmail.com>
Fri, 7 Nov 2025 02:11:30 +0000 (18:11 -0800)
committerTimothy Q Nguyen <timqn22@gmail.com>
Wed, 4 Mar 2026 18:33:20 +0000 (10:33 -0800)
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 <timqn22@gmail.com>
src/pybind/mgr/cephadm/module.py

index c815bbb128798dbb35511bbbc6a44448c91c22b2..3df2387cd433c5676bfb1093ee6073b574230641 100644 (file)
@@ -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)