diff options
author | Zuul <zuul@review.opendev.org> | 2021-02-27 05:05:56 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-02-27 05:05:56 +0000 |
commit | fe08143dcadbe97ae142f802c9c441afbbac5b23 (patch) | |
tree | b975359e908248fbe8d070bfb648d53f0b277e2e /nova | |
parent | b39561a7a3e5726de5b8de41f276f4102e9205d9 (diff) | |
parent | f7ba1aab5f6f76ba88d6cc63cde2ec246ee61ec5 (diff) | |
download | nova-fe08143dcadbe97ae142f802c9c441afbbac5b23.tar.gz |
Merge "compute: Lock by instance.uuid lock during swap_volume" into stable/ussuri
Diffstat (limited to 'nova')
-rw-r--r-- | nova/compute/manager.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index bcc839c6cf..cc4f8a58bf 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -7320,9 +7320,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, |