Skip to content
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

--failhard option not working as expected #24996

Closed
danlsgiga opened this issue Jun 26, 2015 · 11 comments
Closed

--failhard option not working as expected #24996

danlsgiga opened this issue Jun 26, 2015 · 11 comments
Assignees
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@danlsgiga
Copy link
Contributor

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.

@justinta
Copy link

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

@justinta justinta added the info-needed waiting for more info label Jun 29, 2015
@justinta justinta added this to the Blocked milestone Jun 29, 2015
@danlsgiga
Copy link
Contributor Author

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

@danlsgiga
Copy link
Contributor Author

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

@danlsgiga
Copy link
Contributor Author

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?

@danlsgiga
Copy link
Contributor Author

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

@danlsgiga
Copy link
Contributor Author

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']

@justinta justinta added Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around and removed info-needed waiting for more info labels Aug 7, 2015
@justinta justinta modified the milestones: Approved, Blocked Aug 7, 2015
@justinta
Copy link

justinta commented Aug 7, 2015

@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.

@danlsgiga
Copy link
Contributor Author

@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!! ;)

@rallytime
Copy link
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.

@rallytime rallytime added the fixed-pls-verify fix is linked, bug author to confirm fix label May 4, 2016
@rallytime rallytime modified the milestones: B -3, Approved May 4, 2016
@rallytime rallytime self-assigned this May 4, 2016
@danlsgiga
Copy link
Contributor Author

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!!!!

@rallytime
Copy link
Contributor

@danlsgiga Sweeeet! Glad to hear it! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

4 participants