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

salt.hightstate no top file error but exit status is zero #6973

Closed
mitchellh opened this issue Aug 30, 2013 · 17 comments
Closed

salt.hightstate no top file error but exit status is zero #6973

mitchellh opened this issue Aug 30, 2013 · 17 comments
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix severity-low 4th level, cosemtic problems, work around exists
Milestone

Comments

@mitchellh
Copy link

I ran salt.highstate and it gave me an error about no top file and yet the exit status was still zero. This is breaking error detection in tools like Vagrant and Packer because they can't detect if it failed.

See here: https://gist.github.com/armon/843f44777db3cf6e20f9

@basepi
Copy link
Contributor

basepi commented Sep 3, 2013

Yes, this is something we've been meaning to fix. Thanks for the report.

@terminalmage
Copy link
Contributor

So, I did some digging, and within the state module __context__['retcode'] was set to nonzero, the salt CLI just isn't returning it.

@s0undt3ch
Copy link
Collaborator

Please try again by passing --retcode-passthrough to salt

@terminalmage
Copy link
Contributor

Actually, the retcode wasn't being set right, I had modified salt/utils/init.py.

Here's an example of the ret data in a highstate, which ends up getting passed to salt.utils.check_state_result()

{'no_|-states_|-states_|-None': {
    'comment': 'No Top file or external nodes data matches found',
    '__run_num__': 0,
    'changes': {},
    'result': False,
    'name': 'No States'
    }
}

There seems to be a bug here, so I changed this line to:

if '_|-' in host:

@s0undt3ch
Copy link
Collaborator

Hmm, that's a fix @thatch45 did a while back because I was having some issues... Can't remember what the issue was...

@terminalmage
Copy link
Contributor

@s0undt3ch

(saltdev)[root@virtucentos saltdev]# salt -c etc/salt --retcode-passthrough virtucentos state.highstate
Usage: salt [options] '<target>' <function> [arguments]

salt: error: no such option: --retcode-passthrough

@s0undt3ch
Copy link
Collaborator

Your fix might work because the will never be a key like _|-, hopefully...

@s0undt3ch
Copy link
Collaborator

@terminalmage, salt-call

@s0undt3ch
Copy link
Collaborator

I wonder if we can also add it to the salt binary...

@s0undt3ch
Copy link
Collaborator

Hmm, no, if returning info from several minions and only one failed? Or two failed with different exit codes...

@s0undt3ch
Copy link
Collaborator

Sorry for the misleading in my initial comment about --retcode-passthrough. It's available for salt-call not salt.

@dlanderson
Copy link
Contributor

Added a test to make sure 'salt-call --retcode-passthrough' works as intended in #7224

jcollie pushed a commit to jcollie/salt that referenced this issue Nov 15, 2013
…e for saltstack#6973 - expect a non-zero exit code when running "salt-call --retcode-passthrough state.highstate"
@techdragon
Copy link
Contributor

more bad return code issues - linking to issue #7013

@basepi basepi modified the milestones: Approved, Outstanding Bugs Apr 21, 2014
@cachedout
Copy link
Contributor

This does not seem to be an error in the current version of Salt.

mp@silver:~$ sudo salt silver state.highstate
silver:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or external nodes data matches found
     Started: 
     Duration:  ms
     Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
mp@silver:~$ echo $?
11

And with salt-call

mp@silver:~$ sudo salt-call --local  --retcode-passthrough state.highstate
[INFO    ] Loading fresh modules for state activity
local:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or external nodes data matches found
     Started: 
     Duration:  ms
     Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
mp@silver:~$ echo $?
2

@techdragon and @mitchellh is this the behaviour you would expect?

@techdragon
Copy link
Contributor

@cachedout That looks good to me.

@mitchellh can you confirm?

@cachedout
Copy link
Contributor

Thanks for the reply @techdragon. I think this is fixed but we'll wait a bit for @mitchellh to respond, as you recommend.

@mitchellh
Copy link
Author

I don't have the repro case anymore to confirm, sorry. You can probably just safetly close this if you're confident it is fixed.

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 fixed-pls-verify fix is linked, bug author to confirm fix severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

7 participants