fix(quota): correct breaker halfOpen comment and add concurrent test - #898
fix(quota): correct breaker halfOpen comment and add concurrent test#898vishalmore90 wants to merge 1 commit into
Conversation
Signed-off-by: vishal <httpsvishal07@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #898 +/- ##
==========================================
+ Coverage 82.31% 82.40% +0.08%
==========================================
Files 244 254 +10
Lines 19782 21457 +1675
==========================================
+ Hits 16284 17681 +1397
- Misses 2888 3079 +191
- Partials 610 697 +87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Ⅰ. Describe what this PR does
This PR corrects a factually wrong comment in
BreakerBackend.beforeCall()that misrepresents the state machine, and introduces a missing concurrent unit test to cover this specific race condition.Context:
In
pkg/sandbox-manager/quota/breaker.goline 118, the comment described thehalfOpen == truestate as:// 3. the probe acquire failed, breaker stays open.This is incorrect. When
beforeCall()executes thehalfOpen == truebranch, it means a probe acquire is currently in-flight in another goroutine, not that it has failed. The actual failure path is handled asynchronously insideafterCall(), which re-opens the breaker.Changes:
breaker.goto accurately describe the fail-fast thundering herd protection.concurrent caller during in-flight probe gets ErrBackendUnavailable without touching innertobreaker_test.go. This test uses a newblockingBackendto intentionally pause the probe mid-flight and ensure that a concurrent caller correctly fails-fast withErrBackendUnavailablewithout incrementing the inner backend call count.Ⅱ. Does this pull request fix one issue?
fixes #897
Ⅲ. Describe how to verify it
breaker.goto confirm the comment change aligns with theafterCall()state transitions.go test -v -run TestBreaker ./pkg/sandbox-manager/quota