Instances with delete_on_terminate volumes do not reschedule

Bug #1437516 reported by Vish Ishaya
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Triaged
Medium
Unassigned

Bug Description

If you create an instance with attached delete_on_terminate volumes and it fails to launch on a host (due to a hardware or hypervisor issue) it will be rescheduled but the volumes will have already been deleted. The volumes should only be deleted if the instance is not going to be rescheduled (or perhaps not at all).

Changed in nova:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Vish Ishaya (vishvananda) wrote :

I'm thinking something like the following

diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 6f756e4..2e7aebb 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -1533,6 +1533,10 @@ class ComputeManager(manager.Manager):
                         reason=six.text_type(exc_info[1]))
             else:
                 # not re-scheduling, go to error:
+ if bdms is None:
+ bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
+ context, instance.uuid)
+ self._cleanup_volumes(context, instance.uuid, bdms)
                 raise exc_info[0], exc_info[1], exc_info[2]

         # spawn success
@@ -1569,7 +1573,6 @@ class ComputeManager(manager.Manager):

             self._shutdown_instance(context, instance,
                                     bdms, requested_networks)
- self._cleanup_volumes(context, instance.uuid, bdms)
         except Exception:
             # do not attempt retry if clean up failed:
             with excutils.save_and_reraise_exception():

Revision history for this message
Andrew Laski (alaski) wrote :

This was fixed with https://review.openstack.org/#/c/106477/, though that only applies to deployments who are using the new build_and_run_instance method in manager.py. A new fix would be necessary in order to backport it to deployments using run_instance.

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Thanks andrew, marked this as a duplicate

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.