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

balancer: add SubConn.Shutdown; deprecate Balancer.RemoveSubConn #6493

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Aug 1, 2023

Part 3 of #6472

RELEASE NOTES:

  • balancer: add SubConn.Shutdown and deprecate Balancer.RemoveSubConn

@@ -115,6 +115,13 @@ type SubConn interface {
// creates a new one and returns it. Returns a close function which must
// be called when the Producer is no longer needed.
GetOrBuildProducer(ProducerBuilder) (p Producer, close func())
// Shutdown shuts down the SubConn gracefully. Any started RPCs will be
// allowed to complete. No future calls should be made on the SubConn.
Copy link
Contributor

Choose a reason for hiding this comment

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

No future calls should be made on the SubConn

Do we handle calls on a closed subConn gracefully?
From what I see UpdateAddresses and Connect become no-ops if the state is SHUTDOWN. It would have been nicer if these methods returned an error though. At least Connect() could have returned an error, as the underlying addrConn.connect() already returns an error if the addrConn is shutdown, but we drop that error in our acBalancerWrapper.

Would it be better to say that future calls will be no-ops instead of saying future calls shouldn't be made?

Copy link
Member Author

Choose a reason for hiding this comment

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

t would have been nicer if these methods returned an error though.

UpdateAddresses is going away, but note that adding error return values to things typically makes the calling code more complex and the API harder to reason about.

Would it be better to say that future calls will be no-ops instead of saying future calls shouldn't be made?

I'm of the opinion that telling people not to do things is better than stating what will happen if they do things that are not sensible. This is more straightforward and also gives us flexibility in how we decide to behave.

Copy link
Contributor

Choose a reason for hiding this comment

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

note that adding error return values to things typically makes the calling code more complex and the API harder to reason about

It feels completely logical for an operation like Connect to return something to its caller. But I do agree that in this case though, the caller could (and does) rely on subsequent state updates to figure out how things went. But for UpdateAddresses, there is no clean way to let the caller know that the update did not happen. Good that it is going away :)

balancer/balancer.go Outdated Show resolved Hide resolved
balancer/grpclb/grpclb.go Outdated Show resolved Hide resolved
internal/testutils/balancer.go Show resolved Hide resolved
balancer/grpclb/grpclb_util.go Outdated Show resolved Hide resolved
@easwars easwars assigned dfawley and unassigned easwars Aug 3, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Aug 3, 2023
@@ -115,6 +115,13 @@ type SubConn interface {
// creates a new one and returns it. Returns a close function which must
// be called when the Producer is no longer needed.
GetOrBuildProducer(ProducerBuilder) (p Producer, close func())
// Shutdown shuts down the SubConn gracefully. Any started RPCs will be
// allowed to complete. No future calls should be made on the SubConn.
Copy link
Contributor

Choose a reason for hiding this comment

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

note that adding error return values to things typically makes the calling code more complex and the API harder to reason about

It feels completely logical for an operation like Connect to return something to its caller. But I do agree that in this case though, the caller could (and does) rely on subsequent state updates to figure out how things went. But for UpdateAddresses, there is no clean way to let the caller know that the update did not happen. Good that it is going away :)

@easwars easwars assigned dfawley and unassigned easwars Aug 3, 2023
@dfawley dfawley merged commit 7aceafc into grpc:master Aug 4, 2023
1 check passed
@dfawley dfawley deleted the SubConnRemove branch August 4, 2023 15:14
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: API Change Breaking API changes (experimental APIs only!)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants