]> git-server-git.apps.pok.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)
committerNathan Cutler <ncutler@suse.com>
Tue, 6 Oct 2020 09:40:53 +0000 (11:40 +0200)
add more context than simply passing the `daemon_id`

Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit 183f7c34a303333fa5fdfbfa79f18bed725c3a83)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/services/cephadmservice.py

index 0f3b0c9b0e88284fb58221043630082fd0a387f1..26d3b2c0d3b89309353a279b4d91951ac21cba0e 100644 (file)
@@ -2035,14 +2035,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))
@@ -2053,7 +2053,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