From 09da2937a85c5032cffea850cb31e963d5627321 Mon Sep 17 00:00:00 2001 From: Sam Betts Date: Thu, 28 Sep 2017 17:28:37 +0100 Subject: [PATCH] Stop passing raw Exceptions as the reasons for ironic Image exceptions When an exception occured in the ironic image service code, the raw exception was passed into the IronicException as the reason. The ironic exception logic then attempted to converted it to json which fails and then falls back to converting it to string. This patch preemptively converts the Exception to string to avoid that first failure. Change-Id: Id3a166a74505c142d7217217882246a64f625eb8 --- ironic/common/image_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ironic/common/image_service.py b/ironic/common/image_service.py index c85c1f11c5f..10ff11ff98a 100644 --- a/ironic/common/image_service.py +++ b/ironic/common/image_service.py @@ -118,7 +118,7 @@ class HttpImageService(BaseImageService): "HEAD request.") % response.status_code) except requests.RequestException as e: raise exception.ImageRefValidationFailed(image_href=output_url, - reason=e) + reason=six.text_type(e)) return response def download(self, image_href, image_file): @@ -143,7 +143,7 @@ class HttpImageService(BaseImageService): shutil.copyfileobj(input_img, image_file, IMAGE_CHUNK_SIZE) except (requests.RequestException, IOError) as e: raise exception.ImageDownloadFailed(image_href=image_href, - reason=e) + reason=six.text_type(e)) def show(self, image_href): """Get dictionary of image properties. @@ -235,7 +235,7 @@ class FileImageService(BaseImageService): 0, filesize) except Exception as e: raise exception.ImageDownloadFailed(image_href=image_href, - reason=e) + reason=six.text_type(e)) def show(self, image_href): """Get dictionary of image properties.