mirror of https://github.com/hashicorp/consul
Backport of NET-6943 - Replace usage of deprecated Envoy field envoy.config.router.v3.WeightedCluster.total_weight. into release/1.15.x (#20059)
NET-6943 - Replace usage of deprecated Envoy field envoy.config.router.v3.WeightedCluster.total_weight. (#20011) Co-authored-by: John Murret <john.murret@hashicorp.com>pull/20069/head
parent
e13a4c2e09
commit
ca07c058b6
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
connect: replace usage of deprecated Envoy field `envoy.config.router.v3.WeightedCluster.total_weight`.
|
||||
```
|
|
@ -867,7 +867,6 @@ func (s *ResourceGenerator) makeRouteActionForSplitter(
|
|||
forMeshGateway bool,
|
||||
) (*envoy_route_v3.Route_Route, error) {
|
||||
clusters := make([]*envoy_route_v3.WeightedCluster_ClusterWeight, 0, len(splits))
|
||||
totalWeight := 0
|
||||
for _, split := range splits {
|
||||
nextNode := chain.Nodes[split.NextNode]
|
||||
|
||||
|
@ -884,7 +883,6 @@ func (s *ResourceGenerator) makeRouteActionForSplitter(
|
|||
// The smallest representable weight is 1/10000 or .01% but envoy
|
||||
// deals with integers so scale everything up by 100x.
|
||||
weight := int(split.Weight * 100)
|
||||
totalWeight += weight
|
||||
cw := &envoy_route_v3.WeightedCluster_ClusterWeight{
|
||||
Weight: makeUint32Value(weight),
|
||||
Name: targetOptions.clusterName,
|
||||
|
@ -900,19 +898,11 @@ func (s *ResourceGenerator) makeRouteActionForSplitter(
|
|||
return nil, fmt.Errorf("number of clusters in splitter must be > 0; got %d", len(clusters))
|
||||
}
|
||||
|
||||
envoyWeightScale := 10000
|
||||
if envoyWeightScale < totalWeight {
|
||||
clusters[0].Weight.Value += uint32(totalWeight - envoyWeightScale)
|
||||
} else {
|
||||
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(envoyWeightScale), // scaled up 100%
|
||||
Clusters: clusters,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
"name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 450
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
},
|
||||
"hashPolicy": [
|
||||
{
|
||||
|
@ -64,4 +63,4 @@
|
|||
],
|
||||
"typeUrl": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
|
||||
"nonce": "00000001"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -359,8 +359,7 @@
|
|||
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -84,8 +84,7 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
"name": "db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 450
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
},
|
||||
"hashPolicy": [
|
||||
{
|
||||
|
@ -65,4 +64,4 @@
|
|||
],
|
||||
"typeUrl": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
|
||||
"nonce": "00000001"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
"name": "v2.db.default.dc2.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 5000
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,8 +360,7 @@
|
|||
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -360,8 +360,7 @@
|
|||
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -85,8 +85,7 @@
|
|||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
"name": "exported~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 4000
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
"name": "v2.db.default.dc2.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 5000
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -350,8 +350,7 @@
|
|||
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -417,4 +416,4 @@
|
|||
],
|
||||
"typeUrl": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
|
||||
"nonce": "00000001"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,8 +349,7 @@
|
|||
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
|
||||
"weight": 50
|
||||
}
|
||||
],
|
||||
"totalWeight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -416,4 +415,4 @@
|
|||
],
|
||||
"typeUrl": "type.googleapis.com/envoy.config.route.v3.RouteConfiguration",
|
||||
"nonce": "00000001"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,8 +174,7 @@
|
|||
"name": "backend2.default.dc1.internal.domain.consul",
|
||||
"weight": 5000
|
||||
}
|
||||
],
|
||||
"total_weight": 10000
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue