]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/orch,cephadm: elevate --force flag for daemons to interface 33973/head
authorSage Weil <sage@redhat.com>
Sat, 14 Mar 2020 14:10:13 +0000 (09:10 -0500)
committerSage Weil <sage@redhat.com>
Sat, 14 Mar 2020 22:16:37 +0000 (17:16 -0500)
Apply this check in the generic orchestrator code so that it applies
consistently to all implementations.

Signed-off-by: Sage Weil <sage@redhat.com>
qa/tasks/mgr/test_orchestrator_cli.py
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/osd.py
src/pybind/mgr/cephadm/tests/test_cephadm.py
src/pybind/mgr/orchestrator/_interface.py
src/pybind/mgr/orchestrator/module.py
src/pybind/mgr/rook/module.py
src/pybind/mgr/test_orchestrator/module.py

index 9753e18f67a04224ff23eeda591aeca051797273..5232af29905e6e294e78b3e1d7ed55c42273c2c7 100644 (file)
@@ -129,7 +129,7 @@ data_devices:
         self._orch_cmd('daemon', 'add', "nfs", "service_name", "pool")
 
     def test_osd_rm(self):
-        self._orch_cmd('daemon', "rm", "osd.0")
+        self._orch_cmd('daemon', "rm", "osd.0", '--force')
 
     def test_mds_rm(self):
         self._orch_cmd("daemon", "rm", "mds.fsname")
index e4bbcaf78aa91b3cadc3d4c5ca61aa24a189f5a3..378383951c024d4d39a05b4b19ec9ba2e431b795 100644 (file)
@@ -1858,13 +1858,13 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
             ','.join(['%s.%s' % (a[0], a[1]) for a in args])))
         return self._daemon_actions(args)
 
-    def remove_daemons(self, names, force):
-        # type: (List[str], bool) -> orchestrator.Completion
+    def remove_daemons(self, names):
+        # type: (List[str]) -> orchestrator.Completion
         args = []
         for host, dm in self.cache.daemons.items():
             for name in names:
                 if name in dm:
-                    args.append((name, host, force))
+                    args.append((name, host))
         if not args:
             raise OrchestratorError('Unable to find daemon(s) %s' % (names))
         self.log.info('Remove daemons %s' % [a[0] for a in args])
@@ -2167,10 +2167,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
             'Reconfigured' if reconfig else 'Deployed', name, host)
 
     @async_map_completion
-    def _remove_daemons(self, name, host, force=False):
-        return self._remove_daemon(name, host, force)
+    def _remove_daemons(self, name, host):
+        return self._remove_daemon(name, host)
 
-    def _remove_daemon(self, name, host, force=False):
+    def _remove_daemon(self, name, host):
         """
         Remove a daemon
         """
@@ -2178,10 +2178,6 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
         if daemon_type == 'mon':
             self._check_safe_to_destroy_mon(daemon_id)
 
-            # fail early, before we update the monmap
-            if not force:
-                raise OrchestratorError('Must pass --force to remove a monitor and DELETE potentially PRECIOUS CLUSTER DATA')
-
             # remove mon from quorum before we destroy the daemon
             self.log.info('Removing monitor %s from monmap...' % name)
             ret, out, err = self.mon_command({
@@ -2192,9 +2188,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
                 raise OrchestratorError('failed to remove mon %s from monmap' % (
                     name))
 
-        args = ['--name', name]
-        if force:
-            args.extend(['--force'])
+        args = ['--name', name, '--force']
         self.log.info('Removing daemon %s from %s' % (name, host))
         out, err, code = self._run_cephadm(
             host, name, 'rm-daemon', args)
@@ -2284,7 +2278,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
             if d.hostname not in target_hosts:
                 # NOTE: we are passing the 'force' flag here, which means
                 # we can delete a mon instances data.
-                self._remove_daemon(d.name(), d.hostname, True)
+                self._remove_daemon(d.name(), d.hostname)
                 r = True
 
         return r
@@ -2320,7 +2314,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
                 # (mon and mgr specs should always exist; osds aren't matched
                 # to a service spec)
                 self.log.info('Removing orphan daemon %s...' % dd.name())
-                self._remove_daemon(dd.name(), dd.hostname, True)
+                self._remove_daemon(dd.name(), dd.hostname)
 
             # dependencies?
             if dd.daemon_type == 'grafana':
index 4e2181d201aef6865a1150a78cf2d00e28e3602d..2ead0cb8077f6508f82c8866e2e22397cfe93818 100644 (file)
@@ -97,7 +97,7 @@ class RemoveUtil(object):
                     # also remove it from the remove_osd list and set a health_check warning?
                     raise orchestrator.OrchestratorError(f"Could not purge OSD <{osd.osd_id}>")
 
-            self.mgr._remove_daemon(osd.fullname, osd.nodename, True)
+            self.mgr._remove_daemon(osd.fullname, osd.nodename)
             logger.info(f"Successfully removed OSD <{osd.osd_id}> on {osd.nodename}")
             logger.debug(f"Removing {osd.osd_id} from the queue.")
             self.to_remove_osds.remove(osd)
index 70dd171bcce9a663a9a83de7d46e17271d63d1db..09eb4606f48cf045ed16d24a9a8595dd02340c01 100644 (file)
@@ -165,7 +165,7 @@ class TestCephadm(object):
             c = cephadm_module.list_daemons(refresh=True)
             wait(cephadm_module, c)
 
-            c = cephadm_module.remove_daemons(['osd.0'], False)
+            c = cephadm_module.remove_daemons(['osd.0'])
             out = wait(cephadm_module, c)
             assert out == ["Removed osd.0 from host 'test'"]
 
@@ -226,7 +226,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'], False)
+            c = cephadm_module.remove_daemons(['rgw.myrgw.myhost.myid'])
             out = wait(cephadm_module, c)
             assert out == ["Removed rgw.myrgw.myhost.myid from host 'test'"]
 
index 5a83120b065f42c65df74831e4d99caa9e097c30..558f87b0b68317a6563d39174b88e774716fb5e5 100644 (file)
@@ -850,8 +850,8 @@ class Orchestrator(object):
         """
         raise NotImplementedError()
 
-    def remove_daemons(self, names, force):
-        # type: (List[str], bool) -> Completion
+    def remove_daemons(self, names):
+        # type: (List[str]) -> Completion
         """
         Remove specific daemon(s).
 
index 37cbaf6d31cd72e75d473823ab50add71ac0173b..8461d5e42a1329bbd30fe9747a55bc31aa8bde90 100644 (file)
@@ -733,7 +733,10 @@ Usage:
         for name in names:
             if '.' not in name:
                 raise OrchestratorError('%s is not a valid daemon name' % name)
-        completion = self.remove_daemons(names, force)
+            (daemon_type) = name.split('.')[0]
+            if not force and daemon_type in ['osd', 'mon', 'prometheus']:
+                raise OrchestratorError('must pass --force to REMOVE daemon with potentially PRECIOUS DATA for %s' % name)
+        completion = self.remove_daemons(names)
         self._orchestrator_wait([completion])
         raise_if_exception(completion)
         return HandleCommandResult(stdout=completion.result_str())
index 1a2f7ad1c905e6e5b85bcaf63abfc215ab1cca83..6036d25bb68f7c07ac8f55c6f488106d4e26dba6 100644 (file)
@@ -434,7 +434,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
             mgr=self
         )
 
-    def remove_daemons(self, names, force):
+    def remove_daemons(self, names):
         return write_completion(
             lambda: self.rook_cluster.remove_pods(names),
             "Removing daemons {}".format(','.join(names)),
index 5f22e30ce0d7a50497c1e158c379797bd96785de..2d8d859c65753f85c312b90a7c92c763f0ddcd13 100644 (file)
@@ -275,7 +275,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator):
         )
 
     @deferred_write("remove_daemons")
-    def remove_daemons(self, names, force):
+    def remove_daemons(self, names):
         assert isinstance(names, list)
 
     @deferred_write("remove_service")