Don't fail to delete if VolumeAttachment not found
Change-Id: If12b7ebbee2d71e39e49152d971c11f55badca18 Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
parent
a974326cd7
commit
2652832ef3
@ -18,6 +18,7 @@ from heat.openstack.common import log as logging
|
|||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.engine.resources import Resource
|
from heat.engine.resources import Resource
|
||||||
|
from novaclient.exceptions import NotFound
|
||||||
|
|
||||||
logger = logging.getLogger('heat.engine.volume')
|
logger = logging.getLogger('heat.engine.volume')
|
||||||
|
|
||||||
@ -99,18 +100,24 @@ class VolumeAttachment(Resource):
|
|||||||
(server_id, volume_id))
|
(server_id, volume_id))
|
||||||
|
|
||||||
volapi = self.nova().volumes
|
volapi = self.nova().volumes
|
||||||
volapi.delete_server_volume(server_id,
|
try:
|
||||||
volume_id)
|
volapi.delete_server_volume(server_id,
|
||||||
|
volume_id)
|
||||||
|
|
||||||
vol = self.nova('volume').volumes.get(volume_id)
|
vol = self.nova('volume').volumes.get(volume_id)
|
||||||
logger.info('un-attaching %s, status %s' % (volume_id, vol.status))
|
|
||||||
while vol.status == 'in-use':
|
logger.info('un-attaching %s, status %s' % (volume_id, vol.status))
|
||||||
logger.info('trying to un-attach %s, but still %s' %
|
while vol.status == 'in-use':
|
||||||
(volume_id, vol.status))
|
logger.info('trying to un-attach %s, but still %s' %
|
||||||
eventlet.sleep(1)
|
(volume_id, vol.status))
|
||||||
try:
|
eventlet.sleep(1)
|
||||||
volapi.delete_server_volume(server_id,
|
try:
|
||||||
volume_id)
|
volapi.delete_server_volume(server_id,
|
||||||
except Exception:
|
volume_id)
|
||||||
pass
|
except Exception:
|
||||||
vol.get()
|
pass
|
||||||
|
vol.get()
|
||||||
|
except NotFound as e:
|
||||||
|
logger.warning('Deleting VolumeAttachment %s %s - not found' %
|
||||||
|
(server_id, volume_id))
|
||||||
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user