SolidFire: Handle connect_volume() failure when create vol from image

Currently the _create_image_volume() method in solidfire.py doesn't
catch the exception for initialize_connection() or connect_volume(),
therefore when something wrong happens at this stage, which is as
critial as image conversion, the empty volume created as image cache
wouldn't be deleted.  And that invalid image cache would cause all
consecutive volume creation from same image fail silently.

This change makes simple adjustment of the code to make sure the
errors happen at connecting volume to controler stage is being
covered.

Change-Id: Idd192be86a83dc341431593ab27bed9178cc36d1
Closes-bug: #1663782
(cherry picked from commit 55c1863e1d)
This commit is contained in:
Zhiteng Huang 2017-02-10 19:16:51 -07:00 committed by Huang Zhiteng
parent dbc0f1a7d9
commit a73e37aff5
1 changed files with 6 additions and 4 deletions

View File

@ -821,11 +821,12 @@ class SolidFireDriver(san.SanISCSIDriver):
tvol['provider_location'] = template_vol['provider_location']
tvol['provider_auth'] = template_vol['provider_auth']
connector = {'multipath': False}
conn = self.initialize_connection(tvol, connector)
attach_info = super(SolidFireDriver, self)._connect_device(conn)
properties = 'na'
try:
connector = {'multipath': False}
conn = self.initialize_connection(tvol, connector)
attach_info = super(SolidFireDriver, self)._connect_device(
conn)
properties = 'na'
image_utils.convert_image(tmp_image,
attach_info['device']['path'],
'raw',
@ -848,6 +849,7 @@ class SolidFireDriver(san.SanISCSIDriver):
vol['volumeID'])
self._detach_volume(context, attach_info, tvol, properties)
self._issue_api_request('DeleteVolume', params)
self._issue_api_request('PurgeDeletedVolume', params)
return
self._detach_volume(context, attach_info, tvol, properties)