diff --git a/qa/tasks/cephadm_cases/test_cli.py b/qa/tasks/cephadm_cases/test_cli.py index b06e276b1a9..3d39902a09b 100644 --- a/qa/tasks/cephadm_cases/test_cli.py +++ b/qa/tasks/cephadm_cases/test_cli.py @@ -37,3 +37,9 @@ class TestCephadmCLI(MgrTestCase): out = self._orch_cmd('status', '--format', 'yaml') self.assertNotIn('!!python', out) + + def test_pause(self): + self._orch_cmd('pause') + self.wait_for_health('CEPHADM_PAUSED', 30) + self._orch_cmd('resume') + self.wait_for_health_clear(30) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 73459d3f233..6e8824e5c92 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -467,8 +467,13 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): ret = self.event.wait(sleep_interval) self.event.clear() - def serve(self): - # type: () -> None + def serve(self) -> None: + """ + The main loop of cephadm. + + A command handler will typically change the declarative state + of cephadm. This loop will then attempt to apply this new state. + """ self.log.debug("serve starting") while self.run: @@ -480,19 +485,9 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self._check_for_strays() - if self.paused: - self.health_checks['CEPHADM_PAUSED'] = { - 'severity': 'warning', - 'summary': 'cephadm background work is paused', - 'count': 1, - 'detail': ["'ceph orch resume' to resume"], - } - self.set_health_checks(self.health_checks) - else: - if 'CEPHADM_PAUSED' in self.health_checks: - del self.health_checks['CEPHADM_PAUSED'] - self.set_health_checks(self.health_checks) + self._update_paused_health() + if not self.paused: self.rm_util._remove_osds_bg() self.migration.migrate() @@ -520,6 +515,20 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule): self._serve_sleep() self.log.debug("serve exit") + def _update_paused_health(self): + if self.paused: + self.health_checks['CEPHADM_PAUSED'] = { + 'severity': 'warning', + 'summary': 'cephadm background work is paused', + 'count': 1, + 'detail': ["'ceph orch resume' to resume"], + } + self.set_health_checks(self.health_checks) + else: + if 'CEPHADM_PAUSED' in self.health_checks: + del self.health_checks['CEPHADM_PAUSED'] + self.set_health_checks(self.health_checks) + def config_notify(self): """ This method is called whenever one of our config options is changed.