{"action":"opened","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/30914","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/30914/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/30914/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/30914/events","html_url":"https://github.com/saltstack/salt/issues/30914","id":131509204,"number":30914,"title":"minion retcode is incorrect","user":{"login":"plastikos","id":3281727,"avatar_url":"https://avatars.githubusercontent.com/u/3281727?v=3","gravatar_id":"","url":"https://api.github.com/users/plastikos","html_url":"https://github.com/plastikos","followers_url":"https://api.github.com/users/plastikos/followers","following_url":"https://api.github.com/users/plastikos/following{/other_user}","gists_url":"https://api.github.com/users/plastikos/gists{/gist_id}","starred_url":"https://api.github.com/users/plastikos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plastikos/subscriptions","organizations_url":"https://api.github.com/users/plastikos/orgs","repos_url":"https://api.github.com/users/plastikos/repos","events_url":"https://api.github.com/users/plastikos/events{/privacy}","received_events_url":"https://api.github.com/users/plastikos/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-04T23:48:12Z","updated_at":"2016-02-04T23:48:12Z","closed_at":null,"body":"Certain state failures do not set `retcode` properly.  Consequently the master does not enumerate the minions as failed and summary information is incorrect.  This appears to be related to states that cause additional salt calls that instantiate new `__context__`.  The roll-up of child `__context__` to the parent `__context__` fails and then `__context__['retcode']` is incorrect.\r\n\r\nIt is notable that when the master *parses* the return information for colorization that the failed states are correctly colorized due to state return structures correctly indicate the failure.  Unfortunately the overall success/failure is determined by reading `retcode` which is incorrect.  Consequently summary information provided by `-v --summary` is incorrect.  This can go unnoticed when visually scanning the output from a few minions, but when there are thousands of minions the summary information must be reliable.\r\n\r\nPut the following contents in `junk/foo.sls`:\r\n\r\n> #!jinja|yaml\r\n>\r\n> foo:\r\n>   cmd.run:\r\n>     - name: 'true'\r\n>     - check_cmd:\r\n>       - 'false'\r\n\r\nThe following is expected output:\r\n\r\n> [root@orc1.ut1 ~]# salt -v --summary minion-a state.apply junk.foo\r\n> Executing job with jid 20160204153220765528\r\n> -------------------------------------------\r\n>\r\n> minion-a:\r\n> ----------\r\n>           ID: foo\r\n>     Function: cmd.run\r\n>         Name: true\r\n>       Result: False\r\n>      Comment: check_cmd determined the state failed\r\n>      Started: 15:32:22.346851\r\n>     Duration: 785.631 ms\r\n>      Changes:\r\n>               ----------\r\n>               pid:\r\n>                   13114\r\n>               retcode:\r\n>                   0\r\n>               stderr:\r\n>               stdout:\r\n>\r\n> Summary for minion-a\r\n> ------------\r\n> Succeeded: 0 (changed=1)\r\n> Failed:    1\r\n> ------------\r\n> Total states run:     1\r\n> Total run time: 785.631 ms\r\n>\r\n>\r\n> -------------------------------------------\r\n> Summary\r\n> -------------------------------------------\r\n> # of minions targeted: 1\r\n> # of minions returned: 1\r\n> # of minions that did not return: 0\r\n> # of minions with errors: 1\r\n> Minions with failures: minion-a\r\n> -------------------------------------------\r\n> ERROR: Minions returned with non-zero exit code\r\n\r\nWhile `minion-a` shows a `Failed: 1` it does not show as a minion with errors.\r\n"}}