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

xds: Use wrr_locality LB and support load_balancing_policy in Cluster #9141

Merged
merged 6 commits into from
May 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fail the whole conversion process on the first conversion failure.
temawi committed May 6, 2022
commit 54b007e665a5b40f766fe70c7557d0f5bfd0da8a
11 changes: 3 additions & 8 deletions xds/src/main/java/io/grpc/xds/LoadBalancerConfigFactory.java
Original file line number Diff line number Diff line change
@@ -171,17 +171,12 @@ static class LoadBalancingPolicyConverter {
}
// TODO: support least_request once it is added to the envoy protos.
} catch (InvalidProtocolBufferException e) {
logger.log(XdsLogLevel.WARNING, "Invalid Any protobuf for policy {0}: {1}",
typedConfig.getTypeUrl(), e.getMessage());
continue;
} catch (ResourceInvalidException e) {
logger.log(XdsLogLevel.WARNING, "Invalid configuration for policy {0}: {1}",
typedConfig.getTypeUrl(), e.getMessage());
continue;
throw new ResourceInvalidException(
"Unable to unpack typedConfig for: " + typedConfig.getTypeUrl(), e);
}
// The service config is expected to have a single root entry, where the name of that entry
// is the name of the policy. A Load balancer with this name must exist in the registry.
if (serviceConfig != null && LoadBalancerRegistry.getDefaultRegistry()
if (serviceConfig == null || LoadBalancerRegistry.getDefaultRegistry()
.getProvider(Iterables.getOnlyElement(serviceConfig.keySet())) == null) {
logger.log(XdsLogLevel.WARNING, "Policy {0} not found in the LB registry, skipping",
typedConfig.getTypeUrl());
16 changes: 12 additions & 4 deletions xds/src/test/java/io/grpc/xds/LoadBalancerConfigFactoryTest.java
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ public void ringHash_invalidHash() {
// With the new config mechanism we get a more generic error than with the old one because the
// logic loops over potentially multiple configurations and only throws an exception at the
// end if there was no valid policies found.
assertThat(e).hasMessageThat().contains("Invalid LoadBalancingPolicy");
assertThat(e).hasMessageThat().contains("Invalid ring hash function");
return;
}
fail("ResourceInvalidException not thrown");
@@ -266,7 +266,9 @@ public void complexCustomConfig_customProviderRegistered() throws ResourceInvali
LoadBalancerConfigFactory.newConfig(cluster, false)));
}

// When a provider for the custom policy is NOT available, we fall back to the next available one.
// When a provider for the custom policy is NOT available, we still fail even if there is another
// round_robin configuration in the list as the wrr_locality the custom config is wrapped in is
// a recognized type and expected to have a valid config.
@Test
public void complexCustomConfig_customProviderNotRegistered() throws ResourceInvalidException {
Cluster cluster = Cluster.newBuilder()
@@ -275,8 +277,14 @@ public void complexCustomConfig_customProviderNotRegistered() throws ResourceInv
.addPolicies(buildWrrPolicy(ROUND_ROBIN_POLICY)))
.build();

assertValidRoundRobin(ServiceConfigUtil.unwrapLoadBalancingConfig(
LoadBalancerConfigFactory.newConfig(cluster, false)));
try {
ServiceConfigUtil.unwrapLoadBalancingConfig(
LoadBalancerConfigFactory.newConfig(cluster, false));
} catch (ResourceInvalidException e) {
assertThat(e).hasMessageThat().contains("Invalid LoadBalancingPolicy");
return;
}
fail("ResourceInvalidException not thrown");
}

private void assertValidCustomConfig(LbConfig lbConfig) {