Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating affinity in job is destructive #25070

Closed
pawelbeza opened this issue Feb 10, 2025 · 2 comments · Fixed by #25109
Closed

Updating affinity in job is destructive #25070

pawelbeza opened this issue Feb 10, 2025 · 2 comments · Fixed by #25109

Comments

@pawelbeza
Copy link
Contributor

pawelbeza commented Feb 10, 2025

Hi there 👋

not sure if that's expected behavior but changing Affinity is destructive and it'causig in-place update. It's a weird behavior considering that there is no update on Constraint change

case "Service", "Constraint":

Would you consider changing this behavior and skipping in-place update when affinity is changed? I could help with the PR

@tgross
Copy link
Member

tgross commented Feb 10, 2025

Hi @pawelbeza!

Just to refine your bug report a bit, what you're seeing is a destructive update. An in-place update is one where we update the definition of the allocation without touching any running tasks (any easy example of this might be incrementing the group.count). An affinity, spread, or constraint update are all supposed to be in-place updates, because we update the definition of the job without replacing any of the allocations. This logic was make explicit in #6703 (shipped in Nomad 0.10.2).

But, as you note, it's not behaving as expected! Here's an example of what that looks like with a job update that only updates an affinity block:

$ nomad job plan example.nomad.hcl
+/- Job: "example"
+/- Task Group: "group" (1 create/destroy update)
  + Affinity {
    + LTarget: "${attr.os.name}"
    + Operand: "="
    + RTarget: "ubuntu"
    + Weight:  "75"
    }
  - Affinity {
    - LTarget: "${attr.os.name}"
    - Operand: "="
    - RTarget: "ubuntu"
    - Weight:  "50"
    }
    Task: "task"
...

And if I run that, I get a destructive update with a new allocation, which isn't right.

Would you consider changing this behavior and skipping in-place update when affinity is changed? I could help with the PR

I'd be happy to review a PR! We should fix this for spread blocks too while we're here.

@pawelbeza
Copy link
Contributor Author

pawelbeza commented Feb 13, 2025

Thanks for clarifying the issue. I may have misused the term in-place update. You can find the fix here #25109 :)

@tgross tgross moved this from Triaging to In Progress in Nomad - Community Issues Triage Feb 13, 2025
@tgross tgross added this to the 1.10.0 milestone Feb 14, 2025
@tgross tgross closed this as completed in 43885f6 Feb 14, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Nomad - Community Issues Triage Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants