-
Notifications
You must be signed in to change notification settings - Fork 224
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
bolt --target localhost munges puppet's non-zero exit codes #1846
Labels
Bug
Bug reports and fixes.
Comments
sheenaajay
changed the title
bolt gem throws error on apply_manifest(pp, expect_changes: true) / (catch_failures: true) for win32
bolt gem throws error different error code for run a command for win32
May 26, 2020
DavidS
changed the title
bolt gem throws error different error code for run a command for win32
bolt --target localhost munges non-zero exit codes
May 27, 2020
DavidS
changed the title
bolt --target localhost munges non-zero exit codes
bolt --target localhost munges puppet's non-zero exit codes
May 27, 2020
Updated initial description with easier repro without extra module and additional screenshots. |
Sorry fatfinger 😅 |
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands through Bolt, and not tasks or scripts. This modifies powershell's `run_command` function to always wrap the command in a file and execute the file, which will consistently return the correct exit code without attempting to modify the command itself. Closes puppetlabs#1846 * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands through Bolt, and not tasks or scripts. This modifies powershell's `run_command` function to always wrap the command in a file and execute the file, which will consistently return the correct exit code without attempting to modify the command itself. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands through Bolt, and not tasks or scripts. This modifies powershell's `run_command` to append 'exit $LASTEXITCODE', which will correctly exit the powershell command with the exit code of the command it ran. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This modifies the local transport to append `; exit $LASTEXITCODE` to commands run on Windows, which will correctly return the exit code from the command run instead of changing it to 1. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 9, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 10, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 10, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 10, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
lucywyman
added a commit
to lucywyman/bolt
that referenced
this issue
Jun 10, 2020
Powershell will [exit 1](PowerShell/PowerShell#11461) whenever the $LASTEXITCODE is greater than 0, regardless of what the code is, whenever running a bare command. Powershell exits with the correct exit code when executing files, or when `exit $LASTEXITCODE` is appended to the command being run (as in the [execute_process snippet](https://github.com/puppetlabs/bolt/blob/0d44ce739d4dafcb6d27abd894e230894fdd50e0/lib/bolt/shell/powershell/snippets.rb#L19), meaning this is only an issue when running commands using the local transport through Bolt. This appends a Powershell snippet to exit with the correct exit code to commands running on Windows using the local transport. Closes puppetlabs#1846 !bug * **Return correct exit code when running commands in powershell** ([1846](puppetlabs#1846)) Bolt will now display the correct exit code when running commands in powershell that exit with code > 1.
nicklewis
added a commit
that referenced
this issue
Jun 11, 2020
(GH-1846) Exit with correct exit code when running on Windows with local transport
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the Bug
bolt command run --targets localhost 'puppet ...'
does not correctly report exit codes that are not 0 or 1:Expected Behavior
Notably the command in the screenshot above is returning exit code 2 and bolt should have correctly reported this.
Steps to Reproduce
and it throws the following error
Note how bolt reports exitcode 1, but the same command executed through the powershell has the expected
$LASTEXITCODE
of 2 ("something changed").Environment
Additional Context
In our testing we could not reproduce the behaviour with bolt 2.6.0. This is currently impacting our testing and we're rolling temporarily back to that version to unblock our pipelines.
Please let us know if you need more information. Thanks a lot for all the help.
The text was updated successfully, but these errors were encountered: