From c94458d4df1fd3ee0c51f4237823f08b8a85af4f Mon Sep 17 00:00:00 2001 From: Harsh Shah Date: Thu, 1 Oct 2015 16:18:57 +0000 Subject: [PATCH] Add resource fault detail in exception This commit adds the fault attribute of resource to exception message when the resource goes into error state. This will allow easy lookup and tracking of the actual cause of the error rather than manually looking it up for each resource. Adding to exception also allows the detailed error to be available in the generated reports. Change-Id: I1293bc5b2fd1c344f0752d5cb89ccbbcebb351fc --- rally/exceptions.py | 3 ++- rally/task/utils.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rally/exceptions.py b/rally/exceptions.py index 4aa9d9a9e6..9f9a33ec32 100644 --- a/rally/exceptions.py +++ b/rally/exceptions.py @@ -137,7 +137,8 @@ class GetResourceNotFound(GetResourceFailure): class GetResourceErrorStatus(GetResourceFailure): - msg_fmt = _("Resource %(resource)s has %(status)s status.") + msg_fmt = _("Resource %(resource)s has %(status)s status.\n" + "Fault: %(fault)s") class ScriptError(RallyException): diff --git a/rally/task/utils.py b/rally/task/utils.py index 9eaa5b5271..413e924f60 100644 --- a/rally/task/utils.py +++ b/rally/task/utils.py @@ -85,8 +85,9 @@ def get_from_manager(error_statuses=None): if status in ("DELETED", "DELETE_COMPLETE"): raise exceptions.GetResourceNotFound(resource=res) if status in error_statuses: - raise exceptions.GetResourceErrorStatus(resource=res, - status=status) + raise exceptions.GetResourceErrorStatus( + resource=res, status=status, + fault=getattr(res, "fault", "n/a")) return res