]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: pass `DaemonDescription` during pre/post remove
authorMichael Fritch <mfritch@suse.com>
Fri, 11 Sep 2020 14:10:26 +0000 (08:10 -0600)
committerMichael Fritch <mfritch@suse.com>
Fri, 11 Sep 2020 14:10:26 +0000 (08:10 -0600)
add more context than simply passing the `daemon_id`

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/cephadmservice.py

index d188637baa425629990d6f54ac34f1a177a5daf0..24d3eb9e46d53b273a6090a4d9e5d376b046ae58 100644 (file)
@@ -2038,14 +2038,14 @@ To check that the host is reachable:
         Remove a daemon
         """
         (daemon_type, daemon_id) = name.split('.', 1)
+        daemon = orchestrator.DaemonDescription(
+            daemon_type=daemon_type,
+            daemon_id=daemon_id,
+            hostname=host)
 
-        with set_exception_subject('service', orchestrator.DaemonDescription(
-                daemon_type=daemon_type,
-                daemon_id=daemon_id,
-                hostname=host,
-        ).service_id(), overwrite=True):
+        with set_exception_subject('service', daemon.service_id(), overwrite=True):
 
-            self.cephadm_services[daemon_type].pre_remove(daemon_id)
+            self.cephadm_services[daemon_type].pre_remove(daemon)
 
             args = ['--name', name, '--force']
             self.log.info('Removing daemon %s from %s' % (name, host))
@@ -2056,7 +2056,7 @@ To check that the host is reachable:
                 self.cache.rm_daemon(host, name)
             self.cache.invalidate_host_daemons(host)
 
-            self.cephadm_services[daemon_type].post_remove(daemon_id)
+            self.cephadm_services[daemon_type].post_remove(daemon)
 
             return "Removed {} from host '{}'".format(name, host)
 
index 73b7c88d3c5c4bbfe2c6c9d22045d1aab28b2095..0593b39d9693097975313db257eb093d9bfaad05 100644 (file)
@@ -212,17 +212,19 @@ class CephadmService(metaclass=ABCMeta):
         logger.info(out)
         return HandleCommandResult(r.retval, out, r.stderr)
 
-    def pre_remove(self, daemon_id: str) -> None:
+    def pre_remove(self, daemon: DaemonDescription) -> None:
         """
         Called before the daemon is removed.
         """
-        logger.debug(f'Pre remove daemon {self.TYPE}.{daemon_id}')
+        assert self.TYPE == daemon.daemon_type
+        logger.debug(f'Pre remove daemon {self.TYPE}.{daemon.daemon_id}')
 
-    def post_remove(self, daemon_id: str) -> None:
+    def post_remove(self, daemon: DaemonDescription) -> None:
         """
         Called after the daemon is removed.
         """
-        logger.debug(f'Post remove daemon {self.TYPE}.{daemon_id}')
+        assert self.TYPE == daemon.daemon_type
+        logger.debug(f'Post remove daemon {self.TYPE}.{daemon.daemon_id}')
 
 
 class CephService(CephadmService):
@@ -359,8 +361,10 @@ class MonService(CephService):
         raise OrchestratorError(
             'Removing %s would break mon quorum (new quorum %s, new mons %s)' % (mon_id, new_quorum, new_mons))
 
-    def pre_remove(self, daemon_id: str) -> None:
-        super().pre_remove(daemon_id)
+    def pre_remove(self, daemon: DaemonDescription) -> None:
+        super().pre_remove(daemon)
+
+        daemon_id: str = daemon.daemon_id
         self._check_safe_to_destroy(daemon_id)
 
         # remove mon from quorum before we destroy the daemon