Fix issue on deleting cinder volume

Zun has a feature to auto cleanup container's volumes on deleting
a container. In before, compute manager issue API call to cinder
to request deleting the cinder volumes and wait for the cinder
to complete the deletion. However, we should wait for the volumes
that are auto-removed, because waiting for non-auto-removed volumes
will cause a timeout error obviously.

Change-Id: Idfb5429f618fc8163e87a7df7f8ed110f12ada1b
This commit is contained in:
Hongbin Lu 2019-03-03 21:07:37 +00:00
parent ca85190e9d
commit 1f868534eb
1 changed files with 3 additions and 1 deletions

View File

@ -420,13 +420,15 @@ class Manager(periodic_task.PeriodicTasks):
volmaps = objects.VolumeMapping.list_by_container(context,
container.uuid)
auto_remove_volmaps = []
for volmap in volmaps:
db_volmaps = objects.VolumeMapping.list_by_cinder_volume(
context, volmap.cinder_volume_id)
self._detach_volume(context, volmap, reraise=reraise)
if volmap.auto_remove and len(db_volmaps) == 1:
self.driver.delete_volume(context, volmap)
self._wait_for_volumes_deleted(context, volmaps, container)
auto_remove_volmaps.append(volmap)
self._wait_for_volumes_deleted(context, auto_remove_volmaps, container)
def _detach_volume(self, context, volmap, reraise=True):
if objects.VolumeMapping.count(