Fix: LVM optimized migration path during retype

Change[1] enabled optimized migration during retype but it
doesn't currently work when trying to retype from one LVM
backend to another.
This happens because of a status check[2] happening at the
start of the operation which checks if the volume is in
'available' state.
This is not true in case of retype as the status changes to
'retyping'[3].
Adding the 'retyping' state in the check fixes the issue and
results in the following workflow.

1. Create new volume in destination backend (lvmdriver-2)

Mar 27 06:35:18 devstack-lvm-multi sudo[103853]:    stack : PWD=/ ; USER=root ; COMMAND=/opt/stack/data/venv/bin/cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C lvcreate -T -V 1g -n volume-f009cc14-69da-418e-a734-a4d9d7be89db stack
-volumes-lvmdriver-2/stack-volumes-lvmdriver-2-pool

2. Copy data from source to destination (lvmdriver-1 -> lvmdriver-2)

Mar 27 06:35:20 devstack-lvm-multi sudo[103884]:    stack : PWD=/ ; USER=root ; COMMAND=/opt/stack/data/venv/bin/cinder-rootwrap /etc/cinder/rootwrap.conf dd if=/dev/mapper/stack--volumes--lvmdriver--1-volume--f009cc14--69da--418e--a734--
a4d9d7be89db of=/dev/mapper/stack--volumes--lvmdriver--2-volume--f009cc14--69da--418e--a734--a4d9d7be89db count=1073741824 bs=1M iflag=count_bytes,direct oflag=direct conv=sparse

3. Remove volume from source backend (lvmdriver-1)

Mar 27 06:35:21 devstack-lvm-multi sudo[103893]:    stack : PWD=/ ; USER=root ; COMMAND=/opt/stack/data/venv/bin/cinder-rootwrap /etc/cinder/rootwrap.conf lvremove --config 'activation { retry_deactivation = 1} ' -f stack-volumes-lvmdriver-1/volume-f009cc14-69da-418e-a734-a4d9d7be89db

The above confirms that the retype with optimized migration works when
using LVM.

[1] https://review.opendev.org/c/openstack/cinder/+/938827
[2] 689c88da61/cinder/volume/drivers/lvm.py (L760-L761)
[3] 689c88da61/cinder/volume/api.py (L1963-L1964)

Closes-Bug: #2104334
Change-Id: I8a14f35a119493bf4d2f4068bc378533cc40a4a3
This commit is contained in:
Rajat Dhasmana
2025-03-27 06:26:24 +00:00
parent 8993a10157
commit 5f59436bfb
2 changed files with 6 additions and 1 deletions

View File

@@ -757,7 +757,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
"""
false_ret = (False, None)
if volume['status'] != 'available':
if volume['status'] not in ['available', 'retyping']:
return false_ret
if 'location_info' not in host['capabilities']:
return false_ret

View File

@@ -0,0 +1,5 @@
---
fixes:
- |
`Bug #2104334 <https://bugs.launchpad.net/cinder/+bug/2104334>`_:
Fixed optimized migration path for LVM volumes during retype.