]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: save host cache data after scheduling daemon action 49863/head
authorAdam King <adking@redhat.com>
Mon, 17 Oct 2022 18:56:34 +0000 (14:56 -0400)
committerAdam King <adking@redhat.com>
Wed, 25 Jan 2023 00:45:54 +0000 (19:45 -0500)
Otherwise, the actions could be lost on a mgr failover
despite us including shceduled actions as part of the data
we store in the config-key entry for the host.

This also makes it impossible to redeploy the active mgr
with a new image in one command.

Fixes: https://tracker.ceph.com/issues/57884
Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit 2ff3ae71fac22f9267451442b9e43c49375e40e3)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py

index 178abd985d106894531f5263c5ba08560b94ec56..65253929892a9aa1212cd3177fb2ef20230818f9 100644 (file)
@@ -2040,6 +2040,7 @@ Then run the following:
             raise OrchestratorError(
                 f'Unable to schedule redeploy for {daemon_name}: No standby MGRs')
         self.cache.schedule_daemon_action(dd.hostname, dd.name(), action)
+        self.cache.save_host(dd.hostname)
         msg = "Scheduled to {} {} on host '{}'".format(action, daemon_name, dd.hostname)
         self._kick_serve_loop()
         return msg
index 0d737380af85aa5a988fc5576de4dee09567605f..2548b7a87a5cde27580109886e77aa8623644560 100644 (file)
@@ -404,7 +404,8 @@ class TestCephadm(object):
         ]
     )
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}'))
-    def test_daemon_check(self, cephadm_module: CephadmOrchestrator, action):
+    @mock.patch("cephadm.module.HostCache.save_host")
+    def test_daemon_check(self, _save_host, cephadm_module: CephadmOrchestrator, action):
         with with_host(cephadm_module, 'test'):
             with with_service(cephadm_module, ServiceSpec(service_type='grafana'), CephadmOrchestrator.apply_grafana, 'test') as d_names:
                 [daemon_name] = d_names
@@ -416,6 +417,7 @@ class TestCephadm(object):
 
                 CephadmServe(cephadm_module)._check_daemons()
 
+                assert _save_host.called_with('test')
                 assert cephadm_module.cache.get_scheduled_daemon_action('test', daemon_name) is None
 
     @mock.patch("cephadm.serve.CephadmServe._run_cephadm")