Skip to content

Commit

Permalink
Implemented possibility for configuring traffic splitting, and fallba…
Browse files Browse the repository at this point in the history
…ck using aggregate cluster #292
  • Loading branch information
nastassia-dailidava committed Aug 24, 2023
1 parent 2865fb2 commit b65015c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ class EnvoyClustersFactory(
): Collection<Cluster> {
return cluster?.let {
if (enableTrafficSplitting(serviceName, cluster.name, dependencies, clusterLoadAssignment)) {
logger.debug("Creating traffic splitting egress cluster config for ${cluster.name}, service: $serviceName")
logger.debug(
"Creating traffic splitting egress cluster config for ${cluster.name}, service: $serviceName")
createSetOfClustersForGroup(dependencySettings, cluster)
} else {
listOf(createClusterForGroup(dependencySettings, cluster))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package pl.allegro.tech.servicemesh.envoycontrol.utils

import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterConstants.AGGREGATE_CLUSTER_POSTFIX
import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterConstants.SECONDARY_CLUSTER_POSTFIX
import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterNames.AGGREGATE_CLUSTER_POSTFIX
import pl.allegro.tech.servicemesh.envoycontrol.utils.ClusterNames.SECONDARY_CLUSTER_POSTFIX

object ClusterConstants {
object ClusterNames {
const val SECONDARY_CLUSTER_POSTFIX= "secondary"
const val AGGREGATE_CLUSTER_POSTFIX= "aggregate"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ import pl.allegro.tech.servicemesh.envoycontrol.groups.Outgoing
import pl.allegro.tech.servicemesh.envoycontrol.groups.ProxySettings
import pl.allegro.tech.servicemesh.envoycontrol.groups.ServicesGroup
import pl.allegro.tech.servicemesh.envoycontrol.groups.with
import pl.allegro.tech.servicemesh.envoycontrol.services.ClusterState
import pl.allegro.tech.servicemesh.envoycontrol.services.Locality
import pl.allegro.tech.servicemesh.envoycontrol.services.MultiClusterState
import pl.allegro.tech.servicemesh.envoycontrol.services.ServiceInstance
import pl.allegro.tech.servicemesh.envoycontrol.services.ServiceInstances
import pl.allegro.tech.servicemesh.envoycontrol.services.ServicesState
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.ClusterConfiguration
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.EnvoySnapshotFactory
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.GlobalSnapshot
Expand All @@ -47,7 +41,6 @@ import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.EnvoyEg
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.EnvoyIngressRoutesFactory
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.ServiceTagMetadataGenerator
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.serviceDependencies
import java.util.concurrent.ConcurrentHashMap

class EnvoySnapshotFactoryTest {
companion object {
Expand Down Expand Up @@ -509,25 +502,6 @@ class EnvoySnapshotFactoryTest {
}
}

private fun createMultiClusterState(services: List<String>): List<MultiClusterState> {
return services
.map {
ClusterState(
ServicesState(
ConcurrentHashMap(
mutableMapOf(
it to ServiceInstances(
it,
setOf(ServiceInstance("id", setOf(), "localhost", 8080))
)
)
)
), Locality.LOCAL, it
)
}
.map { MultiClusterState(it) }
}

private fun createCluster(
defaultProperties: SnapshotProperties,
clusterName: String = CLUSTER_NAME,
Expand Down

0 comments on commit b65015c

Please sign in to comment.