]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: Add CEPHADM_PAUSED to test_cli
authorSebastian Wagner <sebastian.wagner@suse.com>
Tue, 30 Jun 2020 13:13:51 +0000 (15:13 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 23 Jul 2020 13:20:10 +0000 (15:20 +0200)
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit aee1aed64131e615bbf5b9453f52fec5eef36bf9)

qa/tasks/cephadm_cases/test_cli.py
src/pybind/mgr/cephadm/module.py

index b06e276b1a920db498e248b42c47b0987125eac8..3d39902a09b79ef2e7bbfc683d4a533102f07fc5 100644 (file)
@@ -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)
index 73459d3f2336b265f7f6fab9ee4664e35c66ee20..6e8824e5c927ee7f30f8127bab24aca03f34b5b7 100644 (file)
@@ -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.