Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/kgateway/endpoints/prioritize.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ func prioritizeWithLbInfo(logger *slog.Logger, ep ir.EndpointsForBackend, lbInfo
return cla
}

// lbWeight returns the per-endpoint load balancing weight, treating an unset
// weight as 1, matching Envoy's default (LbEndpoint.load_balancing_weight).
func lbWeight(ep *envoyendpointv3.LbEndpoint) uint32 {
if w := ep.GetLoadBalancingWeight(); w != nil {
return w.GetValue()
}
return 1
}

// ensure we don't send invalid endpoints to envoy and cause NACKs
func filterInvalidEps(eps []ir.EndpointWithMd) []ir.EndpointWithMd {
return istioslices.Filter(eps, func(ewm ir.EndpointWithMd) bool {
Expand All @@ -178,7 +187,7 @@ func getEndpoints(eps []ir.EndpointWithMd, lbinfo LoadBalancingInfo) []*envoyend
var weight uint32
for _, ep := range eps {
epsOut[0].LbEndpoints = append(epsOut[0].GetLbEndpoints(), ep.LbEndpoint)
weight += ep.LbEndpoint.GetLoadBalancingWeight().GetValue()
weight += lbWeight(ep.LbEndpoint)
}
// reset weight
if weight > 0 {
Expand Down Expand Up @@ -214,7 +223,7 @@ func applyFailoverPriorityPerLocality(
var weight uint32
for _, index := range priorityMap[priority] {
out[i].LbEndpoints = append(out[i].GetLbEndpoints(), eps[index].LbEndpoint)
weight += eps[index].GetLoadBalancingWeight().GetValue()
weight += lbWeight(eps[index].LbEndpoint)
}
// reset weight
if weight > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Clusters:
socketAddress:
address: 1.1.1.1
portValue: 5000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-a_se-a.example.com_5000
type: STATIC
Expand All @@ -23,7 +22,6 @@ Clusters:
socketAddress:
address: 2.2.2.2
portValue: 9000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-b_se-b.example.com_9000
type: STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Clusters:
socketAddress:
address: 1.1.1.1
portValue: 5000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-a_se-a.example.com_5000
type: STATIC
Expand All @@ -23,7 +22,6 @@ Clusters:
socketAddress:
address: 2.2.2.2
portValue: 9000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-b_se-b.example.com_9000
type: STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Clusters:
socketAddress:
address: 1.1.1.1
portValue: 5000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-a_se-a.example.com_5000
type: STATIC
Expand All @@ -23,7 +22,6 @@ Clusters:
socketAddress:
address: 2.2.2.2
portValue: 9000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-b_se-b.example.com_9000
type: STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Clusters:
socketAddress:
address: 3.3.3.3
portValue: 9000
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_infra_se-c_se-c.infra.svc.cluster.local_9000
type: STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ endpoints:
socketAddress:
address: 10.244.1.12
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
- clusterName: kube_gwtest_reviews_8080
endpoints:
Expand All @@ -48,7 +47,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ endpoints:
socketAddress:
address: 10.244.1.12
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
- clusterName: kube_gwtest_reviews_8080
endpoints:
Expand All @@ -48,7 +47,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ endpoints:
socketAddress:
address: 10.244.1.12
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
- clusterName: kube_gwtest_reviews_8080
endpoints:
Expand All @@ -48,7 +47,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -51,7 +50,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -64,7 +62,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -77,7 +74,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -51,7 +50,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -64,7 +62,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -77,7 +74,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -40,7 +39,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -53,7 +51,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -66,7 +63,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -40,7 +39,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -53,7 +51,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -66,7 +63,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -50,7 +49,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -63,7 +61,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -76,7 +73,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
- clusterName: kube_gwtest_httpbin_9000
listeners:
Expand Down
1 change: 0 additions & 1 deletion pkg/kgateway/setup/testdata/istio_mtls/istio-svc-out.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
- clusterName: kube_gwtest_httpbin_9000
listeners:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 8080
loadBalancingWeight: 1
loadBalancingWeight: 1
listeners:
- address:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ clusters:
socketAddress:
address: 1.1.1.1
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
name: istio-se_gwtest_httpbin-se_se.example.com_80
type: STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ endpoints:
socketAddress:
address: 255.0.0.1
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
priority: 3
- lbEndpoints:
Expand All @@ -41,7 +40,6 @@ endpoints:
socketAddress:
address: 10.244.1.11
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -53,7 +51,6 @@ endpoints:
socketAddress:
address: 10.244.2.14
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -66,7 +63,6 @@ endpoints:
socketAddress:
address: 10.244.3.3
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r1
Expand All @@ -79,7 +75,6 @@ endpoints:
socketAddress:
address: 10.244.4.4
portValue: 80
loadBalancingWeight: 1
loadBalancingWeight: 1
locality:
region: r2
Expand Down
Loading
Loading