Clean up ports and volumes when deleting ERROR instance
Usually, when instance.host = None, it means the instance was never
scheduled. However, the exception handling routine in compute manager
[1] will set instance.host = None and set instance.vm_state = ERROR
if the instance fails to build on the compute host. If that happens, we
end up with an instance with host = None and vm_state = ERROR which may
have ports and volumes still allocated.
This adds some logic around deleting the instance when it may have
ports or volumes allocated.
1. If the instance is not in ERROR or SHELVED_OFFLOADED state, we
expect instance.host to be set to a compute host. So, if we find instance.host = None in states other than ERROR or SHELVED_OFFLOADED, we consider the instance to have failed
scheduling and not require ports or volumes to be freed, and we
simply destroy the instance database record and return. This is
the "delete while booting" scenario.
2. If the instance is in ERROR because of a failed build or is SHELVED_OFFLOADED, we expect instance.host to be None even though
there could be ports or volumes allocated. In this case, run the _local_delete routine to clean up ports and volumes and delete the
instance database record.
Reviewed: https:/ /review. openstack. org/546203 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=26e32ce8582 3bf1d87ec5c729a a408b92f526e38
Committed: https:/
Submitter: Zuul
Branch: stable/queens
commit 26e32ce85823bf1 d87ec5c729aa408 b92f526e38
Author: ankitagrawal <email address hidden>
Date: Wed Sep 23 03:58:19 2015 -0700
Clean up ports and volumes when deleting ERROR instance
Usually, when instance.host = None, it means the instance was never
scheduled. However, the exception handling routine in compute manager
[1] will set instance.host = None and set instance.vm_state = ERROR
if the instance fails to build on the compute host. If that happens, we
end up with an instance with host = None and vm_state = ERROR which may
have ports and volumes still allocated.
This adds some logic around deleting the instance when it may have
ports or volumes allocated.
1. If the instance is not in ERROR or SHELVED_OFFLOADED state, we
instance. host = None in states other than ERROR or
SHELVED_ OFFLOADED, we consider the instance to have failed
expect instance.host to be set to a compute host. So, if we find
scheduling and not require ports or volumes to be freed, and we
simply destroy the instance database record and return. This is
the "delete while booting" scenario.
2. If the instance is in ERROR because of a failed build or is
SHELVED_ OFFLOADED, we expect instance.host to be None even though
_local_ delete routine to clean up ports and volumes and delete the
there could be ports or volumes allocated. In this case, run the
instance database record.
Co-Authored-By: Ankit Agrawal <email address hidden>
Co-Authored-By: Samuel Matzek <email address hidden>
Co-Authored-By: melanie witt <email address hidden>
Closes-Bug: 1404867
Closes-Bug: 1408527
Conflicts:
nova/ tests/unit/ compute/ test_compute_ api.py
[1] https:/ /github. com/openstack/ nova/blob/ 55ea961/ nova/compute/ manager. py#L1927- L1929
Change-Id: I4dc6c8bd3bb6c1 35f8a698af41f5d 0e026c39117 fb141de61850cbd 84fecdb544)
(cherry picked from commit b3f39244a3eacd6