Skip to content

Add preserve-resources flag#26841

Merged
allisonlarson merged 7 commits intomainfrom
f-add-preserve-resources
Oct 2, 2025
Merged

Add preserve-resources flag#26841
allisonlarson merged 7 commits intomainfrom
f-add-preserve-resources

Conversation

@allisonlarson
Copy link
Copy Markdown
Contributor

@allisonlarson allisonlarson commented Sep 25, 2025

Description

Adds a --preserve-resources flag when running a job to preserve the task resources when updating an existing job. In situations where the resources of a task were updated separately, like via nomad-autoscaler, the job can still be deployed and choose to keep those configurations.

Testing & Reproduction steps

Added unit tests, and tested flag manually by running the DAS autoscaler

Links

internal ref: https://hashicorp.atlassian.net/browse/NMD-870

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 website documentation to reflect this. Refer to
    the website README for docs guidelines. Please also consider whether the
    change requires notes within the upgrade 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.
  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

Copy link
Copy Markdown
Contributor

@aimeeu aimeeu left a comment

Choose a reason for hiding this comment

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

minor nit - thanks for updating the docs!

Comment thread website/content/commands/job/run.mdx Outdated
- `-preserve-counts`: If set, the existing task group counts will be preserved
when updating a job.

- `-preserve-resources`: If set, the existing task resources will be preserved
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `-preserve-resources`: If set, the existing task resources will be preserved
- `-preserve-resources`: If set, the existing task resources are preserved

change to present tense, and also to match other entries

@aimeeu aimeeu removed request for a team and RubenSandwich September 26, 2025 13:07
Comment thread .changelog/26841.txt Outdated
Comment thread nomad/job_endpoint_test.go Outdated
Comment thread nomad/job_endpoint.go Outdated
Comment thread website/content/commands/job/run.mdx Outdated
Comment thread nomad/fsm.go Outdated
Comment thread nomad/fsm.go Outdated
Comment thread nomad/fsm.go Outdated
Comment thread nomad/fsm.go Outdated
aimeeu
aimeeu previously approved these changes Sep 30, 2025
Copy link
Copy Markdown
Contributor

@aimeeu aimeeu left a comment

Choose a reason for hiding this comment

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

doc content look great - thank you!

Copy link
Copy Markdown
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM!

I think if we could do it over again we'd probably figure out a better way to split up the declarative job spec from the ephemeral job state, and stick the scaling counts in the job state. And that's informing the awkwardness of having to wrap the upsertJobImpl this way where we're pushing the request down to the state store. We could rewrite every caller of UpsertJob to take a request (similar to other methods) but that's hundreds and hundreds of new lines of test code where we're making up a request to contain the job and don't care about these flags. Not worth the added test complexity everywhere.

:shipit:

@allisonlarson allisonlarson merged commit e40164a into main Oct 2, 2025
42 checks passed
@allisonlarson allisonlarson deleted the f-add-preserve-resources branch October 2, 2025 20:57
@github-actions
Copy link
Copy Markdown

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants