-
Notifications
You must be signed in to change notification settings - Fork 8
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
error_set not populated if fail_ok true and assertion fails #97
Comments
The code treats a task that failed, while fail_ok is true and that only had 1 try as success. Now, debatable if this is right - seems to me its not - but I am also I am not sure I can change this behaviour as it will break things for people. Difficult to know whats right here |
@ripienaar the line you pointed out is a problem (for me), but I think the issue I reported is about something slightly different: Namely, that when an assertion fails with In other words, failure by assertion is treated differently than other kinds of failures which is problematic. Regarding the problem you pointed out: I would suggest that
I'm happy to create a separate issue if you want me to. |
yes, I understand the problem, error set is only populated for failed requests - the request didnt fail, it merely didnt match. Where as it is error set is only for actual failed requests where the RPC request failed. The task system detect this more or less correctly though and correctly marks the overall task run as failed despite the rpc requests passing because it understands the assert intention, however this line that I highlighted then takes the failed request - because assert set it to fail - and force it back to success because it was fail_ok, 1 try and marked as failed. Ultimately the problem is the line I highlighted, right before this block the result from your scenario is:
this then sets it to successful and so it never makes it into error set. task behavior is right, exposing that result set to puppet is not - its this exposing that gets done right here and munges the data. I appreciate the desire though but as things stand I don't think the basic intent with the design is to treat individual PRC replies that does not pass assertion as error, it operates at a higher level - it makes the whole task fail or not based on assertion over replies and this seems right to me. The |
Hi @ripienaar , Thanks for the detail - I see what you mean now. I see the subtle distinction you are making between assertion and RPC failure, but I consider this to be problematic on the following counts:
So you would need something like the following code to extract the set of nodes that failed RPC or assertion: $t4_res = choria::task(
'action' => 'puppet.last_run_summary',
'nodes' => $nodes,
'fail_ok' => true,
'assert' => 'summary.events.failure=0',
'tries' => 1,
'silent' => true,
)
# Work around https://github.com/choria-io/mcollective-choria/issues/617
notice($t4_res)
$fail_res = $t4_res.ok_set.filter |Choria::TaskResult $r| {$r['data']['summary']['events']['failure'] != 0 + $t4_res.error_set }
$good_res = $t4_res.results.filter |Choria::TaskResult $r| {$r['data']['summary']['events']['failure'] == 0 }
Since we are supporting assertions as a first class concept, maybe the solution is to return another result set that is the set of nodes for which an assertion failed. Or alternatively, it could be a property of nodes in the |
yeah the docs took me a long time to figure out too and I had to spelunk into the code to figure out the answer and what the intended behaviour is, we definitely have a huge gap in the docs here. We can create something like a method on the Results set, something like:
Would that help a bit? At least that would be the same assertion language etc and feels a bit more natural? |
I think that would help and be a decent addition. It still leaves the potential for confusion around the concept of "failure", though. To keep code changes minimal, how about this for now:
I can do the first task fairly easily, but I'm less sure about 2+3. |
@ripienaar Now that the holidays are over I'm keen to get a resolution on this. What do you think about the options I outlined? I can probably help with the implementation if you give me some pointers. |
I havnt had a chance to go through this again and think through all the implications. Gathering results on actual fails isnt possible without major plumbum, assert fails we can probably do and I like the jgrep helper in general |
Summary
Observation:
When
fail_ok
is set and an assertion is also set, the resultant choria task has an emptyerror_set
.Expected
Per the tips on error handling the documentation I expect the
error_set
to be populated with the tasks whose assertions failed even thoughfail_ok
is set.Details
Given the following plan with an assertion that will never succeed
the
$t1_res
results set will have an emptyerror_set
- all the results will be in theok_set
.The execution log shows this:
NOTE that if I remove the assertion and instead make the task fail in another way the error_set is populated as expected:
Versions
Puppet AIO: 6.3.0
mcollective_choria
module: 0.17.1The text was updated successfully, but these errors were encountered: