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
hc-github-team-consul-core 2024-01-02 11:32:30 -06:00 committed by GitHub
parent e13a4c2e09
commit ca07c058b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 21 additions and 41 deletions

3
.changelog/20011.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
connect: replace usage of deprecated Envoy field `envoy.config.router.v3.WeightedCluster.total_weight`.
```

View File

@ -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,
},
},
},

View File

@ -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"
}
}

View File

@ -359,8 +359,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 50
}
],
"totalWeight": 10000
]
}
}
},

View File

@ -84,8 +84,7 @@
}
]
}
],
"totalWeight": 10000
]
}
}
}

View File

@ -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"
}
}

View File

@ -27,8 +27,7 @@
"name": "v2.db.default.dc2.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 5000
}
],
"totalWeight": 10000
]
}
}
}

View File

@ -360,8 +360,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 50
}
],
"totalWeight": 10000
]
}
}
},

View File

@ -360,8 +360,7 @@
"name": "lil-bit-side.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 50
}
],
"totalWeight": 10000
]
}
}
},

View File

@ -85,8 +85,7 @@
}
]
}
],
"totalWeight": 10000
]
}
}
}

View File

@ -26,8 +26,7 @@
"name": "exported~db.default.dc1.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 4000
}
],
"totalWeight": 10000
]
}
}
},

View File

@ -26,8 +26,7 @@
"name": "v2.db.default.dc2.internal.11111111-2222-3333-4444-555555555555.consul",
"weight": 5000
}
],
"totalWeight": 10000
]
}
}
}

View File

@ -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"
}
}

View File

@ -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"
}
}

View File

@ -174,8 +174,7 @@
"name": "backend2.default.dc1.internal.domain.consul",
"weight": 5000
}
],
"total_weight": 10000
]
}
}
}