From d78ae6c04db3deb3d2741615febe1eece3f2b42b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 6 Mar 2020 14:00:42 -0600 Subject: [PATCH] mgr/cephadm: remove mon from monmap before removing mon Check for force flag early so we don't update the monmap if the daemon remove is going to fail anyway. Signed-off-by: Sage Weil --- src/pybind/mgr/cephadm/module.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 723e9db3faf88..07796619a30ee 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -2149,6 +2149,20 @@ 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({ + 'prefix': 'mon rm', + 'name': daemon_id, + }) + if ret: + raise OrchestratorError('failed to remove mon %s from monmap' % ( + name)) + args = ['--name', name] if force: args.extend(['--force']) -- 2.39.5