Skip to content

Commit 4a002cd

Browse files
committed
feat(linstor): add counter to GC volume deletion prefix
When a snapshot operation has failed, a rollback operation takes place which marks the new leaf volume (which took the UUID of the volume being snapshotted) for deletion, and updates the UUID of the volume being snapshotted back to its original UUID. The reason for the snapshot having failed may last for quite some time, and the GC may not be able to actually destroy the volumes that are marked for deletion. If such a scenario occurs, further snapshot attempts will also fail, but the rollback operation will also fail because a volume with the UUID of the volume to snapshot was already marked for deletion by the first snapshot attempt. This fixes the issue by introducing a counter to the prefix of volume UUIDs that are marked for deletion, therefore allowing multiple of them co-existing until the underlying storage issues are fixed. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
1 parent 8ad8dde commit 4a002cd

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

drivers/linstorvolumemanager.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ class LinstorVolumeManagerError(Exception):
244244
ERR_VOLUME_NOT_EXISTS = 2,
245245
ERR_VOLUME_DESTROY = 3,
246246
ERR_GROUP_NOT_EXISTS = 4,
247-
ERR_VOLUME_IN_USE = 5
247+
ERR_VOLUME_IN_USE = 5,
248+
ERR_VOLUME_PROPERTIES_NOT_EMPTY = 6
248249

249250
def __init__(self, message, code=ERR_GENERIC):
250251
super(LinstorVolumeManagerError, self).__init__(message)
@@ -1072,7 +1073,8 @@ def update_volume_uuid(self, volume_uuid, new_volume_uuid, force=False):
10721073
raise LinstorVolumeManagerError(
10731074
'Cannot update volume uuid {} to {}: '
10741075
.format(volume_uuid, new_volume_uuid) +
1075-
'this last one is not empty'
1076+
'this last one is not empty',
1077+
LinstorVolumeManagerError.ERR_VOLUME_PROPERTIES_NOT_EMPTY
10761078
)
10771079

10781080
try:
@@ -1156,9 +1158,23 @@ def mark_volume_for_deletion(self, volume_uuid, force=False):
11561158
if volume_uuid.startswith(DELETED_PREFIX):
11571159
return
11581160

1159-
self.update_volume_uuid(
1160-
volume_uuid, DELETED_PREFIX + volume_uuid, force=force
1161-
)
1161+
deleted_prefix_counter = 0
1162+
while True:
1163+
new_volume_uuid = '{}{}_{}'.format(
1164+
DELETED_PREFIX, deleted_prefix_counter, volume_uuid
1165+
)
1166+
1167+
try:
1168+
self.update_volume_uuid(
1169+
volume_uuid, new_volume_uuid, force=force
1170+
)
1171+
1172+
break
1173+
except LinstorVolumeManagerError as e:
1174+
if e.code != LinstorVolumeManagerError.ERR_VOLUME_PROPERTIES_NOT_EMPTY:
1175+
raise
1176+
1177+
deleted_prefix_counter += 1
11621178

11631179
def update_volume_name(self, volume_uuid, volume_name):
11641180
"""

0 commit comments

Comments
 (0)