From: jianglong01 Date: Mon, 6 Sep 2021 10:37:06 +0000 (+0800) Subject: mgr/cephadm: osd should not be zap when it is running X-Git-Tag: v16.2.7~67^2~64 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=888a2e960c02a0acfa4030dcbdcb341da668d978;p=ceph.git mgr/cephadm: osd should not be zap when it is running 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 (cherry picked from commit aed472f7b6663c487a5ae89fcdd788b32910b621) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index c46cf6a9ae3d..5fab152eb299 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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],