summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-03-19 03:31:06 +0000
committerGerrit Code Review <review@openstack.org>2021-03-19 03:31:06 +0000
commit7139634863e67beca850343564757dcb13322eb4 (patch)
tree482d4244cfbfed9263f480ff09a5096653c7de7a
parentdff026a2cdf6e2d1117111ea1a354385ceaa6937 (diff)
parentfb81b16df09bedadecca9acd234ef137a427e02a (diff)
downloadnova-7139634863e67beca850343564757dcb13322eb4.tar.gz
Merge "compute: Lock by instance.uuid lock during swap_volume" into stable/train
-rw-r--r--nova/compute/manager.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index f7bb00df7b..6e5d72f27a 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -6462,9 +6462,33 @@ class ComputeManager(manager.Manager):
@wrap_instance_fault
def swap_volume(self, context, old_volume_id, new_volume_id, instance,
new_attachment_id):
- """Swap volume for an instance."""
- context = context.elevated()
+ """Replace the old volume with the new volume within the active server
+ :param context: User request context
+ :param old_volume_id: Original volume id
+ :param new_volume_id: New volume id being swapped to
+ :param instance: Instance with original_volume_id attached
+ :param new_attachment_id: ID of the new attachment for new_volume_id
+ """
+ @utils.synchronized(instance.uuid)
+ def _do_locked_swap_volume(context, old_volume_id, new_volume_id,
+ instance, new_attachment_id):
+ self._do_swap_volume(context, old_volume_id, new_volume_id,
+ instance, new_attachment_id)
+ _do_locked_swap_volume(context, old_volume_id, new_volume_id, instance,
+ new_attachment_id)
+
+ def _do_swap_volume(self, context, old_volume_id, new_volume_id,
+ instance, new_attachment_id):
+ """Replace the old volume with the new volume within the active server
+
+ :param context: User request context
+ :param old_volume_id: Original volume id
+ :param new_volume_id: New volume id being swapped to
+ :param instance: Instance with original_volume_id attached
+ :param new_attachment_id: ID of the new attachment for new_volume_id
+ """
+ context = context.elevated()
compute_utils.notify_about_volume_swap(
context, instance, self.host,
fields.NotificationPhase.START,