Skip to content

--failhard option not working as expected #24996

Closed

Description

@danlsgiga

The --failhard parameter for the salt command is supposed to stop batch execution upon first "bad" return. This is not happening even when failhard = True in the master config.
Quick example:
salt -b 1 --failhard 'nginx*' cmd.run 'systemctl restart nginx'
is executing in all targetted systems regardless of the error return code. It should stop the batch execution at the first failed execution.

Activity

  1. justinta commented on Jun 29, 2015

    @justinta

    @danlsgiga Can you provide the output from salt --versions-report? Thanks!

  2. added
    needs-more-info
    on Jun 29, 2015
  3. added this to the Blocked milestone on Jun 29, 2015
  4. danlsgiga commented on Jun 29, 2015

    @danlsgiga
    ContributorAuthor

    Sure! Here it goes:
    salt --versions-report
    Salt: 2015.5.2
    Python: 2.7.5 (default, Jun 24 2015, 00:41:19)
    Jinja2: 2.7.2
    M2Crypto: 0.21.1
    msgpack-python: 0.4.6
    msgpack-pure: Not Installed
    pycrypto: 2.6.1
    libnacl: Not Installed
    PyYAML: 3.10
    ioflo: Not Installed
    PyZMQ: 14.3.1
    RAET: Not Installed
    ZMQ: 3.2.5
    Mako: Not Installed

  5. danlsgiga commented on Jul 8, 2015

    @danlsgiga
    ContributorAuthor

    Just as an update, I made some tests using the batch mode and --failhard with modules and it is working fine, the issue is happening only when using the cmd.run module. So, for example:
    salt -b 1 --failhard '' service.restart httpd -> Works
    salt -b 1 --failhard '
    ' cmd.run 'systemctl restart httpd' -> Doesn't work even when ret code != 0

  6. danlsgiga commented on Aug 7, 2015

    @danlsgiga
    ContributorAuthor

    I was reading the salt -d documentation and tried the cmd.run_all module with the -b1 --failhard parameters. So, it turned out that I must use cmd.run_all instead of cmd.run to have the --failhard parameter to be effectively working. Is that on purpose or is it a bug?

  7. danlsgiga commented on Aug 7, 2015

    @danlsgiga
    ContributorAuthor

    Here are the results for the cmd.run module:

    salt -b1 --failhard 'minion*' cmd.run 'systemctl restart httpd'

    Executing run on ['minion3.local.dom']

    minion3.local.dom:
    /bin/sh: systemctl: command not found
    retcode:
    127

    Executing run on ['minion1.local.dom']

    minion1.local.dom:
    Failed to issue method call: Unit httpd.service failed to load: No such file or directory.
    retcode:
    6

    Executing run on ['minion2.local.dom']

    minion2.local.dom:
    Failed to issue method call: Unit httpd.service failed to load: No such file or directory.
    retcode:
    6

  8. danlsgiga commented on Aug 7, 2015

    @danlsgiga
    ContributorAuthor

    Here are the results for the cmd.run module:

    salt -b1 --failhard 'minion*' cmd.run_all 'systemctl restart httpd'

    Executing run on ['minion3.local.dom']

  9. added
    bug
    Core
    P3
    severity-medium
    and removed
    needs-more-info
    on Aug 7, 2015
  10. modified the milestones: Approved, Blocked on Aug 7, 2015
  11. justinta commented on Aug 7, 2015

    @justinta

    @danlsgiga I'm so sorry for the delay on this, I seem to have not gotten a notification from your updates until today... Let me look into --failhard a little more. I'm leaning towards this being a bug, but I may be missing something about it being expected behavior.

  12. danlsgiga commented on Aug 7, 2015

    @danlsgiga
    ContributorAuthor

    @jtand No worries... The behaviour I expected on cmd.run using the batch mode and --failhard is working great if I use cmd.run_all. But yeah, it's a good idea to check if cmd.run must behave like that or if it is a bug. I'm also leaning towards this being a bug, because the only specification difference between cmd.run and cmd.run_all should be cmd.run returns data as string and cmd.run_all as a dict. Thanks!! ;)

  13. added
    P2
    and removed
    P3
    on Apr 11, 2016
  14. added a commit that references this issue on May 4, 2016
    2d14bd6
  15. rallytime commented on May 4, 2016

    @rallytime
    Contributor

    @danlsgiga The fix in #33048 should button this up for you. I showed an example of the previous behavior and the new behavior in the pull request. Please give that a try and let me know how it goes.

    Note that the command doesn't currently give any output about the failure as it stands in that fix. I'm going to address that in a new PR to fix #32452, which is linked above.

  16. added
    fixed-pls-verify
    on May 4, 2016
  17. modified the milestones: B -3, Approved on May 4, 2016
  18. self-assigned this
    on May 4, 2016
  19. danlsgiga commented on May 4, 2016

    @danlsgiga
    ContributorAuthor

    Hey @rallytime, awesome news! Thanks for working on this!
    So, yeah, I've just changed my batch.py code to the proposed commit, restarted salt-master and it works like a charm!!!
    Awesome!!!!

  20. rallytime commented on May 4, 2016

    @rallytime
    Contributor

    @danlsgiga Sweeeet! Glad to hear it! :D

  21. added a commit that references this issue on May 5, 2016
    54b783a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreP2bugfixed-pls-verifyseverity-medium

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions