Skip to content

Commit

Permalink
Fixed traffic splitting for endpoints with tag metadata - Rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
nastassia-dailidava committed Dec 22, 2023
1 parent b018abf commit e7ad8f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ class EnvoySnapshotFactory(
): RouteSpecification {
val trafficSplitting = properties.loadBalancing.trafficSplitting
val weights = trafficSplitting.serviceByWeightsProperties[serviceName]
val enabledForDependency = globalSnapshot.endpoints[clusterName]?.let {
endpointsFactory.filterEndpoints(it, settings.routingPolicy)
}?.endpointsList?.any { e -> trafficSplitting.zoneName == e.locality.zone && e.lbEndpointsCount > 0 } ?: false
val enabledForDependency = globalSnapshot.endpoints[clusterName]?.endpointsList
?.any { e -> trafficSplitting.zoneName == e.locality.zone }
?: false
return if (weights != null && enabledForDependency) {
logger.debug(
"Building traffic splitting route spec, weights: $weights, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ fun CallStats.verifyCallsCountCloseTo(service: EchoServiceExtension, expectedCou
return this
}

fun CallStats.verifyCallsCountEquals(service: EchoServiceExtension, expectedCount: Int): CallStats {
Assertions.assertThat(this.hits(service)).isEqualTo(expectedCount)
return this
}

fun CallStats.verifyCallsCountGreaterThan(service: EchoServiceExtension, hits: Int): CallStats {
Assertions.assertThat(this.hits(service)).isGreaterThan(hits)
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,19 @@ class WeightedClustersRoutingTest {
.verifyCallsCountCloseTo(upstreamServiceDC1, 90)
.verifyCallsCountGreaterThan(upstreamServiceDC2, 1)
}

@Test
fun `should route traffic according to weights with service tag`() {
consul.serverFirst.operations.registerServiceWithEnvoyOnEgress(echoEnvoyDC1, name = serviceName)

consul.serverFirst.operations.registerService(upstreamServiceDC1, name = upstreamServiceName, tags = listOf("tag"))
echoEnvoyDC1.verifyIsReachable(upstreamServiceDC1, upstreamServiceName)

consul.serverSecond.operations.registerService(upstreamServiceDC2, name = upstreamServiceName, tags = listOf("tag"))
echoEnvoyDC1.verifyIsReachable(upstreamServiceDC2, upstreamServiceName)

echoEnvoyDC1.callUpstreamServiceRepeatedly(upstreamServiceDC1, upstreamServiceDC2, tag = "tag")
.verifyCallsCountCloseTo(upstreamServiceDC1, 90)
.verifyCallsCountGreaterThan(upstreamServiceDC2, 1)
}
}

This file was deleted.

0 comments on commit e7ad8f0

Please sign in to comment.