Skip to content

[pull] master from Project-HAMi:master#216

Merged
pull[bot] merged 1 commit into
herb-duan:masterfrom
Project-HAMi:master
May 22, 2026
Merged

[pull] master from Project-HAMi:master#216
pull[bot] merged 1 commit into
herb-duan:masterfrom
Project-HAMi:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented May 22, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

#1880)

* fix(quota): clamp Used to zero in RmUsage to prevent negative tracking

Quota.Used could go negative when RmUsage was called for a pod that
had no matching AddUsage entry. FitQuota checks Used+alloc>Limit so
a negative Used value allows scheduling beyond the namespace quota.

PR 1400 added a second RmUsage call site in the terminated-pod path
of onAddPod. In edge cases both onAddPod and onDelPod can attempt to
remove the same pod from the quota, making the underflow reachable.

Guard against this by clamping Used to zero on subtraction.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>

* fix(quota): single map lookup and nil guard in RmUsage

Replace the double lookup with a single one and add a nil check
before dereferencing the Quota pointer.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>

* fix(quota): prevent double RmUsage via atomic TakeAndDeletePod

Add TakeAndDeletePod to PodManager: get and delete in a single lock
acquisition so only one caller wins. Use it in both onAddPod (terminated
path) and onDelPod to guarantee RmUsage is called exactly once per pod.

Revert the max(0,...) clamp in RmUsage since the double-call is now
prevented at the source.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>

* style: fix gofmt formatting in quota_test.go

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>

---------

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@pull pull Bot locked and limited conversation to collaborators May 22, 2026
@pull pull Bot added the ⤵️ pull label May 22, 2026
@pull pull Bot merged commit bf628a1 into herb-duan:master May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant