]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/orch: add --force arg to 'daemon rm'
authorSage Weil <sage@redhat.com>
Wed, 12 Feb 2020 21:59:05 +0000 (15:59 -0600)
committerSage Weil <sage@redhat.com>
Thu, 13 Feb 2020 15:43:38 +0000 (09:43 -0600)
This is needed when removing mons.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py

index 648d01adcf45ab916e3bfaf2714e11d87123a514..53cb3596eec2c928ce060a6989069f8c7308f6ac 100644 (file)
@@ -1454,15 +1454,17 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             daemon_type=daemon_type,
             daemon_id=daemon_id).then(_proc_daemons)
 
-    def remove_daemons(self, names):
-        # type: (List[str]) -> orchestrator.Completion
+    def remove_daemons(self, names, force):
+        # type: (List[str], bool) -> orchestrator.Completion
         def _filter(daemons):
             args = []
             for d in daemons:
                 for name in names:
                     if d.name() == name:
                         args.append(
-                            ('%s.%s' % (d.daemon_type, d.daemon_id), d.nodename)
+                            ('%s.%s' % (d.daemon_type, d.daemon_id),
+                             d.nodename,
+                             force)
                         )
             if not args:
                 raise OrchestratorError('Unable to find daemon(s) %s' % (names))
@@ -1769,13 +1771,16 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
             'Reconfigured' if reconfig else 'Deployed', name, host)
 
     @async_map_completion
-    def _remove_daemon(self, name, host):
+    def _remove_daemon(self, name, host, force=False):
         """
         Remove a daemon
         """
+        self.log.debug('_remove_daemon %s on %s force=%s' % (name, host, force))
+        args = ['--name', name]
+        if force:
+            args.extend(['--force'])
         out, err, code = self._run_cephadm(
-            host, name, 'rm-daemon',
-            ['--name', name])
+            host, name, 'rm-daemon', args)
         self.log.debug('_remove_daemon code %s out %s' % (code, out))
         if not code and host in self.daemon_cache:
             # remove item from cache
index f555cbf6205aaa5cdd0632e739f7a6c9f571e483..e201c5b29b9fe58f11e95904654bd1f1f129e22e 100644 (file)
@@ -151,7 +151,7 @@ class TestCephadm(object):
         with self._with_host(cephadm_module, 'test'):
             c = cephadm_module.list_daemons(refresh=True)
             wait(cephadm_module, c)
-            c = cephadm_module.remove_daemons(['osd.0'])
+            c = cephadm_module.remove_daemons(['osd.0'], False)
             out = wait(cephadm_module, c)
             assert out == ["Removed osd.0 from host 'test'"]
 
@@ -237,7 +237,7 @@ class TestCephadm(object):
         with self._with_host(cephadm_module, 'test'):
             c = cephadm_module.list_daemons(refresh=True)
             wait(cephadm_module, c)
-            c = cephadm_module.remove_daemons(['rgw.myrgw.myhost.myid'])
+            c = cephadm_module.remove_daemons(['rgw.myrgw.myhost.myid'], False)
             out = wait(cephadm_module, c)
             assert out == ["Removed rgw.myrgw.myhost.myid from host 'test'"]
 
index 1621d091a4500ea2ab6cb8d84a2a1f6c470a3bca..08868c7f8ce04368aa877d0f8fd7d3c2cee90f78 100644 (file)
@@ -878,8 +878,8 @@ class Orchestrator(object):
         """
         raise NotImplementedError()
 
-    def remove_daemons(self, names):
-        # type: (List[str]) -> Completion
+    def remove_daemons(self, names, force):
+        # type: (List[str], bool) -> Completion
         """
         Remove specific daemon(s).
 
index 233c862d5e82506816f632e54484c1af70a0a02d..66031bf9cf19fbe528d285d53bb7014bc3e35f47 100644 (file)
@@ -532,13 +532,14 @@ Usage:
 
     @orchestrator._cli_write_command(
         'orch daemon rm',
-        "name=names,type=CephString,n=N",
+        "name=names,type=CephString,n=N "
+        'name=force,type=CephBool,req=false',
         'Remove specific daemon(s)')
-    def _daemon_rm(self, names):
+    def _daemon_rm(self, names, force=False):
         for name in names:
             if '.' not in name:
                 raise orchestrator.OrchestratorError('%s is not a valid daemon name' % name)
-        completion = self.remove_daemons(names)
+        completion = self.remove_daemons(names, force)
         self._orchestrator_wait([completion])
         orchestrator.raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())