From 16fb8ac3f4c2fe94ae83d65fbcf6f49665a0dd60 Mon Sep 17 00:00:00 2001 From: Lee Yarwood Date: Mon, 29 Jul 2019 16:25:45 +0100 Subject: [PATCH] compute: Take an instance.uuid lock when rebooting Previously simultaneous requests to reboot and delete an instance could race as only the latter took a lock against the uuid of the instance. With the Libvirt driver this race could potentially result in attempts being made to reconnect previously disconnected volumes on the host. Depending on the volume backend being used this could then result in stale block devices point to unmapped volumes being left on the host that in turn could cause failures later on when connecting newly mapped volumes. This change avoids this race by ensuring any request to reboot an instance takes an instance.uuid lock within the compute manager, serialising requests to reboot and then delete the instance. Closes-Bug: #1838392 Change-Id: Ieb59de10c63bb067f92ec054535766cdd722dae2 (cherry picked from commit 9ad54f3dacbd372271f441baea5380f913072dde) (cherry picked from commit 939cd9b177db8f12952e72145a5c00a0574959eb) (cherry picked from commit 304d3f62a4e3bdbaab6fe7dd665174bc5b696d08) (cherry picked from commit 7d14b6a5170821c65e55d7b39ccf4419a81640f8) --- nova/compute/manager.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 3b8f83f00dc2..3954810e6b9c 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -3310,6 +3310,15 @@ class ComputeManager(manager.Manager): @wrap_instance_fault def reboot_instance(self, context, instance, block_device_info, reboot_type): + @utils.synchronized(instance.uuid) + def do_reboot_instance(context, instance, block_device_info, + reboot_type): + self._reboot_instance(context, instance, block_device_info, + reboot_type) + do_reboot_instance(context, instance, block_device_info, reboot_type) + + def _reboot_instance(self, context, instance, block_device_info, + reboot_type): """Reboot an instance on this host.""" # acknowledge the request made it to the manager if reboot_type == "SOFT":