hashicorp / hashicorp/nomad

Nomad CLI Monitor Dispatched Jobs

Open
#11,601 6 comments 30 reactions 1 assignee Claimed by @Juanadelacuesta View on GitHub
hcc/jira stage/accepted theme/batch theme/cli type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Proposal

Since the Nomad CLI supports monitoring deployments with `nomad job run`, it would be great to see similar behavior with `nomad job dispatch`.

Ideally it would dispatch the job and poll the dispatched job while it is running, and then exit 0/non-zero based on the exit status of the job (maybe some consideration with idempotency tokens needed).

### Use-cases

Use case is mostly around a CI environment where we use dispatched jobs to prepare an environment, seed a database, etc.

Being able to shell out to the Nomad CLI rather than custom scripting with the Nomad API would be great.

### Attempted Solutions

Current solution is pretty clunky, unless there's a better way to do it.

- Dispatch a parameterized job
- Get the dispatched job ID from the previous command
- Poll the Nomad API until the dispatched job is dead
- Check the latest alloc of the dispatched job to see if it completed successfully or failed.
- `/v1/job/` will only say "dead" without indication of success/failure. Gets a bit tricky when the dispatched job has rescheduling, lost nodes, etc. so logic gets a little dicey.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.