]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: osd should not be zap when it is running
authorjianglong01 <jianglong01@qianxin.com>
Mon, 6 Sep 2021 10:37:06 +0000 (18:37 +0800)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:01:18 +0000 (10:01 +0100)
When osd is running, we exec the command of "ceph orch device zap".
Then ceph-volume will exec dd command which cause the osd of lvs to be destroyed.
If the osd of systemctl unit restarts, it will be unable to boot.

Signed-off-by: jianglong01 <jianglong01@qianxin.com>
(cherry picked from commit aed472f7b6663c487a5ae89fcdd788b32910b621)

src/pybind/mgr/cephadm/module.py

index c46cf6a9ae3d1d7b25b2e92f15f5b48b56ce6038..5fab152eb299b08fc0f8d6898ebb8f7f491d8de9 100644 (file)
@@ -2089,6 +2089,23 @@ Then run the following:
     @handle_orch_error
     def zap_device(self, host: str, path: str) -> str:
         self.log.info('Zap device %s:%s' % (host, path))
+
+        out, err, code = CephadmServe(self)._run_cephadm(
+            host, 'osd.', 'ceph-volume',
+            ['--', 'lvm', 'list', path, '--format', 'json'],
+            error_ok=True)
+        if code:
+            raise OrchestratorError('Zap failed: ceph-volume lvm list %s' % '\n'.join(path))
+        osd_info = json.loads('\n'.join(out))
+
+        for osd_id in osd_info.keys():
+            out, err, code = CephadmServe(self)._run_cephadm(
+                host, 'osd.', 'unit',
+                ['is-active', '--name', 'osd.%s' % osd_id],
+                error_ok=True)
+            if code == 0:
+                raise OrchestratorError('The systemctl unit of osd is active. Rm osd first')
+
         out, err, code = CephadmServe(self)._run_cephadm(
             host, 'osd', 'ceph-volume',
             ['--', 'lvm', 'zap', '--destroy', path],