From effe65533f4b7248137fcdc0ae966f8438a05b01 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Tue, 23 Nov 2021 15:33:35 +0100 Subject: [PATCH] ceph-volume: zap osds in rollback_osd() 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 --- src/ceph-volume/ceph_volume/devices/lvm/batch.py | 2 +- src/ceph-volume/ceph_volume/devices/lvm/common.py | 8 ++++---- src/ceph-volume/ceph_volume/devices/lvm/migrate.py | 2 +- src/ceph-volume/ceph_volume/devices/lvm/zap.py | 3 +-- src/ceph-volume/ceph_volume/util/arg_validators.py | 3 +++ 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/batch.py b/src/ceph-volume/ceph_volume/devices/lvm/batch.py index 0dfd809bdf3..8f652d1bc2e 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/batch.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/batch.py @@ -345,7 +345,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 diff --git a/src/ceph-volume/ceph_volume/devices/lvm/common.py b/src/ceph-volume/ceph_volume/devices/lvm/common.py index 752f354f35a..933ad9fda89 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/common.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/common.py @@ -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', diff --git a/src/ceph-volume/ceph_volume/devices/lvm/migrate.py b/src/ceph-volume/ceph_volume/devices/lvm/migrate.py index dc982f153b4..86159fd505b 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/migrate.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/migrate.py @@ -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__) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/zap.py b/src/ceph-volume/ceph_volume/devices/lvm/zap.py index 20023a27c90..231d20a38ac 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/zap.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/zap.py @@ -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', ) diff --git a/src/ceph-volume/ceph_volume/util/arg_validators.py b/src/ceph-volume/ceph_volume/util/arg_validators.py index 39ad6384f2d..38a01198516 100644 --- a/src/ceph-volume/ceph_volume/util/arg_validators.py +++ b/src/ceph-volume/ceph_volume/util/arg_validators.py @@ -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): -- 2.39.5