Skip to content

Commit

Permalink
test_ring_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
KSmigielski committed Mar 13, 2024
1 parent 07c4254 commit 6685adf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class EnvoyClustersFactory(
).setServiceName(clusterConfiguration.serviceName)
)
.setLbPolicy(properties.loadBalancing.policy)
// .setLbPolicy(Cluster.LbPolicy.RING_HASH)
// TODO: if we want to have multiple memory-backend instances of ratelimit
// then we should have consistency hashed lb
// setting RING_HASH here is not enough (but it's probably required so I leave it here)
Expand All @@ -507,6 +508,10 @@ class EnvoyClustersFactory(
// )
.configureLbSubsets()

if (clusterConfiguration.serviceName.startsWith("service-mesh")) {
cluster.setLbPolicy(Cluster.LbPolicy.RING_HASH)
}

cluster.setCommonHttpProtocolOptions(httpProtocolOptions)
cluster.setCircuitBreakers(allThresholds)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,15 @@ class EnvoyEgressRoutesFactory(
if (properties.egress.hostHeaderRewriting.enabled && routeSpecification.settings.rewriteHostHeader) {
routeAction.hostRewriteHeader = properties.egress.hostHeaderRewriting.customHostHeader
}
if (routeSpecification.clusterName.startsWith("service-mesh")) {
routeAction.addHashPolicy(
RouteAction.HashPolicy.newBuilder()
.setHeader(
RouteAction.HashPolicy.Header.newBuilder()
.setHeaderName("x-hashing-key")
)
)
}

return routeAction
}
Expand Down

0 comments on commit 6685adf

Please sign in to comment.