diff --git a/src/core/ext/filters/client_channel/xds/xds_client.cc b/src/core/ext/filters/client_channel/xds/xds_client.cc index 9dc7b97773c..aec4ec4e708 100644 --- a/src/core/ext/filters/client_channel/xds/xds_client.cc +++ b/src/core/ext/filters/client_channel/xds/xds_client.cc @@ -2068,10 +2068,14 @@ grpc_error* XdsClient::CreateServiceConfig( " { \"xds_routing_experimental\":{\n" " \"actions\":{\n"); std::vector actions_vector; + std::set actions_set; for (size_t i = 0; i < rds_update.routes.size(); ++i) { auto route = rds_update.routes[i]; - actions_vector.push_back( - CreateServiceConfigActionCluster(route.cluster_name.c_str())); + if (actions_set.find(route.cluster_name) == actions_set.end()) { + actions_vector.push_back( + CreateServiceConfigActionCluster(route.cluster_name.c_str())); + actions_set.emplace(route.cluster_name); + } } config_parts.push_back(absl::StrJoin(actions_vector, ",\n")); config_parts.push_back( diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index aa873490ca4..8eb897233e9 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -2576,6 +2576,9 @@ TEST_P(LdsTest, XdsRoutingPathMatching) { auto* route2 = new_route_config.mutable_virtual_hosts(0)->add_routes(); route2->mutable_match()->set_path("/grpc.testing.EchoTest2Service/Echo2"); route2->mutable_route()->set_cluster(kNewCluster2Name); + auto* route3 = new_route_config.mutable_virtual_hosts(0)->add_routes(); + route3->mutable_match()->set_path("/grpc.testing.EchoTest3Service/Echo3"); + route3->mutable_route()->set_cluster(kDefaultResourceName); auto* default_route = new_route_config.mutable_virtual_hosts(0)->add_routes(); default_route->mutable_match()->set_prefix(""); default_route->mutable_route()->set_cluster(kDefaultResourceName);