mirror of https://github.com/grpc/grpc-java.git
xds: Return a null RouteAction when cluster has no cluster_specifier or route lookup is not enabled with a cluster_specifier_plugin.
We want to ignore the route in these situations, which is achieved by returning a null. The current behavior of returning an error triggers a NACK to the update.
This commit is contained in:
parent
700afafb10
commit
6c00f0052f
|
|
@ -1340,12 +1340,11 @@ final class ClientXdsClient extends XdsClient implements XdsResponseHandler, Res
|
||||||
return StructOrError.fromStruct(RouteAction.forClusterSpecifierPlugin(
|
return StructOrError.fromStruct(RouteAction.forClusterSpecifierPlugin(
|
||||||
namedPluginConfig, hashPolicies, timeoutNano, retryPolicy));
|
namedPluginConfig, hashPolicies, timeoutNano, retryPolicy));
|
||||||
} else {
|
} else {
|
||||||
return StructOrError.fromError("Support for ClusterSpecifierPlugin not enabled");
|
return null;
|
||||||
}
|
}
|
||||||
case CLUSTERSPECIFIER_NOT_SET:
|
case CLUSTERSPECIFIER_NOT_SET:
|
||||||
default:
|
default:
|
||||||
return StructOrError.fromError(
|
return null;
|
||||||
"Unknown cluster specifier: " + proto.getClusterSpecifierCase());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package io.grpc.xds;
|
package io.grpc.xds;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static io.envoyproxy.envoy.config.route.v3.RouteAction.ClusterSpecifierCase.CLUSTER_SPECIFIER_PLUGIN;
|
||||||
|
|
||||||
import com.github.udpa.udpa.type.v1.TypedStruct;
|
import com.github.udpa.udpa.type.v1.TypedStruct;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
@ -801,6 +802,30 @@ public class ClientXdsClientDataTest {
|
||||||
assertThat(policies.get(1).isTerminal()).isFalse();
|
assertThat(policies.get(1).isTerminal()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseRouteAction_clusterSpecifier_routeLookupDisabled() {
|
||||||
|
ClientXdsClient.enableRouteLookup = false;
|
||||||
|
io.envoyproxy.envoy.config.route.v3.RouteAction proto =
|
||||||
|
io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder()
|
||||||
|
.setClusterSpecifierPlugin(CLUSTER_SPECIFIER_PLUGIN.name())
|
||||||
|
.build();
|
||||||
|
StructOrError<RouteAction> struct =
|
||||||
|
ClientXdsClient.parseRouteAction(proto, filterRegistry, false,
|
||||||
|
ImmutableMap.<String, PluginConfig>of());
|
||||||
|
assertThat(struct).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseRouteAction_custerSpecifierNotSet() {
|
||||||
|
io.envoyproxy.envoy.config.route.v3.RouteAction proto =
|
||||||
|
io.envoyproxy.envoy.config.route.v3.RouteAction.newBuilder()
|
||||||
|
.build();
|
||||||
|
StructOrError<RouteAction> struct =
|
||||||
|
ClientXdsClient.parseRouteAction(proto, filterRegistry, false,
|
||||||
|
ImmutableMap.<String, PluginConfig>of());
|
||||||
|
assertThat(struct).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseClusterWeight() {
|
public void parseClusterWeight() {
|
||||||
io.envoyproxy.envoy.config.route.v3.WeightedCluster.ClusterWeight proto =
|
io.envoyproxy.envoy.config.route.v3.WeightedCluster.ClusterWeight proto =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue