Skip to content

Commit 8817813

Browse files
committed
fix(linstor): handle non-existing volumes when updating UUID
We may update the UUID of a volume that does not actually exist. This happens when rolling back a clone operation that failed because the physical volume could not be created. This updates the `update_volume_uuid` function to save the `not-exists` state of the volume that is being renamed, so that it is not wrongly considered as existing after the UUID update completes. Signed-off-by: Alexandre Sollier <alexandre.sollier@vates.tech>
1 parent 4a002cd commit 8817813

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/linstorvolumemanager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,9 +1060,10 @@ def update_volume_uuid(self, volume_uuid, new_volume_uuid, force=False):
10601060
.format(volume_uuid)
10611061
)
10621062

1063-
# 1. Copy in temp variables metadata and volume_name.
1063+
# 1. Copy in temp variables metadata, volume_name and not_exists.
10641064
metadata = volume_properties.get(self.PROP_METADATA)
10651065
volume_name = volume_properties.get(self.PROP_VOLUME_NAME)
1066+
not_exists = volume_properties.get(self.PROP_NOT_EXISTS)
10661067

10671068
# 2. Switch to new volume namespace.
10681069
volume_properties.namespace = self._build_volume_namespace(
@@ -1093,7 +1094,7 @@ def update_volume_uuid(self, volume_uuid, new_volume_uuid, force=False):
10931094
volume_properties[self.PROP_VOLUME_NAME] = volume_name
10941095

10951096
# 5. Ok!
1096-
volume_properties[self.PROP_NOT_EXISTS] = self.STATE_EXISTS
1097+
volume_properties[self.PROP_NOT_EXISTS] = not_exists
10971098
except Exception as err:
10981099
try:
10991100
# Clear the new volume properties in case of failure.
@@ -1138,7 +1139,8 @@ def update_volume_uuid(self, volume_uuid, new_volume_uuid, force=False):
11381139
# we are processing a deleted resource.
11391140
assert force
11401141

1141-
self._volumes.add(new_volume_uuid)
1142+
if not_exists == self.STATE_EXISTS:
1143+
self._volumes.add(new_volume_uuid)
11421144

11431145
self._logger(
11441146
'UUID update succeeded of {} to {}! (properties={})'

0 commit comments

Comments
 (0)