refactor(scheduler): delegate effective-request accounting to k8s.io/component-helpers - #2036
Merged
gshaibi merged 3 commits intoAug 9, 2026
Conversation
…helpers Replaces hand-rolled KEP-1287 aggregation with upstream resource.AggregateContainerRequests(UseStatusResources: true). - delete effective_requests.go entirely (3 funcs -> upstream) - collapse getPodResourceWithoutInitContainers + initContainerEffects into a single upstream call - webhook uses resource.IsPodResizeInfeasible instead of a local copy - retarget effective-request tests at the public aggregation path KNOWN FAILURE: upstream IsPodResizeInfeasible does not check condition.Status == True, so a stale Infeasible condition with Status=False is treated as infeasible. Signed-off-by: gshaibi <gshaibi@nvidia.com>
Signed-off-by: gshaibi <gshaibi@nvidia.com>
…ion test Upstream keys off Reason alone and ignores condition.Status, so the Status==True guard added in #2021 does not survive the move to k8s.io/component-helpers. Accepts upstream semantics and pins the difference so a future upstream tightening surfaces as a test failure rather than a silent change. Signed-off-by: gshaibi <gshaibi@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Prototype / discussion PR — targets the #2021 branch, not
main.Replaces the hand-rolled KEP-1287 effective-request accounting introduced in #2021 with the upstream implementation in
k8s.io/component-helpers/resource, already a direct dependency (go.mod, v0.35.4).Upstream's
determineEffectiveRequestsis semantically identical to what #2021 implements:and
AggregateContainerRequestsalready implements the full sidecar formula (KEP-753) — the restartable-init running sum and the init-phase peak — with effective requests applied.1. Scheduler side
effective_requests.go(whole file, 3 funcs)getPodResourceWithoutInitContainersAggregateContainerRequestsinitContainerEffectslogIfErr(became dead)sidecarSumandinitPhasePeakwere never consumed separately —getPodResourceRequestrecombined them immediately withAdd+SetMaxResource, which is exactly how upstream folds them internally. So the split served no purpose.2. Admission side
podResizeDelta+accumulateDeltaSums(~130 lines) collapse to three aggregate calls:The
UseStatusResourcesflag is the spec/effective distinction. Both the scheduler and the webhook now call the same function, so the invariant "the delta baseline equals what the queue charges" holds by construction rather than by parallel hand-written logic. All three review findings on #2021'spodResizeDeltacame from exactly that drift.The webhook's duplicated
isPodResizeInfeasibleis also gone, in favour ofresource.IsPodResizeInfeasible.This also fixes a latent bug in #2021
New test
TestPodResizeValidator_InitPeakDominates_NoDeltacovers a pod whose queue charge is dominated by the init-phase peak rather than steady state:max(steady, initPeak)=max(1,10)= 10 before,max(2,10)= 10 after — unchangedOn the #2021 branch this test fails:
The per-container sum never sees the
max(), so it invents a 1-CPU delta and rejects a resize that costs the queue nothing. With upstream aggregates the delta is empty and the resize is admitted.If this refactor is not taken, that test is worth cherry-picking to #2021 as a known-failing case — the bug exists there today.
Semantic change: the
StatusguardUpstream keys off
Reasonalone:#2021 added a
Status == ConditionTrueguard, which does not survive the move. Decision taken: accept upstream semantics. The kubelet deletes the condition rather than setting itFalse, so the case is not expected to be reachable.Rather than dropping the coverage,
TestIsPodResizeInfeasiblenow pins upstream's behaviour as a characterization test — if upstream ever tightens the check, it fails and the change surfaces instead of passing silently.Related Issues
Follow-up to #2021. Not for independent merge.
Checklist
make changelog(or applied theskip-changeloglabel)Refactor; the one semantic change is documented above. Labelled
skip-changelog.Breaking Changes
None intended. The
Statusguard difference is the only behavioural change, described above.Additional Notes
Test results: full suite green.
TestGetPodResourceRequestpasses unchanged — covers init containers, sidecars and overhead end-to-end, and confirms theRequirementsFromResourceListround-tripeffective_requests_test.gowas retargeted from the deleted unexported helpers onto the public aggregation path, so it guards against drift if the dependency is bumped.TestGetPodResourceWithoutInitContainerswas deleted — it tested a decomposition that no longer exists and is subsumed byTestGetPodResourceRequest.Not verified: the GPU round-trip is exercised only via CPU/memory cases. If fraction-GPU pods route through
getPodResourceRequestin a way those cases don't cover, that needs a targeted check before this merges anywhere.