Skip to content
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

balancergroup: add a ParseConfig API and remove the UpdateBuilder API #7232

Merged
merged 5 commits into from
May 22, 2024

Conversation

easwars
Copy link
Contributor

@easwars easwars commented May 13, 2024

This PR makes the following API change to the balancergroup package:

  • Adds a ParseConfig method
  • Removes the UpdateBuilder method
  • The above closely aligns with the approach taken by the gracefulswitch balancer
  • Users of the balancergroup that want to change the child policy for a particular child, should call ParseConfig with the new configuration, and call UpdateClientConnState. This will result in graceful switchover to the new child policy.

This PR also has a bunch of cleanup in the clustermanager LB policy:

  • Use the balancer.ConnectivityStateManager instead of manually computing aggregate connectivity state
  • Use the newly added balancergroup API described above
  • A bunch of code in the StateAggregator implementation in clustermanager seems obsolete (like supporting a separate start method and clearing picker state in close).
    • Also added a Locked suffix to methods where appropriate
  • Fix tests to use the leakchecker

RELEASE NOTES: none

@easwars easwars added the Type: Internal Cleanup Refactors, etc label May 13, 2024
@easwars easwars modified the milestones: 1.64 Release, 1.65 Release May 13, 2024
@easwars easwars requested a review from dfawley May 13, 2024 16:37
Comment on lines 383 to 384
// Returns a non-nil error if the provided builder is not registered.
func (bg *BalancerGroup) UpdateBuilder(id, builder string) error {
Copy link
Member

Choose a reason for hiding this comment

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

You modified this to return an error, but don't check it at the call sites. Even though those used to panic, the danger is that a "normal" error will be returned from here in the future, and so not checking it is problematic.

We should either panic if the builder isn't registered (as the previous behavior) or check the error at the call sites.

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 the UpdateBuilder call and replaced with a ParseConfig similar to the gracefulswitch balancer as discussed offline.

}
sbc.gracefulSwitch(builder)
bg.outgoingMu.Unlock()
sbc.gracefulSwitch(bldr)
Copy link
Member

Choose a reason for hiding this comment

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

This used to be called without the lock -- are you sure this is OK to call with the lock held?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was called with the lock held earlier as well. Just that in the if sbc == nil block, we were returning without releasing the lock. With the defer now, we should release it from code paths.

logger *grpclog.PrefixLogger
cc balancer.ClientConn
logger *grpclog.PrefixLogger
csEvltr *balancer.ConnectivityStateEvaluator
Copy link
Member

Choose a reason for hiding this comment

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

Optional, nit: how about csEval instead? I find it much easier to say in my head.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@dfawley dfawley assigned easwars and unassigned dfawley May 13, 2024
@easwars easwars changed the title xds: remove duplicate code in clustermanager by using ConnectivityStateEvaluator balancergroup: add a ParseConfig API and remove the UpdateBuilder API May 15, 2024
@easwars
Copy link
Contributor Author

easwars commented May 15, 2024

@dfawley : This PR now has a totally different flavor. I was a little lazy to break it up. Let me know if you prefer that though. Thanks.

@easwars easwars assigned dfawley and unassigned easwars May 15, 2024
@dfawley
Copy link
Member

dfawley commented May 21, 2024

Please sign the CLAs:

image

😝

@dfawley dfawley assigned easwars and unassigned dfawley May 21, 2024
@easwars easwars closed this May 22, 2024
@easwars easwars reopened this May 22, 2024
@easwars easwars merged commit c822adf into grpc:master May 22, 2024
22 checks passed
@easwars easwars deleted the use_cse_in_clustermanager branch May 22, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants