[pull] master from Project-HAMi:master#216
Merged
Merged
Conversation
#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>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
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 : )