Ophaned Volume Not Removed on Instance Delete
When an instance is created with quota issues, the cinder volume is created butthe nova instance fails to be created. Deleting the instance would fail todelete the volume. Check the status of the volume when deleting the instance, if the status of the volume is "available" delete the volume as it is not connected to any instance. Change-Id: Ie921a8ff2851e2d9d76a3c3836945c750f090c4e Closes-Bug: #1344113
This commit is contained in:
parent
091c255b67
commit
c3d670c218
|
@ -318,6 +318,24 @@ class ClusterTasks(Cluster):
|
|||
|
||||
class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
|
||||
|
||||
def _delete_resources(self, deleted_at):
|
||||
LOG.debug("Begin _delete_resources for instance %s" % self.id)
|
||||
|
||||
# If volume has "available" status, delete it manually.
|
||||
try:
|
||||
if self.volume_id:
|
||||
volume_client = create_cinder_client(self.context)
|
||||
volume = volume_client.volumes.get(self.volume_id)
|
||||
if volume.status == "available":
|
||||
LOG.info(_("Deleting volume %(v)s for instance: %(i)s.")
|
||||
% {'v': self.volume_id, 'i': self.id})
|
||||
volume.delete()
|
||||
except Exception:
|
||||
LOG.exception(_("Error deleting volume of instance %(id)s.") %
|
||||
{'id': self.db_info.id})
|
||||
|
||||
LOG.debug("End _delete_resource for instance %s" % self.id)
|
||||
|
||||
def _get_injected_files(self, datastore_manager):
|
||||
injected_config_location = CONF.get('injected_config_location')
|
||||
guest_info = CONF.get('guest_info')
|
||||
|
|
Loading…
Reference in New Issue