hashicorp / hashicorp/nomad

Tagging the latest version of a "Stopped" job results in the job.Status going from "dead" to "running"

Open
#24,982 0 comments 0 reactions 0 assignees View on GitHub
hcc/jira theme/golden-versions type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

(and additionally, upon starting the job again, the version tag is duplicated)

![Image](https://github.com/user-attachments/assets/4fe626f9-c408-40b0-b89b-0f52036f41e5)
^--- all allocs terminal (complete), job status "running", job.Stopped = true

I noticed a situation where tagging the latest version of a job, if it is currently set to Stopped (having been manually stopped via DELETE to the job endpoint or otherwise), its status in the UI would change from "Stopped" to "Failed". I dug in and the "Stopped" code path only gets hit if the job.Status is set to "dead", and in this case it was coming back as "running" from both the /statuses endpoint and the `nomad job status` command.

### Reproduction:
- Run a service job and allow it to get in a healthy state
- Stop the job (by clicking "Stop Job" in the UI or hitting the /job/$jobid endpoint with DELETE)
- Check the job's status: it should be `dead`
- Observe that the job now has two versions (version 1's only change should be that `Stop` has gone from `false` to `true`)
- Tag the latest (stopped) version via the web UI
- BUG: Check the job's status: it is now `running`
- In the UI, because the status is now `running`, click "Start Job"
- Look again at the versions: There should now be 3.
- BUG: both the latest and second-latest versions should have the tag you applied earli.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the stop, tag, and restart sequence, then trace the /statuses endpoint, the nomad job status command, and the web UI's job tagging and version creation paths. Done means a stopped job remains dead after tagging and restarting does not duplicate the applied version tag.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.