Skip to content

error_set not populated if fail_ok true and assertion fails #97

@ExalDraen

Description

@ExalDraen

Summary

Observation:

When fail_ok is set and an assertion is also set, the resultant choria task has an empty error_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 though fail_ok is set.

Details

Given the following plan with an assertion that will never succeed

plan orchestration::assert_err_test (
) {
  $servers = ['kdhstage-ems03.grass.corp']
  $t1_res = choria::task(
    'action'    => 'puppet.status',
    'nodes'     => $servers,
    'assert'    => 'applying=nevermatch',
    'fail_ok'   => true,
    'silent'    => true,
  )
  notice($t1_res)
  notice("------ Error set ----------")
  notice($t1_res.error_set)
  notice("------ OK set ----------")
  notice($t1_res.ok_set)
}

the $t1_res results set will have an empty error_set - all the results will be in the ok_set.
The execution log shows this:

alexander.hermes orchestration $ mco playbook run orchestration::assert_err_test --modulepath $HOME/code/puppet/modules
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): About to run task: mcollective task
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Starting request for puppet#status against 1 nodes
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Assertion 'applying=nevermatch' failed on 1/1 nodes
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Task failed but fail_ok is true, treating as success
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Failed request 841cc322e989540d86c7d74bd16953d8 for puppet#status assertion failed on 1 node(s)
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 11): Choria::TaskResults({'results' => [Choria::TaskResult({'host' => 'kdhstage-ems03.grass.corp', 'result' => {'value' => {'agent' => 'puppet', 'action' => 'status', 'sender' => 'kdhstage-ems03.grass.corp', 'statuscode' => 0, 'statusmsg' => 'OK', 'data' => {'applying' => false, 'idling' => false, 'enabled' => true, 'daemon_present' => false, 'lastrun' => 1575606931, 'since_lastrun' => 1316, 'status' => 'stopped', 'disable_message' => '', 'message' => 'Currently stopped; last completed run 21 minutes 56 seconds ago'}, 'requestid' => '841cc322e989540d86c7d74bd16953d8'}, 'type' => 'mcollective', 'fail_ok' => true}})]})
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 12): ------ Error set ----------
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 13): Choria::TaskResults({'results' => []})
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 14): ------ OK set ----------
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 15): Choria::TaskResults({'results' => [Choria::TaskResult({'host' => 'kdhstage-ems03.grass.corp', 'result' => {'value' => {'agent' => 'puppet', 'action' => 'status', 'sender' => 'kdhstage-ems03.grass.corp', 'statuscode' => 0, 'statusmsg' => 'OK', 'data' => {'applying' => false, 'idling' => false, 'enabled' => true, 'daemon_present' => false, 'lastrun' => 1575606931, 'since_lastrun' => 1316, 'status' => 'stopped', 'disable_message' => '', 'message' => 'Currently stopped; last completed run 21 minutes 56 seconds ago'}, 'requestid' => '841cc322e989540d86c7d74bd16953d8'}, 'type' => 'mcollective', 'fail_ok' => true}})]})

NOTE that if I remove the assertion and instead make the task fail in another way the error_set is populated as expected:

alexander.hermes orchestration $ mco playbook run orchestration::assert_err_test --modulepath $HOME/code/puppet/modules
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): About to run task: mcollective task
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Starting request for puppet#enable against 1 nodes
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): kdhstage-ems03.grass.corp puppet#enable failure: {:status=>"Could not enable Puppet: Already enabled", :enabled=>true}
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Failed request 8b4a8e41cf8c5d4687cee7c46643869f for puppet#enable in 1.12s
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Failed result from kdhstage-ems03.grass.corp: Could not enable Puppet: Already enabled
Warning: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Task failed but fail_ok is true, treating as success
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 4): Failed request 8b4a8e41cf8c5d4687cee7c46643869f for puppet#enable on 1 failed node(s)
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 13): Choria::TaskResults({'results' => [Choria::TaskResult({'host' => 'kdhstage-ems03.grass.corp', 'result' => {'value' => {'agent' => 'puppet', 'action' => 'enable', 'sender' => 'kdhstage-ems03.grass.corp', 'statuscode' => 1, 'statusmsg' => 'Could not enable Puppet: Already enabled', 'data' => {'status' => 'Could not enable Puppet: Already enabled', 'enabled' => true}, 'requestid' => '8b4a8e41cf8c5d4687cee7c46643869f'}, 'type' => 'mcollective', 'fail_ok' => true, 'error' => {'msg' => 'Could not enable Puppet: Already enabled', 'kind' => 'choria.playbook/taskerror', 'details' => {'agent' => 'puppet', 'action' => 'enable', 'issue_code' => 1}}}})]})
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 14): ------ Error set ----------
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 15): Choria::TaskResults({'results' => [Choria::TaskResult({'host' => 'kdhstage-ems03.grass.corp', 'result' => {'value' => {'agent' => 'puppet', 'action' => 'enable', 'sender' => 'kdhstage-ems03.grass.corp', 'statuscode' => 1, 'statusmsg' => 'Could not enable Puppet: Already enabled', 'data' => {'status' => 'Could not enable Puppet: Already enabled', 'enabled' => true}, 'requestid' => '8b4a8e41cf8c5d4687cee7c46643869f'}, 'type' => 'mcollective', 'fail_ok' => true, 'error' => {'msg' => 'Could not enable Puppet: Already enabled', 'kind' => 'choria.playbook/taskerror', 'details' => {'agent' => 'puppet', 'action' => 'enable', 'issue_code' => 1}}}})]})
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 16): ------ OK set ----------
Notice: Scope(<module>/orchestration/plans/assert_err_test.pp, 17): Choria::TaskResults({'results' => []})

Versions

Puppet AIO: 6.3.0
mcollective_choria module: 0.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions