Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions source/common/upstream/cluster_manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ ClusterManagerImpl::ClusterManagerImpl(
->create(),
main_thread_dispatcher,
*Protobuf::DescriptorPool::generated_pool()->FindMethodByName(
"envoy.service.discovery.v2.AggregatedDiscoveryService.DeltaAggregatedResources"),
dyn_resources.ads_config().transport_api_version() ==
envoy::config::core::v3::ApiVersion::V3
? "envoy.service.discovery.v3.AggregatedDiscoveryService.DeltaAggregatedResources"
: "envoy.service.discovery.v2.AggregatedDiscoveryService."
"DeltaAggregatedResources"),
Comment on lines +271 to +277

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to put this logic in type_to_endpoint.cc so that we have all of the version selection logic in one place? WDYT?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, but ADS is an exception; there is no mapping from type to endpoint... we would probably want to rename that module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you. I think it would be better to co-locate this type of selection logic. Maybe at least put in a TODO if you don't want to do it now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs added, I think this depends on where we go with #10650.

dyn_resources.ads_config().transport_api_version(), random_, stats_,
Envoy::Config::Utility::parseRateLimitSettings(dyn_resources.ads_config()), local_info);
} else {
Expand Down Expand Up @@ -1369,4 +1373,4 @@ ProdClusterManagerFactory::createCds(const envoy::config::core::v3::ConfigSource
}

} // namespace Upstream
} // namespace Envoy
} // namespace Envoy
15 changes: 10 additions & 5 deletions test/integration/api_version_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ class ApiVersionIntegrationTest : public testing::TestWithParam<Params>,
std::string actual_type_url;
const char ads_v2_sotw_endpoint[] =
"/envoy.service.discovery.v2.AggregatedDiscoveryService/StreamAggregatedResources";
const char ads_v3_delta_endpoint[] =
const char ads_v3_sotw_endpoint[] =
"/envoy.service.discovery.v3.AggregatedDiscoveryService/StreamAggregatedResources";
const char ads_v2_delta_endpoint[] =
"/envoy.service.discovery.v2.AggregatedDiscoveryService/DeltaAggregatedResources";
const char ads_v3_delta_endpoint[] =
"/envoy.service.discovery.v3.AggregatedDiscoveryService/DeltaAggregatedResources";
switch (transportApiVersion()) {
case envoy::config::core::v3::ApiVersion::AUTO:
case envoy::config::core::v3::ApiVersion::V2: {
Expand All @@ -133,7 +137,7 @@ class ApiVersionIntegrationTest : public testing::TestWithParam<Params>,
EXPECT_TRUE(!hasHiddenEnvoyDeprecated(delta_discovery_request));
xds_stream_->startGrpcStream();
actual_type_url = delta_discovery_request.type_url();
expected_endpoint = expected_v2_delta_endpoint;
expected_endpoint = ads() ? ads_v2_delta_endpoint : expected_v2_delta_endpoint;
break;
}
case envoy::config::core::v3::ApiConfigSource::REST: {
Expand All @@ -158,7 +162,7 @@ class ApiVersionIntegrationTest : public testing::TestWithParam<Params>,
VERIFY_ASSERTION(xds_stream_->waitForGrpcMessage(*dispatcher_, discovery_request));
EXPECT_TRUE(!hasHiddenEnvoyDeprecated(discovery_request));
actual_type_url = discovery_request.type_url();
expected_endpoint = ads() ? ads_v3_delta_endpoint : expected_v3_sotw_endpoint;
expected_endpoint = ads() ? ads_v3_sotw_endpoint : expected_v3_sotw_endpoint;
break;
}
case envoy::config::core::v3::ApiConfigSource::DELTA_GRPC: {
Expand All @@ -167,7 +171,7 @@ class ApiVersionIntegrationTest : public testing::TestWithParam<Params>,
VERIFY_ASSERTION(xds_stream_->waitForGrpcMessage(*dispatcher_, delta_discovery_request));
EXPECT_TRUE(!hasHiddenEnvoyDeprecated(delta_discovery_request));
actual_type_url = delta_discovery_request.type_url();
expected_endpoint = expected_v3_delta_endpoint;
expected_endpoint = ads() ? ads_v3_delta_endpoint : expected_v3_delta_endpoint;
break;
}
case envoy::config::core::v3::ApiConfigSource::REST: {
Expand Down Expand Up @@ -258,7 +262,8 @@ INSTANTIATE_TEST_SUITE_P(
AdsApiConfigSourcesExplicitApiVersions, ApiVersionIntegrationTest,
testing::Combine(testing::Values(TestEnvironment::getIpVersionsForTest()[0]),
testing::Values(true),
testing::Values(envoy::config::core::v3::ApiConfigSource::GRPC),
testing::Values(envoy::config::core::v3::ApiConfigSource::GRPC,
envoy::config::core::v3::ApiConfigSource::DELTA_GRPC),
testing::Values(envoy::config::core::v3::ApiVersion::V2,
envoy::config::core::v3::ApiVersion::V3),
testing::Values(envoy::config::core::v3::ApiVersion::V2,
Expand Down