Skip to content

Commit ade122f

Browse files
added service name to eds config #292
1 parent 41c0c9b commit ade122f

File tree

10 files changed

+21
-133
lines changed

10 files changed

+21
-133
lines changed

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class EnvoySnapshotFactory(
187187
globalSnapshot: GlobalSnapshot
188188
): Collection<RouteSpecification> {
189189
val definedServicesRoutes = group.proxySettings.outgoing.getServiceDependencies().map {
190-
getTrafficSplittingRouteSpecification(
190+
buildRouteSpecification(
191191
clusterName = it.service,
192192
routeDomains = listOf(it.service) + getServiceWithCustomDomain(it.service),
193193
settings = it.settings,
@@ -199,11 +199,10 @@ class EnvoySnapshotFactory(
199199
is ServicesGroup -> {
200200
definedServicesRoutes
201201
}
202-
203202
is AllServicesGroup -> {
204203
val servicesNames = group.proxySettings.outgoing.getServiceDependencies().map { it.service }.toSet()
205204
val allServicesRoutes = globalSnapshot.allServicesNames.subtract(servicesNames).map {
206-
getTrafficSplittingRouteSpecification(
205+
buildRouteSpecification(
207206
clusterName = it,
208207
routeDomains = listOf(it) + getServiceWithCustomDomain(it),
209208
settings = group.proxySettings.outgoing.defaultServiceSettings,
@@ -216,7 +215,7 @@ class EnvoySnapshotFactory(
216215
}
217216
}
218217

219-
private fun getTrafficSplittingRouteSpecification(
218+
private fun buildRouteSpecification(
220219
clusterName: String,
221220
routeDomains: List<String>,
222221
settings: DependencySettings,
@@ -228,11 +227,11 @@ class EnvoySnapshotFactory(
228227
val enabledForDependency = globalSnapshot.endpoints[clusterName]?.endpointsList
229228
?.any { e -> trafficSplitting.zoneName == e.locality.zone }
230229
?: false
231-
logger.debug(
232-
"Building route spec weights: $weights, enabledForDependency: $enabledForDependency, " +
233-
"serviceName: $serviceName, clusterName: $clusterName"
234-
)
235230
return if (weights != null && enabledForDependency) {
231+
logger.debug(
232+
"Building traffic splitting route spec, weights: $weights, " +
233+
"serviceName: $serviceName, clusterName: $clusterName, "
234+
)
236235
WeightRouteSpecification(
237236
clusterName,
238237
routeDomains,
@@ -341,9 +340,7 @@ class EnvoySnapshotFactory(
341340
listenersVersion = version.listeners,
342341
routes = routes,
343342
routesVersion = version.routes
344-
).also {
345-
logger.debug("Snapshot for group: $it")
346-
}
343+
)
347344
}
348345

349346
private fun createRoutesWhenUsingTransparentProxy(

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ class CanaryProperties {
158158
class TrafficSplittingProperties {
159159
var zoneName = ""
160160
var serviceByWeightsProperties: Map<String, ZoneWeights> = mapOf()
161-
var secondaryClusterPostfix = "sec"
162-
var aggregateClusterPostfix = "agg"
161+
var secondaryClusterPostfix = "secondary"
162+
var aggregateClusterPostfix = "aggregate"
163163
}
164164

165165
class ZoneWeights {

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ class EnvoyEndpointsFactory(
9191
e.locality.zone == properties.loadBalancing.trafficSplitting.zoneName
9292
})
9393
.setClusterName(
94-
"${routeSpec.clusterName}-" +
95-
properties.loadBalancing.trafficSplitting.secondaryClusterPostfix
94+
"${routeSpec.clusterName}-" + properties.loadBalancing
95+
.trafficSplitting.secondaryClusterPostfix
9696
)
9797
.build()
9898
}

envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,12 @@ class EnvoyEgressRoutesFactory(
357357
WeightedCluster.newBuilder()
358358
.withClusterWeight(routeSpec.clusterName, routeSpec.clusterWeights.main)
359359
.withClusterWeight(
360-
"${routeSpec.clusterName}-" +
361-
properties.loadBalancing.trafficSplitting.aggregateClusterPostfix,
360+
"${routeSpec.clusterName}-" + properties.loadBalancing.trafficSplitting
361+
.aggregateClusterPostfix,
362362
routeSpec.clusterWeights.secondary
363363
)
364364
)
365365
}
366-
367366
is StandardRouteSpecification -> {
368367
this.setCluster(routeSpec.clusterName)
369368
}

envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/EnvoySnapshotFactoryTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import pl.allegro.tech.servicemesh.envoycontrol.utils.createEndpoints
5151
class EnvoySnapshotFactoryTest {
5252
companion object {
5353
const val MAIN_CLUSTER_NAME = "service-name-2"
54-
const val SECONDARY_CLUSTER_NAME = "service-name-2-sec"
55-
const val AGGREGATE_CLUSTER_NAME = "service-name-2-agg"
54+
const val SECONDARY_CLUSTER_NAME = "service-name-2-secondary"
55+
const val AGGREGATE_CLUSTER_NAME = "service-name-2-aggregate"
5656
const val SERVICE_NAME_2 = "service-name-2"
5757
}
5858

envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/metrics/ThreadPoolMetricTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package pl.allegro.tech.servicemesh.envoycontrol.metrics
22

33
import io.micrometer.core.instrument.simple.SimpleMeterRegistry
44
import org.assertj.core.api.Assertions.assertThat
5+
import org.junit.jupiter.api.Disabled
56
import org.junit.jupiter.api.Test
67
import pl.allegro.tech.servicemesh.envoycontrol.ControlPlane
78
import pl.allegro.tech.servicemesh.envoycontrol.EnvoyControlProperties
89
import pl.allegro.tech.servicemesh.envoycontrol.server.ExecutorType
910
import reactor.core.publisher.Flux
1011

12+
1113
class ThreadPoolMetricTest {
1214

1315
@Test

envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactoryTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal class EnvoyEndpointsFactoryTest {
5757

5858
private val serviceName = "service-one"
5959

60-
private val secondaryClusterName = "service-one-sec"
60+
private val secondaryClusterName = "service-one-secondary"
6161

6262
private val serviceName2 = "service-two"
6363

envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/TestData.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const val CLUSTER_NAME = "cluster-name"
1313
const val CLUSTER_NAME1 = "cluster-1"
1414
const val CLUSTER_NAME2 = "cluster-2"
1515
const val MAIN_CLUSTER_NAME = "cluster-1"
16-
const val SECONDARY_CLUSTER_NAME = "cluster-1-sec"
17-
const val AGGREGATE_CLUSTER_NAME = "cluster-1-agg"
16+
const val SECONDARY_CLUSTER_NAME = "cluster-1-secondary"
17+
const val AGGREGATE_CLUSTER_NAME = "cluster-1-aggregate"
1818
const val TRAFFIC_SPLITTING_FORCE_TRAFFIC_ZONE = "dc2"
1919
const val CURRENT_ZONE = "dc1"
2020

envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/WeightedClustersRoutingTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import pl.allegro.tech.servicemesh.envoycontrol.config.consul.ConsulMultiCluster
1010
import pl.allegro.tech.servicemesh.envoycontrol.config.envoy.EnvoyExtension
1111
import pl.allegro.tech.servicemesh.envoycontrol.config.envoycontrol.EnvoyControlClusteredExtension
1212
import pl.allegro.tech.servicemesh.envoycontrol.config.service.EchoServiceExtension
13-
import pl.allegro.tech.servicemesh.envoycontrol.logger
1413
import verifyCallsCountCloseTo
1514
import verifyCallsCountGreaterThan
1615
import verifyIsReachable
1716
import java.time.Duration
1817

1918
class WeightedClustersRoutingTest {
2019
companion object {
21-
val logger by logger()
2220
private const val forceTrafficZone = "dc2"
2321

2422
private val properties = mapOf(

envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/trafficsplitting/WeightedClustersServiceTagRoutingTest.kt

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)