Skip to content

scheduler: Remove generated deployment when plan refreshes state. - #28307

Merged
jrasell merged 2 commits into
mainfrom
b-sched-remove-deployment-state-refresh
Jul 28, 2026
Merged

jrasell merged 2 commits into
mainfrom
b-sched-remove-deployment-state-refresh

Conversation

@jrasell

@jrasell jrasell commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

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 If this PR changes user-facing behavior, please generate and add a
    changelog entry using the make cl command.
  • Testing Please add tests to cover any new functionality or to demonstrate bug fixes and
    ensure regressions will be caught.
  • Documentation If the change impacts user-facing functionality such as the CLI, API, UI,
    and job configuration, please update the Nomad product documentation, which is stored in the
    web-unified-docs repo. Refer to the web-unified-docs contributor 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-docs team in this PR.
  • LLM Usage If an LLM was used to generate any code, please ensure and confirm you have read
    and followed the AI usage guide.

Reviewer Checklist

  • Backport Labels Please add the correct backport labels as described by the internal
    backporting document.
  • Commit Type Ensure the correct merge method is selected which should be "squash and merge"
    in the majority of situations. The main exceptions are long-lived feature branches or merges where
    history should be preserved.
  • Enterprise PRs If this is an enterprise only PR, please add any required changelog entry
    within the public repository.

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.
@jrasell jrasell self-assigned this Jul 28, 2026
@jrasell jrasell added backport/ent/1.10.x+ent backport to 1.10.x+ent release line backport/ent/1.11.x+ent backport to 1.11.x+ent release line backport/2.0.x backport to 2.0.x release line labels Jul 28, 2026
@jrasell
jrasell marked this pull request as ready for review July 28, 2026 08:42
@jrasell
jrasell requested review from a team as code owners July 28, 2026 08:42

@tgross tgross left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tgross

tgross commented Jul 28, 2026

Copy link
Copy Markdown
Member

LOL, and then I opened your other PR #28309 and see you addressed that there.

@tgross tgross left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jrasell
jrasell merged commit 1f26000 into main Jul 28, 2026
71 of 73 checks passed
@jrasell
jrasell deleted the b-sched-remove-deployment-state-refresh branch July 28, 2026 14:09
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

1 active deployment
Preview — a0176a30 Deployed Jul 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/ent/1.10.x+ent backport to 1.10.x+ent release line backport/ent/1.11.x+ent backport to 1.11.x+ent release line backport/2.0.x backport to 2.0.x release line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants