]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: zap osds in rollback_osd() 44777/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Tue, 23 Nov 2021 14:33:35 +0000 (15:33 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Tue, 25 Jan 2022 15:50:57 +0000 (16:50 +0100)
rollback_osd() should zap and wipe the device for the corresponding osd
that was being prepared after a failure happens.

Fixes: https://tracker.ceph.com/issues/53376
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit effe65533f4b7248137fcdc0ae966f8438a05b01)

src/ceph-volume/ceph_volume/devices/lvm/batch.py
src/ceph-volume/ceph_volume/devices/lvm/common.py
src/ceph-volume/ceph_volume/devices/lvm/migrate.py
src/ceph-volume/ceph_volume/devices/lvm/zap.py
src/ceph-volume/ceph_volume/util/arg_validators.py

index 5014b9866babd0a8752e047617114972a0b040c0..dace25530aba0d27b11246f5505875b2448bc9f7 100644 (file)
@@ -346,7 +346,7 @@ class Batch(object):
             nargs='*',
             default=[],
             help='Reuse existing OSD ids',
-            type=common.valid_osd_id
+            type=arg_validators.valid_osd_id
         )
         self.args = parser.parse_args(argv)
         self.parser = parser
index 05f83383f0ea13300e8a06abc117afa55295f914..e09f7f0db91acef22646c83e6d7174f5221b0216 100644 (file)
@@ -1,15 +1,14 @@
 from ceph_volume.util import arg_validators, disk
 from ceph_volume import process, conf
 from ceph_volume import terminal
+from ceph_volume.devices.lvm.zap import Zap
 import argparse
 
-def valid_osd_id(val):
-    return str(int(val))
 
 def rollback_osd(args, osd_id=None):
     """
     When the process of creating or preparing fails, the OSD needs to be
-    destroyed so that the ID cane be reused.  This is prevents leaving the ID
+    destroyed so that the ID can be reused.  This prevents from leaving the ID
     around as "used" on the monitor, which can cause confusion if expecting
     sequential OSD IDs.
 
@@ -34,6 +33,7 @@ def rollback_osd(args, osd_id=None):
     ]
 
     process.run(cmd)
+    Zap(['--destroy', '--osd-id', osd_id]).main()
 
 
 common_args = {
@@ -58,7 +58,7 @@ common_args = {
     '--osd-id': {
         'help': 'Reuse an existing OSD id',
         'default': None,
-        'type': valid_osd_id,
+        'type': arg_validators.valid_osd_id,
     },
     '--osd-fsid': {
         'help': 'Reuse an existing OSD fsid',
index dc982f153b4ed25a02626bfed8bd3d1c630edd82..86159fd505b777dd0a86c20865f8438629b19c3b 100644 (file)
@@ -5,10 +5,10 @@ import os
 from textwrap import dedent
 from ceph_volume.util import system, disk, merge_dict
 from ceph_volume.util.device import Device
+from ceph_volume.util.arg_validators import valid_osd_id
 from ceph_volume import decorators, terminal, process
 from ceph_volume.api import lvm as api
 from ceph_volume.systemd import systemctl
-from ceph_volume.devices.lvm.common import valid_osd_id
 
 
 logger = logging.getLogger(__name__)
index 20023a27c901143213b15e2231279b58963d4a4e..231d20a38ac1878b3c1a5cc47b92094e825013b7 100644 (file)
@@ -10,7 +10,6 @@ from ceph_volume.api import lvm as api
 from ceph_volume.util import system, encryption, disk, arg_validators, str_to_int, merge_dict
 from ceph_volume.util.device import Device
 from ceph_volume.systemd import systemctl
-from ceph_volume.devices.lvm.common import valid_osd_id
 
 logger = logging.getLogger(__name__)
 mlogger = terminal.MultiLogger(__name__)
@@ -377,7 +376,7 @@ class Zap(object):
 
         parser.add_argument(
             '--osd-id',
-            type=valid_osd_id,
+            type=arg_validators.valid_osd_id,
             help='Specify an OSD ID to detect associated devices for zapping',
         )
 
index 39ad6384f2d62565d1ccd870675b0ac8a04da279..38a0119851615e1eccd0be479dd5a4d0a376b783 100644 (file)
@@ -7,6 +7,9 @@ from ceph_volume.util import disk
 from ceph_volume.util.device import Device
 
 
+def valid_osd_id(val):
+    return str(int(val))
+
 class ValidDevice(object):
 
     def __init__(self, as_string=False, gpt_ok=False):