Skip to content

fix(atlas): Preserve preferred affinity fallback during resize - #316

Merged
tanmoysrt merged 6 commits into
frappe:developfrom
ryzenate1:fix/preferred-resize-fallback
Oct 4, 2026
Merged

tanmoysrt merged 6 commits into
frappe:developfrom
ryzenate1:fix/preferred-resize-fallback

Conversation

@ryzenate1

Copy link
Copy Markdown
Contributor

Issue

A moving resize with placement rules can skip the Preferred affinity fallback.

When the current Metal Server cannot fit the resize delta and no affinity-matching destination can fit the target shape, a nonmatching server with enough capacity should remain available under Preferred.

The affinity filter currently returns as soon as a resize has a current host, before reading the Affinity Matching setting. This removes the nonmatching fallback and the resize ends in OutOfCapacity.

For example:

  • A matches the placement rule but cannot fit the target.
  • B does not match the rule but can fit the target.
  • C is the current host but cannot fit the resize delta.
  • Affinity Matching is Preferred.

Before this change, placement keeps A and C, drops B, and returns OutOfCapacity.

Summary

Evaluate the affinity matching mode when none of the retained current/matching hosts has room.

Preferred can then fall back to the full host set, while Enforced continues to keep the current/matching set and never uses a nonmatching destination.

Why

A resize always has a current host. The previous early return treated the existence of that host as sufficient reason to keep the affinity-filtered snapshot, even when the current host could not accommodate the resize.

That made the Preferred branch unreachable for this moving-resize case.

This keeps the current host in the candidate set for in-place resize, but only commits to the affinity-filtered set when one of those candidates actually has room.

What changed

  • Let a Preferred moving resize fall back when neither the current host nor an affinity-matching host has capacity.
  • Preserve the restricted candidate set for Enforced.
  • Add a regression test covering a full current host, a full matching host, and a fitting nonmatching fallback.

This preserves the Preferred fallback semantics introduced with the affinity placement behavior in #310 for moving resizes.

Validation

  • Regression test fails on the pristine implementation (Retained hosts: ['a', 'c']; affinity setting reads: 0) and passes with this change.
  • Verified current-host delta-fit still selects the current host.
  • Verified a fitting affinity-matching destination is still preferred over a nonmatching host.
  • Verified Enforced never falls back to the nonmatching host.
  • Verified Preferred VM creation without a current host still falls back as before.
  • Verified contention still returns PlacementBusy instead of relaxing affinity.
  • Placement context suite: 48 tests run, 0 failures, 8 pre-existing DB-integration errors unchanged from baseline; all 4 key ATLAS-C1 controls GREEN.
  • Reproduced on real AWS/Metal infrastructure with an isolated temporary Atlas site and three independent KVM Metal guests with real metald sync and real capacity reports: pristine placement returned OutOfCapacity; patched placement selected the nonmatching fallback. No production site or customer workload was modified.

A moving resize always has a current host, so affinity filtering returned before reading the Preferred matching setting. When neither the current host nor a matching destination had room, this removed a fitting nonmatching fallback and caused OutOfCapacity. Evaluate the affinity matching mode when the retained current/matching hosts have no capacity, while preserving Enforced behavior.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 4, 2026 10:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Reuse the affinity test helper, and drop the comment that the docstring
now covers.
Copilot AI balanced review requested due to automatic review settings October 4, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 4, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@tanmoysrt

tanmoysrt commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Try to keep comments, docstrings smaller and easy to understand. Trimmed it for now.

@tanmoysrt
tanmoysrt enabled auto-merge October 4, 2026 13:58
@tanmoysrt
tanmoysrt merged commit fe9e2cf into frappe:develop Oct 4, 2026
9 checks passed
@ryzenate1

Copy link
Copy Markdown
Contributor Author

Thanks, noted. I’ll keep comments and docstrings concise and limited to non obvious behavior going forward 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants