Skip to content

[API]: Add historical node replacement scheduling for RoleSet - #2628

Merged
varungup90 merged 3 commits into
vllm-project:mainfrom
googs1025:issue-2561-cache-aware-rescheduling
Aug 31, 2026
Merged

varungup90 merged 3 commits into
vllm-project:mainfrom
googs1025:issue-2561-cache-aware-rescheduling

Conversation

@googs1025

@googs1025 googs1025 commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add RoleSet API spec.roles[].updateStrategy.replacementScheduling.historicalNode.mode=Preferred to let replacement Pods prefer nodes that previously ran the same role workload.
  • Persist controller-owned historical node bindings on the RoleSet annotation orchestration.aibrix.ai/historical-node-bindings, so remembered nodes survive controller restarts.
  • Inject preferred kubernetes.io/hostname node affinity for replacement Pods while preserving existing hard scheduling constraints.
  • Add sample YAML and docs for the new field, behavior, and scheduling caveats.

Stateful vs Stateless behavior

  • Stateful roles are supported with slot-level history. Stateful roles have stable replica identity, so worker/0 remains the same logical replica after deletion and recreation. The controller records bindings such as worker/0 -> node-a, and a replacement Pod for that slot prefers the remembered node.
  • Stateless roles are supported with role-level recent-node history. Stateless roles do not have stable per-replica identity, so a replacement Pod cannot safely inherit one exact old Pod's slot binding. The controller records recent nodes for the whole role, such as worker -> [node-a, node-b], and rollout replacement Pods prefer those nodes.
  • Stateless scale-up is not treated as replacement and does not inject historical-node affinity because the new Pod adds capacity instead of replacing a remembered logical replica.

CRD/API impact

  • Updates RoleSet with spec.roles[].updateStrategy.replacementScheduling.historicalNode.
  • Updates embedded RoleSet schemas in StormService CRDs and Helm CRDs because StormService templates carry RoleSet role specs.
  • Adds generated deepcopy and applyconfiguration support for RoleReplacementScheduling and HistoricalNodeSchedulingPolicy.

When historical nodes are used

  • Stateful recreate/rollout replacement: use the remembered node for the same replica slot.
  • Stateful empty-slot creation: use an existing slot binding when the RoleSet annotation already has history.
  • Stateless recreate/rollout replacement: use the role-level recent-node history.
  • Controller restart: history remains effective because it is stored on the RoleSet annotation.
  • Injection is skipped when the Pod template already has required node affinity, when required hostname topology policy may conflict, or when podGroupSize > 1; the controller logs the skip reason.

Fixes #2561

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces historical-node replacement scheduling for RoleSets, allowing replacement Pods to prefer nodes that previously ran the same role workload. It adds the necessary API fields, CRD updates, controller logic to track and persist node bindings via annotations, and comprehensive tests. The review feedback highlights two critical issues: first, the non-deterministic ordering of retrieved pods can shuffle bindings and trigger infinite reconciliation loops, which should be resolved by sorting the pods deterministically; second, mutating the roleSet object in-place before patching is risky and should be performed on a deep copy to prevent state inconsistency on patch failures.

@googs1025
googs1025 force-pushed the issue-2561-cache-aware-rescheduling branch from 5761012 to 351c0fd Compare August 27, 2026 15:08
@googs1025
googs1025 requested a balanced review from Copilot August 27, 2026 15:17

Copilot AI left a comment

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.

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

@googs1025
googs1025 force-pushed the issue-2561-cache-aware-rescheduling branch 4 times, most recently from 031712f to 1282e8c Compare August 27, 2026 16:14
@googs1025
googs1025 force-pushed the issue-2561-cache-aware-rescheduling branch from 1282e8c to 66698b1 Compare August 27, 2026 16:21
@googs1025 googs1025 changed the title Add historical node replacement scheduling for RoleSet [API]: Add historical node replacement scheduling for RoleSet Aug 27, 2026
@googs1025
googs1025 force-pushed the issue-2561-cache-aware-rescheduling branch from 7a9680e to 18c29ae Compare August 27, 2026 16:37
@googs1025
googs1025 requested a balanced review from Copilot August 28, 2026 00:03

Copilot AI left a comment

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.

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

@googs1025

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@googs1025

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18c29aef71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +299 to +301
Key: v1.LabelHostname,
Operator: v1.NodeSelectorOpIn,
Values: nodeNames,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Match the recorded node by metadata.name

When a cluster's kubernetes.io/hostname label differs from the Node object's name, this preference never identifies the historical node: the stored values come from pod.Spec.NodeName, but they are compared against the hostname label. Replacement Pods therefore lose the advertised locality preference in such clusters; use a MatchFields requirement for metadata.name, or resolve and persist the node's hostname label value.

Useful? React with 👍 / 👎.

@varungup90

Copy link
Copy Markdown
Collaborator

Four findings, most severe first:

1.	Correctness bug (high impact) — pkg/controller/stormservice/rolesetoperations.go:152: in-place StormService rollouts overwrite the RoleSet’s entire Annotations map, wiping the historical-node-bindings annotation. Since the shipped sample config uses maxSurge=0/maxUnavailable=1, a slot mid-rollout has no live pod left to rebuild the binding from — the feature loses its memory in its own headline use case, and there’s no test coverage for this interaction.
2.	Correctness/robustness — pkg/controller/roleset/historical_node.go:297: ReplicaSlots (per-slot stateful bindings) has no cap, unlike Roles (capped at 8). Long-lived stateful roles can grow the annotation unboundedly toward the K8s annotation size limit, after which patches silently fail (log-only, no status signal).
3.	Minor/dead code — historical_node.go:303: refreshHistoricalNodeBindingsFromPods always returns nil, so the caller’s if err != nil branch is unreachable — misleading for future maintainers.
4.	Minor efficiency — rolesyncer.go:820: the annotation is JSON-parsed for every role on every Scale/Rollout call before the per-role “is this feature even enabled” check runs, doing wasted parsing for roles that don’t use the feature.

@googs1025

googs1025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed the four findings in 39e137c:

  1. StormService updateRoleSet now preserves the controller-owned orchestration.aibrix.ai/historical-node-bindings annotation while refreshing revision annotations. Added TestUpdateRoleSet coverage for this.
  2. Historical bindings are pruned against the current role spec on refresh, so stale stateful replica slots and removed roles do not stay in the annotation after scale-down or role changes. Added TestRefreshHistoricalNodeBindingsPrunesStaleEntries.
  3. Removed the dead error return from refreshHistoricalNodeBindingsFromPods; parse errors are handled internally by rebuilding from visible Pods.
  4. historicalNodeBindingsForPodCreation now checks whether the role enables historical-node scheduling before parsing the annotation. Added coverage for disabled roles with invalid annotation data.

@varungup90
varungup90 merged commit 7a91d12 into vllm-project:main Aug 31, 2026
19 checks passed
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.

Discussion: Cache-aware rescheduling for recreated StormService/RoleSet pods

3 participants