Fix unsaved exception in v1 API controller

When an exception occurs during exception handling, it lose the
information of the first exception.

We should use the excutils.save_and_reraise_exception() in this case.

Change-Id: I467c9627fa661421926d50c3e894f80d9b75baa2
Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
Zhi Yan Liu 2014-07-10 14:05:09 +08:00
parent a62cdcefb0
commit c725a56962

View File

@ -1031,10 +1031,10 @@ class Controller(controller.BaseController):
if image['location']:
upload_utils.initiate_deletion(req, image['location'], id,
CONF.delayed_delete)
except Exception as e:
registry.update_image_metadata(req.context, id,
{'status': ori_status})
raise e
except Exception:
with excutils.save_and_reraise_exception():
registry.update_image_metadata(req.context, id,
{'status': ori_status})
registry.delete_image_metadata(req.context, id)
except exception.NotFound as e:
msg = _("Failed to find image to delete: %(e)s") % {'e': e}