From bc3c22aa3c6e30ce90c35cf3e36c5f0408552bfa Mon Sep 17 00:00:00 2001 From: Zhiteng Huang Date: Fri, 10 Feb 2017 19:16:51 -0700 Subject: [PATCH] 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 55c1863e1dcd834f491085365e774d017c147448) --- cinder/volume/drivers/solidfire.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 88d2e1af8..9e44f1cd6 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -721,11 +721,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', @@ -748,6 +749,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)