saltstack / pepper

A library and stand-alone CLI tools to access a salt-api instance
Other
246 stars 124 forks source link

Salt runner client does not properly report exit code #195

Open jmarinaro opened 5 years ago

jmarinaro commented 5 years ago

The salt runner is not passing through the exit code due not matching the expected format of a list of minion returns. The runner is returning an extra data dictionary wrapper.

Before

# pepper --fail-any --client runner state.sls debug/state; echo $?
{
    "return": [
        {
            "data": {
                "salt_master": {
                    "test_|-always-fails_|-foo_|-fail_without_changes": {
                        "__id__": "always-fails",
                        "__run_num__": 1,
                        "__sls__": "debug/state",
                        "changes": {},
                        "comment": "Failure!",
                        "duration": 0.505,
                        "name": "foo",
                        "result": false,
                        "start_time": "20:49:18.876819"
                    },
                    "test_|-always-passes_|-foo_|-succeed_without_changes": {
                        "__id__": "always-passes",
                        "__run_num__": 0,
                        "__sls__": "debug/state",
                        "changes": {},
                        "comment": "Success!",
                        "duration": 0.443,
                        "name": "foo",
                        "result": true,
                        "start_time": "20:49:18.876186"
                    }
                }
            },
            "outputter": "highstate",
            "retcode": 1
        }
    ]
}
0

After

# pepper --fail-any --client runner state.sls debug/state; echo $?
{
    "return": [
        {
            "data": {
                "salt_master": {
                    "test_|-always-fails_|-foo_|-fail_without_changes": {
                        "__id__": "always-fails",
                        "__run_num__": 1,
                        "__sls__": "debug/state",
                        "changes": {},
                        "comment": "Failure!",
                        "duration": 0.543,
                        "name": "foo",
                        "result": false,
                        "start_time": "21:13:17.477775"
                    },
                    "test_|-always-passes_|-foo_|-succeed_without_changes": {
                        "__id__": "always-passes",
                        "__run_num__": 0,
                        "__sls__": "debug/state",
                        "changes": {},
                        "comment": "Success!",
                        "duration": 0.575,
                        "name": "foo",
                        "result": true,
                        "start_time": "21:13:17.477012"
                    }
                }
            },
            "outputter": "highstate",
            "retcode": 1
        }
    ]
}
1

debug/state.sls

always-passes:
  test.succeed_without_changes:
    - name: foo

always-fails:
  test.fail_without_changes:
    - name: foo