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

CLI: Return non-zero exit code when deployment fails in nomad run #11550

Merged
merged 4 commits into from
Dec 9, 2021

Conversation

lukas-w
Copy link
Contributor

@lukas-w lukas-w commented Nov 22, 2021

This PR changes the nomad run command (and other commands using the monitor.monitor function) to return a non-zero exit code when monitoring is enabled and deployment fails just like levant deploy does. This enables CI scripts to easily detect deployment failures. I chose return code 1 to match the existing documentation stating 0 on success, 2 on scheduling problems, and 1 for any other failures. A dedicated return code for deployment failures may makes sense though.

I also noticed and fixed a supposed typo from #10661 via 24fbb5e: The monitoring code was using DeploymentStatusDescriptionBlocked instead of DeploymentStatusBlocked.

Fixes #11082, fixes #10994.

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lukas-w! This is looking good! Once you've addressed the comments here, if you'd like to add a changelog item for the improvement that'd be great. If that's a confusing mess (understandable), let me know and I'll get that added.

website/content/docs/commands/job/run.mdx Outdated Show resolved Hide resolved
command/deployment_status.go Show resolved Hide resolved
@tgross tgross added this to Needs Triage in Nomad - Community Issues Triage via automation Dec 8, 2021
@tgross tgross self-assigned this Dec 8, 2021
@tgross tgross moved this from Needs Triage to In Progress in Nomad - Community Issues Triage Dec 8, 2021
Co-authored-by: Tim Gross <tgross@hashicorp.com>
@lukas-w
Copy link
Contributor Author

lukas-w commented Dec 9, 2021

Thanks for the review @tgross! I added a changelog entry via e78fd43 but included the release-note:improvement formatting. Is that just missing in the part of the page you linked? I couldn't find any other changelog entry without a type and if I omit it, the entry isn't included in make changelog's output.

@tgross
Copy link
Member

tgross commented Dec 9, 2021

LGTM. The changelog entry is perfect. Thanks @lukas-w! This will ship in the next planned patch release.

@tgross tgross merged commit bb1fc6e into hashicorp:main Dec 9, 2021
Nomad - Community Issues Triage automation moved this from In Progress to Done Dec 9, 2021
@tgross tgross added this to the 1.2.3 milestone Dec 9, 2021
@lukas-w lukas-w deleted the f-run-exit-code branch December 9, 2021 14:09
jrasell added a commit that referenced this pull request Feb 1, 2022
PR #11550 changed the job stop exit behaviour when monitoring the
deployment. When stopping a job, the deployment becomes cancelled
and therefore the CLI now exits with status code 1 as it see this
as an error.

This change adds a new utility e2e function that accounts for this
behaviour.
jrasell added a commit that referenced this pull request Feb 1, 2022
PR #11550 changed the job stop exit behaviour when monitoring the
deployment. When stopping a job, the deployment becomes cancelled
and therefore the CLI now exits with status code 1 as it see this
as an error.

This change adds a new utility e2e function that accounts for this
behaviour.
@github-actions
Copy link

github-actions bot commented Nov 7, 2022

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
2 participants