Skip to content

fix(webhook): count the resource to fit quota in webhook when reqnum > 1 - #2001

Merged
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
DSFans2014:fix/webhook-quota
Jul 6, 2026
Merged

fix(webhook): count the resource to fit quota in webhook when reqnum > 1#2001
hami-robot[bot] merged 1 commit into
Project-HAMi:masterfrom
DSFans2014:fix/webhook-quota

Conversation

@DSFans2014

@DSFans2014 DSFans2014 commented Jul 3, 2026

Copy link
Copy Markdown
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

count the resource to fit quota in webhook if reqnum > 1

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Summary by CodeRabbit

  • Bug Fixes
    • Improved GPU quota checks so memory and CPU requests are correctly counted when a workload requests multiple GPUs.
    • Multi-GPU jobs with matching memory requests are now more likely to pass resource fit validation as expected.
    • Added coverage for a multi-GPU scheduling scenario to help prevent regressions.

Signed-off-by: james <open4pd@4paradigm.com>
@hami-robot hami-robot Bot added kind/bug Something isn't working dco-signoff: yes labels Jul 3, 2026
@hami-robot
hami-robot Bot requested review from chaunceyjiang and wawa0210 July 3, 2026 02:44
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The quota-fit logic in fitResourceQuota was changed to scale accumulated memory and core requests by the requested GPU count instead of only accumulating when count equals 1. A new test case validates multi-GPU requests fitting within quota.

Changes

Multi-GPU Quota Fix

Layer / File(s) Summary
Scaled quota accumulation and test coverage
pkg/scheduler/webhook.go, pkg/scheduler/webhook_test.go
fitResourceQuota now multiplies memory/core requests by the count instead of restricting accumulation to count==1; a new test case verifies a pod requesting 2 GPUs with 400 GPUMem fits within quota.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A hop, a scale, a count times two,
Quotas now compute what's true.
No more stuck at "req == 1",
Multi-GPU math is finally done!
🐇✨ Thump-thump, tests all run green.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main bug fix: webhook quota fitting now counts requested resources when reqnum > 1.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@DSFans2014 DSFans2014 changed the title fix(webhook): count the resource to fit quota in webhook if reqnum > 1 fix(webhook): count the resource to fit quota in webhook when reqnum > 1 Jul 3, 2026

@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 updates the resource quota fitting logic in the scheduler webhook to correctly scale memory and core requirements when multiple resources (such as GPUs) are requested, rather than assuming a single resource request. A corresponding test case has been added to verify this behavior. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 59.09% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/scheduler/webhook.go 76.19% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mesutoezdil

Copy link
Copy Markdown
Contributor

/lgtm

@mesutoezdil

mesutoezdil commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

the old code assumed reqnum was always 1 — so if a container requested 2 GPUs with 400MB memory each, it would only count 400MB against quota instead of 800MB. multiplying by req fixes that.

same issue existed for cores. good catch.

Why are you rewriting the existing PR definition and code as a comment? Is this some kind of motivational support?

@DSFans2014

Copy link
Copy Markdown
Member Author

the old code assumed reqnum was always 1 — so if a container requested 2 GPUs with 400MB memory each, it would only count 400MB against quota instead of 800MB. multiplying by req fixes that.
same issue existed for cores. good catch.

Why are you rewriting the existing PR definition and code as a comment? Is this some kind of motivational support?

@mesutoezdil Where does your quoted content come from?

@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 Jul 6, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [DSFans2014,archlitchi]

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 merged commit 1c41c74 into Project-HAMi:master Jul 6, 2026
17 checks passed
@mesutoezdil

mesutoezdil commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

the old code assumed reqnum was always 1 — so if a container requested 2 GPUs with 400MB memory each, it would only count 400MB against quota instead of 800MB. multiplying by req fixes that.
same issue existed for cores. good catch.

Why are you rewriting the existing PR definition and code as a comment? Is this some kind of motivational support?

@mesutoezdil Where does your quoted content come from?

As usual, someone had pasted a nonsensical LLM output; after i’d replied, he deleted the post.

We are working on it: #1998 (comment)

Answers should be written by human.

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.

3 participants