Repository navigation
scheduler: Remove generated deployment when plan refreshes state. - #28307
Merged
Merged
Conversation
The plan apply worker can return an refreshed state if it believes the applier process should be retried on a newer state snapshot. This can occur because the quota is blocking the placement or if the follower submitting the plan has an FSM that is lagging behind the rest of the quorum. In this situation the plan apply might be retried, or it might have exhausted its retries and be rejected. If retries are exhausted, the scheduler will create a blocked eval and set the status details of the evaluation which includes the generated deployment ID. This deployment ID is then persisted to state even though no deployment has been created or itself persisted to state. If the plan and apply was driven by the CLI, this can result in the CLI attempting to monitor a deployment that does not exist. This change clears the in-memory scheduler deployment object when a state refresh triggers a plan applier retry. If the apply can be retried, this information will be repopulated. If the process has reached the maximum number of retries, this change means the eval no longer references a non-existent deployment.
tgross
reviewed
Jul 28, 2026
tgross
left a comment
Member
There was a problem hiding this comment.
This looks right, but there's something related about the if !fullCommit check below that seems odd to me. We check if newState != nil and return early, which implies that by the time we get to result.FullCommit that it is always nil, and then if we didn't get a full comit, we'll always take the error path. These two blocks and the comments around them don't seem to line up.
Member
|
LOL, and then I opened your other PR #28309 and see you addressed that there. |
7 tasks done
schmichael
pushed a commit
to vercel/nomad
that referenced
this pull request
Sep 25, 2026
…shicorp#28307) The plan apply worker can return an refreshed state if it believes the applier process should be retried on a newer state snapshot. This can occur because the quota is blocking the placement or if the follower submitting the plan has an FSM that is lagging behind the rest of the quorum. In this situation the plan apply might be retried, or it might have exhausted its retries and be rejected. If retries are exhausted, the scheduler will create a blocked eval and set the status details of the evaluation which includes the generated deployment ID. This deployment ID is then persisted to state even though no deployment has been created or itself persisted to state. If the plan and apply was driven by the CLI, this can result in the CLI attempting to monitor a deployment that does not exist. This change clears the in-memory scheduler deployment object when a state refresh triggers a plan applier retry. If the apply can be retried, this information will be repopulated. If the process has reached the maximum number of retries, this change means the eval no longer references a non-existent deployment.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plan apply worker can return an refreshed state if it believes the applier process should be retried on a newer state snapshot. This can occur because the quota is blocking the placement or if the follower submitting the plan has an FSM that is lagging behind the rest of the quorum. In this situation the plan apply might be retried, or it might have exhausted its retries and be rejected.
If retries are exhausted, the scheduler will create a blocked eval and set the status details of the evaluation which includes the generated deployment ID. This deployment ID is then persisted to state even though no deployment has been created or itself persisted to state. If the plan and apply was driven by the CLI, this can result in the CLI attempting to monitor a deployment that does not exist.
This change clears the in-memory scheduler deployment object when a state refresh triggers a plan applier retry. If the apply can be retried, this information will be repopulated. If the process has reached the maximum number of retries, this change means the eval no longer references a non-existent deployment.
Testing & Reproduction steps
It's tricky to test manually using CE only code and requires artificially slowing down a follower and ensuring this follower is submitting plans to the leader that will be rejected due to stale state. The linked enterprise PR can be used as a reference on how to manually test this using quota rejections. The unit test covers the scenario quite well.
Links
found while testing: https://github.com/hashicorp/nomad-enterprise/pull/4259
Contributor Checklist
changelog entry using the
make clcommand.ensure regressions will be caught.
and job configuration, please update the Nomad product documentation, which is stored in the
web-unified-docsrepo. Refer to theweb-unified-docscontributor guide for docs guidelines.Please also consider whether the change requires notes within the upgrade
guide. If you would like help with the docs, tag the
nomad-docsteam in this PR.and followed the AI usage guide.
Reviewer Checklist
backporting document.
in the majority of situations. The main exceptions are long-lived feature branches or merges where
history should be preserved.
within the public repository.