Skip to content

fix(scheduler): set LimitSet in the remaining ResourceQuota test fixtures - #2432

Merged
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
adity1raut:fix/webhook-quota-limitset
Aug 7, 2026
Merged

fix(scheduler): set LimitSet in the remaining ResourceQuota test fixtures#2432
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
adity1raut:fix/webhook-quota-limitset

Conversation

@adity1raut

@adity1raut adity1raut commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What this fixes

#2313 added a LimitSet flag to device.Quota and switched FitQuota to gate on LimitSet instead of Limit != 0, so an explicitly configured zero limit is honored as a hard block. That PR updated TestFitResourceQuota's fixture to set LimitSet: true to match, but three sibling tests in the same file also build device.Quota values directly and were missed:

  • TestFitResourceQuotaNonNvidia
  • TestFitResourceQuotaCountsEveryDevice
  • TestFitResourceQuotaAscendMemoryFactor

Their fixtures default to LimitSet: false, so FitQuota now treats their configured limits as "not set" and admits every pod — the denial assertions in all three tests currently fail on master:

--- FAIL: TestFitResourceQuotaNonNvidia
    webhook_test.go:561: fitResourceQuota() = true, want false
--- FAIL: TestFitResourceQuotaCountsEveryDevice
    webhook_test.go:602: fitResourceQuota() = true, want false: two devices should each count against the quota
--- FAIL: TestFitResourceQuotaAscendMemoryFactor
    webhook_test.go:683: fitResourceQuota() = true, want false: the request exceeds the scaled limit

I ran into this while rebasing an unrelated PR (#2174) onto current master — make test fails on a clean master checkout with no other changes involved.

Fix

Set LimitSet: true on the five affected fixture entries across the three tests, matching what AddQuota produces and mirroring the fix already applied to TestFitResourceQuota.

Testing

  • go test ./pkg/scheduler/... -run TestFitResourceQuota -race -count=1 passes (all four TestFitResourceQuota* tests).
  • go test ./... scoped to pkg/scheduler/... passes.
  • Test-fixture-only change, no production code touched.

AI disclosure

This PR was written primarily by Claude Code (Anthropic), used to investigate the codebase, identify the bug, implement the fix, and verify it. I reviewed and verified the change before submitting.

Summary by CodeRabbit

  • Tests
    • Updated quota test scenarios to explicitly mark configured limits as enforced.
    • Improved coverage for non-NVIDIA, multi-device, and Ascend quota behavior.

Project-HAMi#2313 added a LimitSet flag that FitQuota now gates on instead of
Limit != 0, and updated TestFitResourceQuota's fixture accordingly,
but missed three sibling tests in the same file that also build
device.Quota directly: TestFitResourceQuotaNonNvidia,
TestFitResourceQuotaCountsEveryDevice, and
TestFitResourceQuotaAscendMemoryFactor. Their fixtures defaulted to
LimitSet: false, so FitQuota treated the configured limits as unset
and admitted every pod, failing the denial assertions in all three
tests on current master.

Set LimitSet: true on the five affected fixture entries to match what
AddQuota produces, mirroring the fix already applied to
TestFitResourceQuota.

Signed-off-by: Aditya Raut <araut7798@gmail.com>
@hami-robot
hami-robot Bot requested review from chaunceyjiang and wawa0210 August 7, 2026 02:40
@github-actions github-actions Bot added the kind/bug Something isn't working label Aug 7, 2026
@hami-robot hami-robot Bot added the size/S label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 141f5a22-b374-4526-b9d3-d13c68ac1c31

📥 Commits

Reviewing files that changed from the base of the PR and between 87d9795 and 606b4ec.

📒 Files selected for processing (1)
  • pkg/scheduler/webhook_test.go

📝 Walkthrough

Walkthrough

The webhook test fixtures now set LimitSet: true for configured Cambricon MLU, Hygon DCU, multi-MLU, and Ascend quotas.

Changes

Quota fixture enforcement

Layer / File(s) Summary
Mark device quotas as enforced
pkg/scheduler/webhook_test.go
Quota fixtures for Cambricon MLU, Hygon DCU, multi-MLU, and Ascend now set LimitSet: true.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

Suggested reviewers: dsfans2014

Poem

A rabbit checked each quota line,
“LimitSet” makes the tests align.
MLU, DCU, Ascend too,
Now enforcement comes through.
Hop, hop—the fixtures are true!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the scheduler test fixture change and the addition of LimitSet.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from DSFans2014 August 7, 2026 02:40
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 63.39% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@archlitchi archlitchi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@hami-robot

hami-robot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adity1raut, archlitchi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hami-robot hami-robot Bot added the approved label Aug 7, 2026
@hami-robot
hami-robot Bot merged commit 1540297 into Project-HAMi:master Aug 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants