-
-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BrigadeSubTaskError for grouped tasks #131
Conversation
Raises BrigadeSubTaskError when a subtask to a grouped task has failed, this allows for a prettier error message when using print_output()
Pull Request Test Coverage Report for Build 647
💛 - Coveralls |
brigade/core/exceptions.py
Outdated
has failed | ||
|
||
Arguments: | ||
task (str): Name of the sub task that failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think task should be a reference the task itself, not just the name. I think we should also have a reference to the result. So you'd basically call this like (see comment below)
brigade/core/task.py
Outdated
if r.failed: | ||
# Without this we will keep running the grouped task | ||
raise r.exception | ||
raise BrigadeSubTaskError((r.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given my previous comment I think this should be:
raise BrigadeSubTaskError(task=task, error=r)
That will also mean we have to change:
r = Task(task, **kwargs).start(self.host, self.brigade)
to:
task = Task(task, **kwargs)
r = task.start(self.host, self.brigade)
brigade/core/exceptions.py
Outdated
def __str__(self): | ||
text = "\n" | ||
text += "{}\n".format("#" * 40) | ||
text += "# Subtask: {} (failed)\n".format(self.task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the #
(including the space before the S
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, just reread it. I think we should just return Subtask: {} (failed)\n".format(self.task)
. Nothing else.
@@ -61,10 +62,17 @@ def start(self, host, brigade): | |||
r = self.task(self, **self.params) | |||
if not isinstance(r, Result): | |||
r = Result(host=host, result=r) | |||
|
|||
except BrigadeSubTaskError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this block, do we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a small difference as I don't save the traceback in the result key after BrigadeSubTaskError. Do you want to remove it?
@@ -13,7 +13,9 @@ Hello from CRITICAL | |||
[1m[32m^^^^ END read_data ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |||
[1m[34m* dev4.group_2 ** changed : False ********************************************** | |||
[1m[31mvvvv read_data ** changed : False vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ERROR | |||
Exception('Unknown Error -> Contact your system administrator',) | |||
BrigadeSubTaskError() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have been something like Subtask: parse_data (failed)\n
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's due to this:
https://github.com/brigade-automation/brigade/blob/develop/tests/plugins/functions/text/test_print_result.py#L101
Because the result key isn't printed. That's to avoid showing the traceback which contains my local paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that should output the task name and the arguments used if possible. If it's too hard we can open an issue and fix it later
Raises BrigadeSubTaskError when a subtask to a grouped task has failed,
this allows for a prettier error message when using print_output()
I haven't changed the output from the tests for print_output yet so currently this will fail.
With a test script:
Running the script with the current develop branch:
Running the script with this PR:
With something like this in place I think we can also ignore #129.