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

Replace GracefulSwitch.switchTo with normal config passing #11204

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

Conversation

ejona86
Copy link
Member

@ejona86 ejona86 commented May 13, 2024

This doesn't actually remove switchTo() as the API is currently public, although we may want to mark it deprecated. You may want to look at each commit separately, especially the first. The rest of the commits should look pretty similar to each other (IIRC). The tests added to GracefulSwitchLoadBalancerTest are copies of the existing tests with switchTo() replaced. You'll notice I made some changes to the existing tests before I copied them.

No rush on reviewing this. It has been sitting around on my machine since March.

This is to replace switchTo(), to allow composing GracefulSwitchLb with
other helpers like MultiChildLb. It also prevents users of
GracefulSwitchLb from needing to use ServiceConfigUtil.
@ejona86 ejona86 requested a review from larry-safran May 13, 2024 14:38
delegate().handleResolvedAddresses(resolvedAddresses);
return;
}
Config config = (Config) resolvedAddresses.getLoadBalancingPolicyConfig();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should provide some javadoc here or at class level that the ResolvedAddresses must have a Config, not the config provided in the EDS resource.

@@ -90,18 +97,51 @@ public String toString() {
private LoadBalancer pendingLb = defaultBalancer;
private ConnectivityState pendingState;
private SubchannelPicker pendingPicker;
private boolean switchToCalled;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should update the class level javadoc to reflect that it is no longer necessary to do a switchTo before calling handleResolvedAddresses as the necessary logic is now done implicitly and switchTo just pins the delegate.

if (switchToCalled) {
return delegate().acceptResolvedAddresses(resolvedAddresses);
}
Config config = (Config) resolvedAddresses.getLoadBalancingPolicyConfig();
Copy link
Contributor

Choose a reason for hiding this comment

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

None of the classes that use GracefulSwitchLB call acceptResolvedAddresses. You have tests, but it seems like they should be throwing an exception on this cast if they don't get short circuited above.

createLoadBalancingPolicyConfig(selection.getProvider(), selection.getConfig()));
}

public static Object createLoadBalancingPolicyConfig(
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to have some javadoc here explaining that you need to call this to get the value for ResolvedAddressBuilder.setLoadBalancingPolicyConfig() for the ResolvedAddress passed to [accept|handle]ResolvedAddresses.

helper0.updateBalancingState(READY, picker);
verify(mockHelper).updateBalancingState(READY, picker);

assertIsOk(gracefulSwitchLb.acceptResolvedAddresses(addressesBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to have a brief comment describing what this group of lines is testing like on line 829.

Object config = new Object();
new EqualsTester()
.addEqualityGroup(createConfig(lbPolicies[0], config), createConfig(lbPolicies[0], config))
.addEqualityGroup(createConfig(lbPolicies[1], config))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why shouldn't configs with different lb policies be non-equal?


ClusterImplConfig(String cluster, @Nullable String edsServiceName,
@Nullable ServerInfo lrsServerInfo, @Nullable Long maxConcurrentRequests,
List<DropOverload> dropCategories, PolicySelection childPolicy,
List<DropOverload> dropCategories,
io.grpc.internal.ServiceConfigUtil.PolicySelection childPolicy,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to restore the import for PolicySelection

Comment on lines +100 to +101
childPolicy.getProvider(), childPolicy.getConfig()),
tlsContext);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could join lines and still be within 100 chars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants