From 3498959338ef06c0fb74629328922d3862544e33 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Wed, 17 Jan 2024 19:29:56 +0100 Subject: [PATCH] Implemented locality weighted load balancing ( tests) --- .../envoycontrol/infrastructure/ControlPlaneConfig.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt index 2edc8b4da..73aff39ef 100644 --- a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt +++ b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/infrastructure/ControlPlaneConfig.kt @@ -75,7 +75,7 @@ class ControlPlaneConfig { ): ControlPlane = ControlPlane.builder(properties, meterRegistry) .withMetrics(metrics) - .withCurrentZone(localDatacenter(consulProperties)) + .withCurrentZone(localDatacenter(consulProperties, properties)) .withEnvoyHttpFilters(envoyHttpFilters) .build(globalStateChanges.combined()) @@ -115,11 +115,12 @@ class ControlPlaneConfig { fun localClusterStateChanges( consulServiceChanges: ConsulServiceChanges, consulProperties: ConsulProperties, - transformers: List + transformers: List, + envoyControlProperties: EnvoyControlProperties ): LocalClusterStateChanges = ConsulLocalClusterStateChanges( consulServiceChanges, Locality.LOCAL, - localDatacenter(consulProperties), + localDatacenter(consulProperties, envoyControlProperties), transformers ) @@ -173,7 +174,9 @@ class ControlPlaneConfig { return EnvoyHttpFilters.defaultFilters(properties.envoy.snapshot) } - fun localDatacenter(properties: ConsulProperties): String { + fun localDatacenter(properties: ConsulProperties, envoyControlProperties: EnvoyControlProperties): String { + logger.info("LoadBalancing priorities: ${envoyControlProperties.envoy + .snapshot.loadBalancing.priorities.zonePriorities}") return (ConsulClient(properties.host, properties.port).agentSelf.value?.config?.datacenter ?: "local") .also { logger.info("Resolved local datacenter name: $it") } }