Skip to content

cmd.run_all with --batch and --failhard gives no output on failure #32452

Closed

Description

@nicholascapo

When using cmd.run_all with --batch and --failhard, if a failure occurs the output from that minion is not displayed.

Expected:

$ sudo salt --batch=1 --failhard 'minion*' cmd.run_all 'not_a_command'

Executing run on ['minion2']

minion2:
    ----------
    pid:
        11525
    retcode:
        127
    stderr:
        /bin/sh: 1: not_a_command: not found
    stdout:


ERROR: Minions returned with non-zero exit code

Got:

$ sudo salt --batch=1 --failhard 'minion*' cmd.run_all 'not_a_command'

Executing run on ['minion1']

ERROR: Minions returned with non-zero exit code

$ sudo salt --versions-report
Salt Version:
           Salt: 2015.8.8.2

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
         Python: 2.7.9 (default, Mar  1 2015, 12:57:24)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: Not Installed
       dateutil: 2.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: 0.3.6
          smmap: 0.8.2
        timelib: Not Installed

System Versions:
           dist: debian 8.4 
        machine: x86_64
        release: 3.16.0-4-amd64
         system: debian 8.4 

Activity

  1. nicholascapo commented on Apr 8, 2016

    @nicholascapo
    Author

    I am trying to build a deployment system using salt, and I need to run commands on minions in series, and fail fast.
    I was hoping to use cmd.run but #24996
    Then I found cmd.run_all but then I found this issue.

  2. added
    bug
    severity-medium
    Core
    P2
    on Apr 11, 2016
  3. added this to the Approved milestone on Apr 11, 2016
  4. jfindlay commented on Apr 11, 2016

    @jfindlay
    Contributor

    @nicholascapo, thanks for reporting.

  5. added a commit that references this issue on May 4, 2016
    c9c445f
  6. rallytime commented on May 4, 2016

    @rallytime
    Contributor

    @nicholascapo I have fixed this issue with PR #33050. This fix will display a data dictionary with the ret of the command that failed, like so:

    root@rallytime:~# salt rallytime cmd.run_all 'foo' -b 1 --failhard
    
    Executing run on ['rallytime']
    
    {'rallytime': {'retcode': 127, 'ret': {'pid': 5838, 'retcode': 127, 'stderr': '/bin/bash: foo: command not found', 'stdout': ''}}}
    ERROR: Minions returned with non-zero exit code.
    

    Because the batch system doesn't have it's own outputter, we must write the error here in this manor.

    I have also fixed #24996 to make sure cmd.run with --batch and --failhard actually recognize failing commands and failhard. With both of these commands combined, the expected output for a cmd.run call looks like this now:

    root@rallytime:~# salt rallytime cmd.run 'foo' -b 1 --failhard
    
    Executing run on ['rallytime']
    
    {'rallytime': {'retcode': 127, 'ret': '/bin/bash: foo: command not found'}}
    ERROR: Minions returned with non-zero exit code.
    
  7. modified the milestones: B -3, Approved on May 4, 2016
  8. self-assigned this
    on May 4, 2016
  9. added
    fixed-pls-verify
    on May 4, 2016
  10. added a commit that references this issue on May 5, 2016
    2dbfa55
  11. nicholascapo commented on Jun 7, 2016

    @nicholascapo
    Author

    @rallytime Sorry for the delay, I can confirm this is fixed in version 2015.8.10

    Thanks

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