From: Adam King Date: Mon, 17 Oct 2022 18:56:34 +0000 (-0400) Subject: mgr/cephadm: save host cache data after scheduling daemon action X-Git-Tag: v17.2.6~57^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8042cb92ef3a702de77b9cb70cbe5849d034ef9c;p=ceph.git mgr/cephadm: save host cache data after scheduling daemon action 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 (cherry picked from commit 2ff3ae71fac22f9267451442b9e43c49375e40e3) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 178abd985d10..65253929892a 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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 diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 0d737380af85..2548b7a87a5c 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -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")