From 1f016807060180bfd03091354b3e99dc88aff268 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Thu, 24 Aug 2023 22:59:53 +0200 Subject: [PATCH] Implemented possibility for configuring traffic splitting, and fallback using aggregate cluster #292 --- .../snapshot/resource/clusters/EnvoyClustersFactory.kt | 3 ++- .../snapshot/resource/endpoints/EnvoyEndpointsFactory.kt | 2 +- .../tech/servicemesh/envoycontrol/utils/ClusterNames.kt | 9 +++++---- 3 files changed, 8 insertions(+), 6 deletions(-) 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 3f4a5edf2..bc16b0956 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 @@ -267,7 +267,8 @@ class EnvoyClustersFactory( return cluster?.let { if (enableTrafficSplitting(serviceName, cluster.name, dependencies, clusterLoadAssignment)) { logger.debug( - "Creating traffic splitting egress cluster config for ${cluster.name}, service: $serviceName") + "Creating traffic splitting egress cluster config for ${cluster.name}, service: $serviceName" + ) createSetOfClustersForGroup(dependencySettings, cluster) } else { listOf(createClusterForGroup(dependencySettings, cluster)) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt index a214cfafb..a204fd127 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt @@ -82,7 +82,7 @@ class EnvoyEndpointsFactory( ): List { return egressRouteSpecifications .filter { it.clusterWeights.isNotEmpty() } - .onEach { logger.debug("Traffic splitting is enabled for cluster: ${it.clusterName}") } + .onEach { logger.debug("Traffic splitting is enabled for cluster: ${it.clusterName}") } .mapNotNull { routeSpec -> clusterLoadAssignments[routeSpec.clusterName]?.let { ClusterLoadAssignment.newBuilder(it) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterNames.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterNames.kt index 7dc6dc1fd..921744309 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterNames.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterNames.kt @@ -4,13 +4,14 @@ import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterNames.AGGREGATE_CLU import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterNames.SECONDARY_CLUSTER_POSTFIX object ClusterNames { - const val SECONDARY_CLUSTER_POSTFIX= "secondary" - const val AGGREGATE_CLUSTER_POSTFIX= "aggregate" + const val SECONDARY_CLUSTER_POSTFIX = "secondary" + const val AGGREGATE_CLUSTER_POSTFIX = "aggregate" } -fun getSecondaryClusterName(serviceName: String) :String { + +fun getSecondaryClusterName(serviceName: String): String { return "$serviceName-$SECONDARY_CLUSTER_POSTFIX" } -fun getAggregateClusterName(serviceName: String) :String { +fun getAggregateClusterName(serviceName: String): String { return "$serviceName-$AGGREGATE_CLUSTER_POSTFIX" }