Skip to content

Commit

Permalink
give magic number var a name
Browse files Browse the repository at this point in the history
  • Loading branch information
missylbytes committed Mar 6, 2023
1 parent 0057e35 commit 4b83b07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions agent/xds/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,18 +896,19 @@ func (s *ResourceGenerator) makeRouteActionForSplitter(
return nil, fmt.Errorf("number of clusters in splitter must be > 0; got %d", len(clusters))
}

if 10000 < totalWeight {
clusters[0].Weight.Value += uint32(totalWeight - 10000)
envoyWeightScale := 10000
if envoyWeightScale < totalWeight {
clusters[0].Weight.Value += uint32(totalWeight - envoyWeightScale)
} else {
clusters[0].Weight.Value += uint32(10000 - totalWeight)
clusters[0].Weight.Value += uint32(envoyWeightScale - totalWeight)
}

return &envoy_route_v3.Route_Route{
Route: &envoy_route_v3.RouteAction{
ClusterSpecifier: &envoy_route_v3.RouteAction_WeightedClusters{
WeightedClusters: &envoy_route_v3.WeightedCluster{
Clusters: clusters,
TotalWeight: makeUint32Value(10000), // scaled up 100%
TotalWeight: makeUint32Value(envoyWeightScale), // scaled up 100%
},
},
},
Expand Down

0 comments on commit 4b83b07

Please sign in to comment.