From 121002ff0dffbc28835bfa0dc48b0d94a7f8abf2 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Mon, 18 Sep 2023 13:49:12 +0200 Subject: [PATCH] added service name to eds config #292 --- .../envoycontrol/snapshot/EnvoySnapshotFactory.kt | 2 +- .../snapshot/resource/clusters/EnvoyClustersFactory.kt | 6 +++++- .../resource/clusters/EnvoyClustersFactoryTest.kt | 1 - .../servicemesh/envoycontrol/utils/ClusterOperations.kt | 9 ++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt index 0b009c1e2..0a8085009 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt @@ -342,7 +342,7 @@ class EnvoySnapshotFactory( routes = routes, routesVersion = version.routes ).also { - logger.info("Snapshot for group: $it") + logger.debug("Snapshot for group: $it") } } diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt index f4c39b191..d6d62dbaa 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt @@ -242,6 +242,10 @@ class EnvoyClustersFactory( return Cluster.newBuilder(cluster) .setCommonHttpProtocolOptions(HttpProtocolOptions.newBuilder().setIdleTimeout(idleTimeoutPolicy)) .setName(clusterName) + .setEdsClusterConfig( + Cluster.EdsClusterConfig.newBuilder(cluster.edsClusterConfig) + .setServiceName(clusterName) + ) .build() .also { logger.debug("Created regular cluster config {}", it.toString()) } } @@ -481,7 +485,7 @@ class EnvoyClustersFactory( ) ) } - ) + ).setServiceName(clusterConfiguration.serviceName) ) .setLbPolicy(properties.loadBalancing.policy) // TODO: if we want to have multiple memory-backend instances of ratelimit diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactoryTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactoryTest.kt index bb5751acc..2a1d8917a 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactoryTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactoryTest.kt @@ -115,7 +115,6 @@ internal class EnvoyClustersFactoryTest { } .anySatisfy { assertThat(it.name).isEqualTo(SECONDARY_CLUSTER_NAME) - assertThat(it.edsClusterConfig).isEqualTo(cluster1.edsClusterConfig) } .anySatisfy { assertThat(it.name).isEqualTo(AGGREGATE_CLUSTER_NAME) diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterOperations.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterOperations.kt index 05f0f4684..d261ed874 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterOperations.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterOperations.kt @@ -18,9 +18,12 @@ fun createCluster( .setType(Cluster.DiscoveryType.EDS) .setConnectTimeout(Durations.fromMillis(defaultProperties.edsConnectionTimeout.toMillis())) .setEdsClusterConfig( - Cluster.EdsClusterConfig.newBuilder().setEdsConfig( - ConfigSource.newBuilder().setAds(AggregatedConfigSource.newBuilder()) - ) + Cluster.EdsClusterConfig.newBuilder() + .setEdsConfig( + ConfigSource.newBuilder().setAds( + AggregatedConfigSource.newBuilder() + ) + ).setServiceName(clusterName) ) .setLbPolicy(defaultProperties.loadBalancing.policy) .setCommonHttpProtocolOptions(