]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: move _apply_all_services to serve.py
authorSebastian Wagner <sebastian.wagner@suse.com>
Fri, 11 Sep 2020 11:21:29 +0000 (13:21 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Wed, 18 Nov 2020 10:52:17 +0000 (11:52 +0100)
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit 3ff6a38c48aa5a113148f682af92389b13bd42aa)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/serve.py
src/pybind/mgr/cephadm/tests/fixtures.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/cephadm/tests/test_migration.py

index 06cd08997ff689cc054983c6a40eb1c55ce4a93b..da93918d5b6de666606a1bbad8d5abb0d932870d 100644 (file)
@@ -1980,22 +1980,6 @@ To check that the host is reachable:
             r = False
         return r
 
-    def _apply_all_services(self):
-        r = False
-        specs = []  # type: List[ServiceSpec]
-        for sn, spec in self.spec_store.specs.items():
-            specs.append(spec)
-        for spec in specs:
-            try:
-                if self._apply_service(spec):
-                    r = True
-            except Exception as e:
-                self.log.exception('Failed to apply %s spec %s: %s' % (
-                    spec.service_name(), spec, e))
-                self.events.for_service(spec, 'ERROR', 'Failed to apply: ' + str(e))
-
-        return r
-
     def _check_pool_exists(self, pool, service_name):
         logger.info(f'Checking pool "{pool}" exists for service {service_name}')
         if not self.rados.pool_exists(pool):
index 74cb760c086a9d5d116a7f793e42ef7894e290ab..f00e61f2167a45007d4f9653dd73efd65dce7019 100644 (file)
@@ -10,6 +10,7 @@ except ImportError:
     remoto = None
 
 from ceph.deployment import inventory
+from ceph.deployment.service_spec import ServiceSpec
 
 import orchestrator
 from cephadm.utils import forall_hosts, cephadmNoImage, str_to_datetime
@@ -63,7 +64,7 @@ class CephadmServe:
                     if self.mgr.migration.is_migration_ongoing():
                         continue
 
-                    if self.mgr._apply_all_services():
+                    if self._apply_all_services():
                         continue  # did something, refresh
 
                     self.mgr._check_daemons()
@@ -369,3 +370,19 @@ class CephadmServe:
                     'detail': daemon_detail,
                 }
         self.mgr.set_health_checks(self.mgr.health_checks)
+
+    def _apply_all_services(self) -> bool:
+        r = False
+        specs = []  # type: List[ServiceSpec]
+        for sn, spec in self.mgr.spec_store.specs.items():
+            specs.append(spec)
+        for spec in specs:
+            try:
+                if self.mgr._apply_service(spec):
+                    r = True
+            except Exception as e:
+                self.log.exception('Failed to apply %s spec %s: %s' % (
+                    spec.service_name(), spec, e))
+                self.mgr.events.for_service(spec, 'ERROR', 'Failed to apply: ' + str(e))
+
+        return r
index c263c81bfc78248f06e9c1d64d4295ae7a0a2998..5548c53e2efe1400376872ddbc6a09dbf8feee52 100644 (file)
@@ -126,7 +126,7 @@ def with_host(m: CephadmOrchestrator, name, refresh_hosts=True):
 
 def assert_rm_service(cephadm, srv_name):
     assert wait(cephadm, cephadm.remove_service(srv_name)) == f'Removed service {srv_name}'
-    cephadm._apply_all_services()
+    CephadmServe(cephadm)._apply_all_services()
 
 
 @contextmanager
@@ -138,7 +138,7 @@ def with_service(cephadm_module: CephadmOrchestrator, spec: ServiceSpec, meth, h
     specs = [d.spec for d in wait(cephadm_module, cephadm_module.describe_service())]
     assert spec in specs
 
-    cephadm_module._apply_all_services()
+    CephadmServe(cephadm_module)._apply_all_services()
 
     dds = wait(cephadm_module, cephadm_module.list_daemons())
     own_dds = [dd for dd in dds if dd.service_name() == spec.service_name()]
index cb98bf46bb2a953b0ec999c568954248fa247ce3..143ce9206df4602250a805fd6b6401bff1c8149e 100644 (file)
@@ -409,7 +409,7 @@ class TestCephadm(object):
 
             _run_cephadm.return_value = (['{}'], '', 0)
 
-            assert cephadm_module._apply_all_services() == False
+            assert CephadmServe(cephadm_module)._apply_all_services() == False
 
             _run_cephadm.assert_any_call(
                 'test', 'osd', 'ceph-volume',
@@ -738,7 +738,7 @@ class TestCephadm(object):
             c = cephadm_module.apply_mds(spec)
             out = wait(cephadm_module, c)
             match_glob(out, "Scheduled mds.fsname update...")
-            cephadm_module._apply_all_services()
+            CephadmServe(cephadm_module)._apply_all_services()
 
             [daemon] = cephadm_module.cache.daemons['host1'].keys()
 
@@ -749,7 +749,7 @@ class TestCephadm(object):
             c = cephadm_module.apply_mds(spec)
             out = wait(cephadm_module, c)
             match_glob(out, "Scheduled mds.fsname update...")
-            cephadm_module._apply_all_services()
+            CephadmServe(cephadm_module)._apply_all_services()
 
             ok_to_stop.assert_called_with([daemon[4:]])
 
index 4b86c22467320efbc484aef57128a275678c58a2..8536c4e19622621f46119a96a80828779adebbef 100644 (file)
@@ -26,7 +26,7 @@ def test_migrate_scheduler(cephadm_module: CephadmOrchestrator):
             assert wait(cephadm_module, c) == 'Scheduled rgw.r.z update...'
 
             # with pytest.raises(OrchestratorError, match="cephadm migration still ongoing. Please wait, until the migration is complete."):
-            cephadm_module._apply_all_services()
+            CephadmServe(cephadm_module)._apply_all_services()
 
             cephadm_module.migration_current = 0
             cephadm_module.migration.migrate()
@@ -36,7 +36,7 @@ def test_migrate_scheduler(cephadm_module: CephadmOrchestrator):
             CephadmServe(cephadm_module)._refresh_hosts_and_daemons()
             cephadm_module.migration.migrate()
 
-            cephadm_module._apply_all_services()
+            CephadmServe(cephadm_module)._apply_all_services()
 
             out = {o.hostname for o in wait(cephadm_module, cephadm_module.list_daemons())}
             assert out == {'host1', 'host2'}