@@ -94,6 +94,8 @@ final class XdsNameResolver extends NameResolver {
9494
9595 static final CallOptions .Key <String > CLUSTER_SELECTION_KEY =
9696 CallOptions .Key .create ("io.grpc.xds.CLUSTER_SELECTION_KEY" );
97+ static final CallOptions .Key <XdsConfig > XDS_CONFIG_CALL_OPTION_KEY =
98+ CallOptions .Key .create ("io.grpc.xds.XDS_CONFIG_CALL_OPTION_KEY" );
9799 static final CallOptions .Key <Long > RPC_HASH_KEY =
98100 CallOptions .Key .create ("io.grpc.xds.RPC_HASH_KEY" );
99101 static final CallOptions .Key <Boolean > AUTO_HOST_REWRITE_KEY =
@@ -467,6 +469,7 @@ public Result selectConfig(PickSubchannelArgs args) {
467469 "Failed to parse service config (method config)" ));
468470 }
469471 final String finalCluster = cluster ;
472+ final XdsConfig xdsConfig = routingCfg .xdsConfig ;
470473 final long hash = generateHash (routeAction .hashPolicies (), headers );
471474 class ClusterSelectionInterceptor implements ClientInterceptor {
472475 @ Override
@@ -475,6 +478,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
475478 final Channel next ) {
476479 CallOptions callOptionsForCluster =
477480 callOptions .withOption (CLUSTER_SELECTION_KEY , finalCluster )
481+ .withOption (XDS_CONFIG_CALL_OPTION_KEY , xdsConfig )
478482 .withOption (RPC_HASH_KEY , hash );
479483 if (routeAction .autoHostRewrite ()) {
480484 callOptionsForCluster = callOptionsForCluster .withOption (AUTO_HOST_REWRITE_KEY , true );
@@ -801,7 +805,7 @@ private void updateRoutes(
801805 }
802806 // Make newly added clusters selectable by config selector and deleted clusters no longer
803807 // selectable.
804- routingConfig = new RoutingConfig (httpMaxStreamDurationNano , routesData .build ());
808+ routingConfig = new RoutingConfig (xdsConfig , httpMaxStreamDurationNano , routesData .build ());
805809 for (String cluster : deletedClusters ) {
806810 int count = clusterRefs .get (cluster ).refCount .decrementAndGet ();
807811 if (count == 0 ) {
@@ -879,17 +883,21 @@ private void cleanUpRoutes(Status error) {
879883 * VirtualHost-level configuration for request routing.
880884 */
881885 private static class RoutingConfig {
882- private final long fallbackTimeoutNano ;
886+ final XdsConfig xdsConfig ;
887+ final long fallbackTimeoutNano ;
883888 final ImmutableList <RouteData > routes ;
884889 final Status errorStatus ;
885890
886- private RoutingConfig (long fallbackTimeoutNano , ImmutableList <RouteData > routes ) {
891+ private RoutingConfig (
892+ XdsConfig xdsConfig , long fallbackTimeoutNano , ImmutableList <RouteData > routes ) {
893+ this .xdsConfig = checkNotNull (xdsConfig , "xdsConfig" );
887894 this .fallbackTimeoutNano = fallbackTimeoutNano ;
888895 this .routes = checkNotNull (routes , "routes" );
889896 this .errorStatus = null ;
890897 }
891898
892899 private RoutingConfig (Status errorStatus ) {
900+ this .xdsConfig = null ;
893901 this .fallbackTimeoutNano = 0 ;
894902 this .routes = null ;
895903 this .errorStatus = checkNotNull (errorStatus , "errorStatus" );
0 commit comments