From 6e23fc57e84990f06adec1b39548f583d649c990 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Wed, 3 Apr 2024 12:36:40 +0200 Subject: [PATCH] #624 Set flat priority only for services with traffic splitting (added log) --- .../envoycontrol/snapshot/EnvoySnapshotFactory.kt | 6 ++++++ .../trafficsplitting/LocalityWeightedLoadBalancingTest.kt | 6 +++++- .../LocalityWeightedLoadBalancingUnlistedServiceTest.kt | 2 -- .../envoycontrol/trafficsplitting/TrafficSplitting.kt | 2 +- 4 files changed, 12 insertions(+), 4 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 c56165dad..ce8f7eb28 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 @@ -328,6 +328,12 @@ class EnvoySnapshotFactory( ) val version = snapshotsVersions.version(group, clusters, endpoints, listeners, routes) + // TODO REMOVE THIS LOG + if (group.serviceName == "service-mesh-service-second") { + endpoints + .find{ it.clusterName == "service-mesh-service-first"} + ?.let { logger.info("Snapshot endpoints (${it.endpointsList.size}): ${it.endpointsList.toString()}") } + } return createSnapshot( clusters = clusters, clustersVersion = version.clusters, diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingTest.kt index 0ddcc9b39..f0342cd5a 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingTest.kt @@ -15,6 +15,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.config.service.EchoServiceExtens import verifyCallsCountCloseTo import verifyCallsCountEq import verifyIsReachable +import java.io.File import java.time.Duration class LocalityWeightedLoadBalancingTest { @@ -100,10 +101,13 @@ class LocalityWeightedLoadBalancingTest { consul.serverSecond.operations.registerService(upstreamServiceDC2, name = UPSTREAM_SERVICE_NAME) downstreamServiceEnvoy.verifyIsReachable(upstreamServiceDC2, UPSTREAM_SERVICE_NAME) + consul.serverThird.operations.registerService(upstreamServiceDC3, name = UPSTREAM_SERVICE_NAME) + envoyDC3.verifyIsReachable(upstreamServiceDC3, UPSTREAM_SERVICE_NAME) + downstreamServiceEnvoy.callUpstreamServiceRepeatedly(upstreamServiceDC1, upstreamServiceDC2) .verifyCallsCountCloseTo(upstreamServiceDC1, 75) .verifyCallsCountCloseTo(upstreamServiceDC2, 25) - .verifyCallsCountEq(upstreamServiceDC3, 0) + .verifyCallsCountEq(upstreamServiceDC3, 0) } @Test diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingUnlistedServiceTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingUnlistedServiceTest.kt index 5dada8a02..cb147556a 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingUnlistedServiceTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/LocalityWeightedLoadBalancingUnlistedServiceTest.kt @@ -12,7 +12,6 @@ import pl.allegro.tech.servicemesh.envoycontrol.config.consul.ConsulMultiCluster import pl.allegro.tech.servicemesh.envoycontrol.config.envoy.EnvoyExtension import pl.allegro.tech.servicemesh.envoycontrol.config.envoycontrol.EnvoyControlClusteredExtension import pl.allegro.tech.servicemesh.envoycontrol.config.service.EchoServiceExtension -import pl.allegro.tech.servicemesh.envoycontrol.trafficsplitting.LocalityWeightedLoadBalancingTest.Companion.upstreamServiceDC3 import verifyCallsCountEq import verifyIsReachable import java.time.Duration @@ -87,6 +86,5 @@ class LocalityWeightedLoadBalancingUnlistedServiceTest { echoEnvoyDC1.callUpstreamServiceRepeatedly(upstreamServiceDC1, upstreamServiceDC2) .verifyCallsCountEq(upstreamServiceDC1, 100) .verifyCallsCountEq(upstreamServiceDC2, 0) - .verifyCallsCountEq(upstreamServiceDC3, 0) } } diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/TrafficSplitting.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/TrafficSplitting.kt index cbd7da660..a0bbe5f3d 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/TrafficSplitting.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/TrafficSplitting.kt @@ -12,7 +12,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.config.service.EchoServiceExtens internal object TrafficSplitting { const val UPSTREAM_SERVICE_NAME = "service-1" const val SERVICE_NAME = "echo2" - const val DELTA_PERCENTAGE = 20.0 + const val DELTA_PERCENTAGE = 10.0 const val FORCE_TRAFFIC_ZONE = "dc2" val DEFAULT_PRIORITIES = mapOf( "dc1" to mapOf(