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 StateListener to NewSubConnOptions for SubConn state updates #6481

Merged
merged 5 commits into from Jul 31, 2023

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Jul 26, 2023

This change is backward-compatible. However I've labeled it as "API Change" since we are deprecating Balancer.UpdateSubConnState.

This also does not fully migrate all our code to stop using UpdateSubConnState. In particular, many tests still invoke this method, and will need to be migrated over slowly. However, it is the minimal amount of changes required to keep everything working while providing support for this optional feature throughout. It also shows an example of how the other tests can be updated for this transition in gracefulswitch_test.go and weightedtarget_test.go, which now calls the SubConns directly to update their state. Future PRs will migrate all our balancers to use this functionality.

#6472

RELEASE NOTES:

  • balancer: add StateListener to NewSubConnOptions for SubConn state updates and deprecate Balancer.UpdateSubConnState --- NOTICE: The Balancer.UpdateSubConnState method will be deleted in a future release and NewSubConnOptions.StateListener will be required.

balancer/balancer.go Show resolved Hide resolved
balancer_conn_wrappers.go Outdated Show resolved Hide resolved
Comment on lines +234 to +236
// UpdateSubConnState forwards the update to the appropriate child.
func (gsb *Balancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) {
gsb.updateSubConnState(sc, state, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since ccb is switched to calling subConn.UpdateState, when and how will this be ever called? From tests maybe (which need to be updated)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, from tests... Loads of tests call these methods. I cleaned up some, but there are more.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a TODO or an issue to track that?

Copy link
Member Author

Choose a reason for hiding this comment

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

That will need to be done as part of #6472. Once this PR lands and I start migrating more things, I'll make UpdateSubConnState for each balancer into a nop and stop calling it from tests at that time. I'll likely do every balancer in its own PR. In hindsight, I probably would have just left the tests I changed in this PR alone to keep the changes smaller, but it's also a nice preview into how it will look, so I left it.

@easwars easwars assigned dfawley and unassigned easwars Jul 28, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Jul 28, 2023
@easwars easwars assigned dfawley and unassigned easwars Jul 28, 2023
@dfawley dfawley assigned easwars and unassigned dfawley Jul 28, 2023
@easwars easwars assigned dfawley and unassigned easwars Jul 28, 2023
@dfawley dfawley merged commit c635404 into grpc:master Jul 31, 2023
11 checks passed
@dfawley dfawley deleted the UpdateSubConnState2 branch July 31, 2023 16:42
mdibaiee added a commit to gazette/core that referenced this pull request Nov 15, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
mdibaiee added a commit to gazette/core that referenced this pull request Nov 15, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
mdibaiee added a commit to gazette/core that referenced this pull request Nov 17, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
mdibaiee added a commit to gazette/core that referenced this pull request Nov 17, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
mdibaiee added a commit to gazette/core that referenced this pull request Nov 21, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
mdibaiee added a commit to gazette/core that referenced this pull request Nov 21, 2023
See grpc/grpc-go#6481, specifically
weightedtarget_test.go as an example of how tests need to be migrated
now that UpdateSubConnState is deprecated. I have followed the same
example in our dispatcher_test.go
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 28, 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.

None yet

2 participants