Skip to content

balancer: Make ExitIdle compulsory for Balancers #8367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

arjan-bal
Copy link
Contributor

@arjan-bal arjan-bal commented May 28, 2025

Fixes: #8345

RELEASE NOTES:

  • balancer: add ExitIdle method to Balancer. Earlier implementing this method was optional.

@arjan-bal arjan-bal added this to the 1.74 Release milestone May 28, 2025
@arjan-bal arjan-bal added the Type: API Change Breaking API changes (experimental APIs only!) label May 28, 2025
Copy link

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.34%. Comparing base (0c24af1) to head (a08fdcc).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
balancer/weightedroundrobin/balancer.go 0.00% 1 Missing ⚠️
internal/balancer/nop/nop.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8367      +/-   ##
==========================================
+ Coverage   82.17%   82.34%   +0.16%     
==========================================
  Files         419      419              
  Lines       42034    42041       +7     
==========================================
+ Hits        34541    34618      +77     
+ Misses       6027     5969      -58     
+ Partials     1466     1454      -12     
Files with missing lines Coverage Δ
balancer/balancer.go 96.29% <ø> (ø)
balancer/endpointsharding/endpointsharding.go 93.33% <100.00%> (+0.22%) ⬆️
balancer/lazy/lazy.go 81.25% <100.00%> (-0.29%) ⬇️
balancer/leastrequest/leastrequest.go 87.50% <100.00%> (+2.25%) ⬆️
balancer/ringhash/ringhash.go 94.22% <100.00%> (ø)
balancer/roundrobin/roundrobin.go 100.00% <100.00%> (+12.50%) ⬆️
internal/balancer/gracefulswitch/gracefulswitch.go 87.38% <100.00%> (-2.18%) ⬇️
xds/internal/balancer/cdsbalancer/cdsbalancer.go 84.41% <100.00%> (-0.08%) ⬇️
...ternal/balancer/clusterresolver/clusterresolver.go 63.44% <100.00%> (-0.31%) ⬇️
xds/internal/balancer/wrrlocality/balancer.go 68.81% <100.00%> (+0.68%) ⬆️
... and 2 more

... and 27 files with indirect coverage changes

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

@arjan-bal arjan-bal force-pushed the balancer-exit-idle branch 2 times, most recently from c91eab8 to dbd5915 Compare May 28, 2025 14:12
@arjan-bal arjan-bal force-pushed the balancer-exit-idle branch from dbd5915 to 111c588 Compare May 28, 2025 14:22
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Looks good, just one thing I noticed in a few places that could possibly eliminate some code.

@@ -102,6 +102,10 @@ type fakePetiole struct {
bOpts balancer.BuildOptions
}

func (fp *fakePetiole) ExitIdle() {
fp.Balancer.ExitIdle()
Copy link
Member

Choose a reason for hiding this comment

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

This isn't necessary, is it? Balancer is embedded so this should happen automatically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, removed it. I was working on top of the previous PR that added ExitIdle implementations but didn't add the method to the Balancer interface. This was an artifact of the that.

if ib, ok := b.Balancer.(balancer.ExitIdler); ok {
ib.ExitIdle()
}
b.Balancer.ExitIdle()
Copy link
Member

Choose a reason for hiding this comment

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

As above? And more below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. Fixed throughout.

@@ -1034,7 +1034,7 @@ func (s) TestSubConn_RegisterHealthListener(t *testing.T) {
return bd.Data.(balancer.Balancer).UpdateClientConnState(ccs)
},
ExitIdle: func(bd *stub.BalancerData) {
bd.Data.(balancer.ExitIdler).ExitIdle()
bd.Data.(balancer.Balancer).ExitIdle()
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a very common pattern. I wonder if it makes sense for the stub balancer stuff to support an embedded child balancer by default? (Not in this PR for sure.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened an issue: #8371

@dfawley dfawley assigned arjan-bal and unassigned dfawley May 29, 2025
@arjan-bal arjan-bal assigned dfawley and unassigned arjan-bal May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: API Change Breaking API changes (experimental APIs only!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ExitIdle method in balancer.Balancer interface
2 participants