-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented possibility of traffic splitting configuration #397
Conversation
...-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/utils/ClusterNames.kt
Outdated
Show resolved
Hide resolved
...core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt
Outdated
Show resolved
Hide resolved
...l/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt
Outdated
Show resolved
Hide resolved
...l/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt
Outdated
Show resolved
Hide resolved
.../pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt
Outdated
Show resolved
Hide resolved
.../pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt
Outdated
Show resolved
Hide resolved
.../pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt
Outdated
Show resolved
Hide resolved
.../pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt
Outdated
Show resolved
Hide resolved
.../pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt
Outdated
Show resolved
Hide resolved
...re/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt
Outdated
Show resolved
Hide resolved
…ck using aggregate cluster| fixed tests #292
@@ -393,7 +493,7 @@ class EnvoyClustersFactory( | |||
) | |||
) | |||
} | |||
).setServiceName(clusterConfiguration.serviceName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clusterLoadAssignment: ClusterLoadAssignment? | ||
): Boolean { | ||
val trafficSplitting = properties.loadBalancing.trafficSplitting | ||
val trafficSplitEnabled = trafficSplitting.serviceByWeightsProperties.containsKey(serviceName) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to check if dependencies contains this cluster? IMO it is unnecessary, because we create clusters for each dependency
.onEach { logger.debug("Traffic splitting is enabled for cluster: ${it.clusterName}") } | ||
.mapNotNull { routeSpec -> | ||
clusterLoadAssignments[routeSpec.clusterName]?.let { assignment -> | ||
ClusterLoadAssignment.newBuilder(assignment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of clearing all endpoints and adding the proper ones after, it can be filtered previously and added only the valid endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ClusterLoadAssignment.Builder
doesn't allow to set list of endpoints. Because of that, we have to clear them, before we add new ones.
@@ -337,6 +343,37 @@ class EnvoyEgressRoutesFactory( | |||
|
|||
return routeAction | |||
} | |||
|
|||
private fun RouteAction.Builder.setCluster(routeSpec: RouteSpecification): RouteAction.Builder { | |||
val hasWeightsConfig = routeSpec.clusterWeights.keys.containsAll(listOf("main", "secondary")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This main and secondary could be a some static constant or clusterWeights should have properties like a main and secondary instead of being a map
) | ||
this.setWeightedClusters( | ||
WeightedCluster.newBuilder() | ||
.withClusterWeight(routeSpec.clusterName, routeSpec.clusterWeights["main"]!!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add only main and secondar, we should not use containsAll during creation of hasWeightsConfig - there should be used an equal operator
) | ||
} | ||
allServicesRoutes + definedServicesRoutes | ||
} | ||
} | ||
} | ||
|
||
private fun getTrafficSplittingWeights( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this PR, i saw two or three simillar functions
@@ -154,6 +155,11 @@ class CanaryProperties { | |||
var headerValue = "1" | |||
} | |||
|
|||
class TrafficSplittingProperties { | |||
var zoneName = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is zoneName? Is it GCP, or gcp/west and gcp/central?. If the second option then LoadBalancingProperties should have a list or map of trafficsplitting properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is gcp-central. For now there is no requirement to support more then one zone, and supporting multiple will make code unnecessary complex. So I think it is good, to leave it as it is
@@ -375,5 +399,6 @@ data class ClusterConfiguration( | |||
class RouteSpecification( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of adding a clusterWeight Property, we should create WeightedRouteSpecification? It will simplify some code and we coud get rid of some checks if this map contains keys like main and secondary.
92f3c6e
to
637b507
Compare
Added logs Ignored failing test #292
141574d
to
832138e
Compare
# Conflicts: # CHANGELOG.md
74f7afb
to
83ebfc5
Compare
@@ -91,7 +90,10 @@ class EnvoyEndpointsFactory( | |||
.addAllEndpoints(assignment.endpointsList?.filter { e -> | |||
e.locality.zone == properties.loadBalancing.trafficSplitting.zoneName | |||
}) | |||
.setClusterName(getSecondaryClusterName(routeSpec.clusterName)) | |||
.setClusterName( | |||
"${routeSpec.clusterName}-" + properties.loadBalancing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to hide this under the function(like it was before), it is used few times - getSecondaryClusterName this can have second param - config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.