diff options
author | Galyna Zholtkevych <gzholtkevych@mirantis.com> | 2016-09-15 16:26:29 +0300 |
---|---|---|
committer | Jim Rollenhagen <jim@jimrollenhagen.com> | 2016-09-21 10:02:22 -0400 |
commit | 993149cfb491dd81b9e9fda155c26d06e16d6fc2 (patch) | |
tree | ab00c8091def875097de81d09859b17dc3e36e77 | |
parent | c4c7115d4fc194a6de76ff9a7f8090863041828d (diff) | |
download | ironic-python-agent-993149cfb491dd81b9e9fda155c26d06e16d6fc2.tar.gz |
Improve error message while download image
Collecting warning logs in the case of download failure
and write them to error logs in the end. This will help
a user to diagnose a problem when warning log was not
enabled.
Change-Id: I4198d7be08fc11b616b3f95c595ff53794436e24
Partial-Bug: 1512186
-rw-r--r-- | ironic_python_agent/extensions/standby.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index a3d1ccac..5e535dfd 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -277,21 +277,25 @@ class ImageDownload(object): self._md5checksum = hashlib.md5() self._time = time_obj or time.time() self._request = None - + details = [] for url in image_info['urls']: try: LOG.info("Attempting to download image from {0}".format(url)) self._request = self._download_file(image_info, url) except errors.ImageDownloadError as e: failtime = time.time() - self._time - log_msg = ('Image download failed. URL: {0}; time: {1} ' - 'seconds. Error: {2}') - LOG.warning(log_msg.format(url, failtime, e.details)) + log_msg = ('URL: {0}; time: {1} ' + 'seconds. Error: {2}').format( + url, failtime, e.details) + LOG.warning('Image download failed. %s', log_msg) + details += log_msg continue else: break else: - msg = 'Image download failed for all URLs.' + details = '/n'.join(details) + msg = ('Image download failed for all URLs with following errors: ' + '{}'.format(details)) raise errors.ImageDownloadError(image_info['id'], msg) def _download_file(self, image_info, url): |