Preempted alloc during deploy guarantees failed deployment
- Dominant language
- Go
- Stars
- 17k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 105
Description
### Nomad version
Output from `nomad version`
`Nomad v0.10.4 (f750636ca68e17dcd2445c1ab9c5a34f9ac69345)`
### Operating system and Environment details
Amazon Linux 2
### Issue
Hello, whenever a deploy is running a canary/bluegreen deploy, if an allocation is pre-empted before it reaches the healthy count, the entire deployment is doomed to fail by progress_deadline.
This is because the deployment will properly count the canary but when it pre-empts it, it does not replace it. So the final count would be N-1 running even though the deployment thinks all N are running. The deployment waits for that pre-empted allocation to get healthy, which of course, it never will since its no longer running, until the progress_deadline hits, then the red bar comes up and all the progress is rolled back.
This is very difficult to reproduce since I'm not too sure what causes a pre-empt action. But we do see it more often than not and is extremely problematic when it does happen.
Here is a deployment where that happened:

Here is the allocation that was redacted:

This may be related to an [earlier issue](https://github.com/hashicorp/nomad/issues/6407) I posted regarding deployment state falling out of sync that @tgross worked on a bit. Is it related? Should the pre-empted allocation have been detected and replaced by the deployment?
Thanks.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how Nomad handles deployments, canary or blue/green allocations, and allocation preemption, using the reported deployment and allocation screenshots as context. Reproduce or test the preemption case and verify that a preempted allocation is detected and replaced rather than leaving the deployment waiting until progress_deadline and rolling back.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100