Merge pull request #22787 from donnadionne/policy_name

Ensuring each action is only generated once in service config, even
pull/22798/head
donnadionne 5 years ago committed by GitHub
commit 7846840841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/core/ext/filters/client_channel/xds/xds_client.cc
  2. 3
      test/cpp/end2end/xds_end2end_test.cc

@ -2068,10 +2068,14 @@ grpc_error* XdsClient::CreateServiceConfig(
" { \"xds_routing_experimental\":{\n"
" \"actions\":{\n");
std::vector<std::string> actions_vector;
std::set<std::string> 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(

@ -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);

Loading…
Cancel
Save