Skip to content
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

Merged
merged 22 commits into from
Oct 4, 2023

Conversation

nastassia-dailidava
Copy link
Contributor

No description provided.

…ck using aggregate cluster| Added tests and fixed review issues #292
…ck using aggregate cluster| Added tests and fixed review issues #292
…ck using aggregate cluster| Added tests and fixed review issues #292
KSmigielski
KSmigielski previously approved these changes Aug 25, 2023
@@ -393,7 +493,7 @@ class EnvoyClustersFactory(
)
)
}
).setServiceName(clusterConfiguration.serviceName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it deleted?

Copy link
Contributor

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) &&
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor

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"))
Copy link
Contributor

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"]!!)
Copy link
Contributor

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(
Copy link
Contributor

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 = ""
Copy link
Contributor

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

Copy link
Contributor

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(
Copy link
Contributor

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.

Ferdudas97
Ferdudas97 previously approved these changes Sep 4, 2023
Ferdudas97
Ferdudas97 previously approved these changes Sep 7, 2023
Added logs
Ignored failing test #292
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nastassia-dailidava nastassia-dailidava merged commit 2b63f78 into master Oct 4, 2023
5 checks passed
@nastassia-dailidava nastassia-dailidava deleted the flex-roadmap-traffic-splitting branch October 4, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants