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

Nomad-pack plan has an exit code of 1 #224

Closed
azdim opened this issue Mar 16, 2022 · 2 comments · Fixed by #236
Closed

Nomad-pack plan has an exit code of 1 #224

azdim opened this issue Mar 16, 2022 · 2 comments · Fixed by #236

Comments

@azdim
Copy link

azdim commented Mar 16, 2022

Successful nomad-pack plan returns an exit code of 1. This issue was discovered when using a CI/CD pipeline within GitHub actions, although a continue-on-error: true prevents the pipeline from failing it is not a viable long term solution.

❯ nomadpack plan . -f ./nomad_vars.hcl
Job: "mark"
Task Group: "app" (1 create/destroy update, 1 in-place update)
  Task: "server"

» Scheduler dry-run:
- All tasks successfully allocated.
Plan succeeded

root in template_nomad_repo/packs/hello_world on  init 🏎💨  v1.1.5default took 2s
❯ echo $?
1
@angrycub
Copy link
Contributor

This is consistent with Nomad Job Plan in that the plan command returns a 1 error code in cases where an allocation will be created. A zero is only returned in cases where the plan doesn't result in any changes.

A workaround would be to wrap the call to nomad-pack plan in a shell script to consume exit code 1 and make it a 0, since you consider that a successful case. However, I can certainly see how this is not desirable in a CI pathway where you would be expecting allocations to be created.

If the plan command provided flags or env vars to let you set the exit codes for the three states that Plan uses exit code to signal, would that resolve your issue? There is a long term plan for a pack configuration file, which would reduce the number of flags and variables, but that feature is not near-term.

@resmo
Copy link

resmo commented Apr 9, 2022

I don't see an issue if plan uses an other exit code then 0 if something changes, this is quite useful to detect changes.

But we should think about using a code other then 1.

Probably worth thinking is to make it configurable e.g. nomad job plan -exit-code-on-change=2 with a default of 1 for backwards compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants