Skip to content

Commit

Permalink
added service name to eds config #292
Browse files Browse the repository at this point in the history
  • Loading branch information
nastassia-dailidava committed Sep 25, 2023
1 parent 41c0c9b commit ade122f
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class EnvoySnapshotFactory(
globalSnapshot: GlobalSnapshot
): Collection<RouteSpecification> {
val definedServicesRoutes = group.proxySettings.outgoing.getServiceDependencies().map {
getTrafficSplittingRouteSpecification(
buildRouteSpecification(
clusterName = it.service,
routeDomains = listOf(it.service) + getServiceWithCustomDomain(it.service),
settings = it.settings,
Expand All @@ -199,11 +199,10 @@ class EnvoySnapshotFactory(
is ServicesGroup -> {
definedServicesRoutes
}

is AllServicesGroup -> {
val servicesNames = group.proxySettings.outgoing.getServiceDependencies().map { it.service }.toSet()
val allServicesRoutes = globalSnapshot.allServicesNames.subtract(servicesNames).map {
getTrafficSplittingRouteSpecification(
buildRouteSpecification(
clusterName = it,
routeDomains = listOf(it) + getServiceWithCustomDomain(it),
settings = group.proxySettings.outgoing.defaultServiceSettings,
Expand All @@ -216,7 +215,7 @@ class EnvoySnapshotFactory(
}
}

private fun getTrafficSplittingRouteSpecification(
private fun buildRouteSpecification(
clusterName: String,
routeDomains: List<String>,
settings: DependencySettings,
Expand All @@ -228,11 +227,11 @@ class EnvoySnapshotFactory(
val enabledForDependency = globalSnapshot.endpoints[clusterName]?.endpointsList
?.any { e -> trafficSplitting.zoneName == e.locality.zone }
?: false
logger.debug(
"Building route spec weights: $weights, enabledForDependency: $enabledForDependency, " +
"serviceName: $serviceName, clusterName: $clusterName"
)
return if (weights != null && enabledForDependency) {
logger.debug(
"Building traffic splitting route spec, weights: $weights, " +
"serviceName: $serviceName, clusterName: $clusterName, "
)
WeightRouteSpecification(
clusterName,
routeDomains,
Expand Down Expand Up @@ -341,9 +340,7 @@ class EnvoySnapshotFactory(
listenersVersion = version.listeners,
routes = routes,
routesVersion = version.routes
).also {
logger.debug("Snapshot for group: $it")
}
)
}

private fun createRoutesWhenUsingTransparentProxy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class CanaryProperties {
class TrafficSplittingProperties {
var zoneName = ""
var serviceByWeightsProperties: Map<String, ZoneWeights> = mapOf()
var secondaryClusterPostfix = "sec"
var aggregateClusterPostfix = "agg"
var secondaryClusterPostfix = "secondary"
var aggregateClusterPostfix = "aggregate"
}

class ZoneWeights {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class EnvoyEndpointsFactory(
e.locality.zone == properties.loadBalancing.trafficSplitting.zoneName
})
.setClusterName(
"${routeSpec.clusterName}-" +
properties.loadBalancing.trafficSplitting.secondaryClusterPostfix
"${routeSpec.clusterName}-" + properties.loadBalancing
.trafficSplitting.secondaryClusterPostfix
)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,12 @@ class EnvoyEgressRoutesFactory(
WeightedCluster.newBuilder()
.withClusterWeight(routeSpec.clusterName, routeSpec.clusterWeights.main)
.withClusterWeight(
"${routeSpec.clusterName}-" +
properties.loadBalancing.trafficSplitting.aggregateClusterPostfix,
"${routeSpec.clusterName}-" + properties.loadBalancing.trafficSplitting
.aggregateClusterPostfix,
routeSpec.clusterWeights.secondary
)
)
}

is StandardRouteSpecification -> {
this.setCluster(routeSpec.clusterName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import pl.allegro.tech.servicemesh.envoycontrol.utils.createEndpoints
class EnvoySnapshotFactoryTest {
companion object {
const val MAIN_CLUSTER_NAME = "service-name-2"
const val SECONDARY_CLUSTER_NAME = "service-name-2-sec"
const val AGGREGATE_CLUSTER_NAME = "service-name-2-agg"
const val SECONDARY_CLUSTER_NAME = "service-name-2-secondary"
const val AGGREGATE_CLUSTER_NAME = "service-name-2-aggregate"
const val SERVICE_NAME_2 = "service-name-2"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package pl.allegro.tech.servicemesh.envoycontrol.metrics

import io.micrometer.core.instrument.simple.SimpleMeterRegistry
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import pl.allegro.tech.servicemesh.envoycontrol.ControlPlane
import pl.allegro.tech.servicemesh.envoycontrol.EnvoyControlProperties
import pl.allegro.tech.servicemesh.envoycontrol.server.ExecutorType
import reactor.core.publisher.Flux


class ThreadPoolMetricTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class EnvoyEndpointsFactoryTest {

private val serviceName = "service-one"

private val secondaryClusterName = "service-one-sec"
private val secondaryClusterName = "service-one-secondary"

private val serviceName2 = "service-two"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const val CLUSTER_NAME = "cluster-name"
const val CLUSTER_NAME1 = "cluster-1"
const val CLUSTER_NAME2 = "cluster-2"
const val MAIN_CLUSTER_NAME = "cluster-1"
const val SECONDARY_CLUSTER_NAME = "cluster-1-sec"
const val AGGREGATE_CLUSTER_NAME = "cluster-1-agg"
const val SECONDARY_CLUSTER_NAME = "cluster-1-secondary"
const val AGGREGATE_CLUSTER_NAME = "cluster-1-aggregate"
const val TRAFFIC_SPLITTING_FORCE_TRAFFIC_ZONE = "dc2"
const val CURRENT_ZONE = "dc1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ 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.logger
import verifyCallsCountCloseTo
import verifyCallsCountGreaterThan
import verifyIsReachable
import java.time.Duration

class WeightedClustersRoutingTest {
companion object {
val logger by logger()
private const val forceTrafficZone = "dc2"

private val properties = mapOf(
Expand Down

This file was deleted.

0 comments on commit ade122f

Please sign in to comment.