From 1f962f59439af26308b0cb5b4873f7ecada00cc2 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 31 May 2024 17:05:29 +0300 Subject: [PATCH] ceph-volume: do source devices zapping if they're detached. One needs to zap source device(s) after DB/WAL migration. Original imlementation removes LVM tags only which leaves device(s) in a state where "ceph-volume raw activate" still reconginizes them as attached to OSD due to information preserved in bdev label. Hence the need to do more zapping. Fixes: https://tracker.ceph.com/issues/66315 Signed-off-by: Igor Fedotov (cherry picked from commit ae5ef432845dcf9b061258357ffd97f4eae59a63) --- .../ceph_volume/devices/lvm/migrate.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/migrate.py b/src/ceph-volume/ceph_volume/devices/lvm/migrate.py index 474b479dee9..83ed16845e7 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/migrate.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/migrate.py @@ -10,7 +10,7 @@ from ceph_volume.util import encryption as encryption_utils 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 import zap logger = logging.getLogger(__name__) mlogger = terminal.MultiLogger(__name__) @@ -174,6 +174,7 @@ class VolumeTagTracker(object): remaining_devices.append(self.wal_device) outdated_tags = [] + removed_devices = [] for device, type in source_devices: if type == "block" or type == target_type: continue @@ -182,10 +183,13 @@ class VolumeTagTracker(object): outdated_tags.append("ceph.{}_uuid".format(type)) outdated_tags.append("ceph.{}_device".format(type)) device.lv_api.clear_tags() + removed_devices.append(device) + if len(outdated_tags) > 0: for d in remaining_devices: if d and d.is_lv: d.lv_api.clear_tags(outdated_tags) + return removed_devices def replace_lvs(self, source_devices, target_type): remaining_devices = [self.data_device] @@ -195,6 +199,7 @@ class VolumeTagTracker(object): remaining_devices.append(self.wal_device) outdated_tags = [] + removed_devices = [] for device, type in source_devices: if type == "block": continue @@ -203,6 +208,7 @@ class VolumeTagTracker(object): outdated_tags.append("ceph.{}_uuid".format(type)) outdated_tags.append("ceph.{}_device".format(type)) device.lv_api.clear_tags() + removed_devices.append(device) new_tags = {} new_tags["ceph.{}_uuid".format(target_type)] = self.target_lv.lv_uuid @@ -224,6 +230,7 @@ class VolumeTagTracker(object): tags["ceph.{}_uuid".format(target_type)] = self.target_lv.lv_uuid tags["ceph.{}_device".format(target_type)] = self.target_lv.lv_path self.target_lv.set_tags(tags) + return removed_devices def undo(self): mlogger.info( @@ -339,7 +346,7 @@ class Migrate(object): # ceph-bluestore-tool removes source volume(s) other than block one # and attaches target one after successful migration - tag_tracker.replace_lvs(source_devices, target_type) + removed_devices = tag_tracker.replace_lvs(source_devices, target_type) osd_path = get_osd_path(osd_id, osd_fsid) source_args = self.get_source_args(osd_path, source_devices) @@ -364,6 +371,9 @@ class Migrate(object): target_type))) if tag_tracker.data_device.lv_api.encrypted: self.close_encrypted(source_devices) + for d in removed_devices: + if d and d.is_lv: + zap.Zap([d.lv_api.lv_path]).main() terminal.success('Migration successful.') except: @@ -395,7 +405,7 @@ class Migrate(object): try: # ceph-bluestore-tool removes source volume(s) other than # block and target ones after successful migration - tag_tracker.remove_lvs(source_devices, target_type) + removed_devices = tag_tracker.remove_lvs(source_devices, target_type) source_args = self.get_source_args(osd_path, source_devices) mlogger.info("Migrate to existing, Source: {} Target: {}".format( source_args, target_path)) @@ -415,6 +425,9 @@ class Migrate(object): 'Failed to migrate to : {}'.format(self.args.target)) if tag_tracker.data_device.lv_api.encrypted: self.close_encrypted(source_devices) + for d in removed_devices: + if d and d.is_lv: + zap.Zap([d.lv_api.lv_path]).main() terminal.success('Migration successful.') except: tag_tracker.undo() -- 2.39.5