Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Weighted Invalid Backend Logic #4911

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
36 changes: 15 additions & 21 deletions internal/xds/translator/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,39 +244,33 @@
Weight: &wrapperspb.UInt32Value{Value: backendWeights.Invalid},
}
weightedClusters = append(weightedClusters, invalidCluster)
return &routev3.RouteAction{
// Intentionally route to a non-existent cluster and return a 500 error when it is not found
ClusterNotFoundResponseCode: routev3.RouteAction_INTERNAL_SERVER_ERROR,
ClusterSpecifier: &routev3.RouteAction_WeightedClusters{
WeightedClusters: &routev3.WeightedCluster{
Clusters: weightedClusters,
},
},
}
}

for _, destinationSetting := range settings {
if destinationSetting.Filters != nil {
if len(destinationSetting.Endpoints) > 0 {
validCluster := &routev3.WeightedCluster_ClusterWeight{
Name: backendWeights.Name,
Weight: &wrapperspb.UInt32Value{Value: *destinationSetting.Weight},
}

if len(destinationSetting.Filters.AddRequestHeaders) > 0 {
validCluster.RequestHeadersToAdd = append(validCluster.RequestHeadersToAdd, buildXdsAddedHeaders(destinationSetting.Filters.AddRequestHeaders)...)
}
if destinationSetting.Filters != nil {
if len(destinationSetting.Filters.AddRequestHeaders) > 0 {
validCluster.RequestHeadersToAdd = append(validCluster.RequestHeadersToAdd, buildXdsAddedHeaders(destinationSetting.Filters.AddRequestHeaders)...)
}

if len(destinationSetting.Filters.RemoveRequestHeaders) > 0 {
validCluster.RequestHeadersToRemove = append(validCluster.RequestHeadersToRemove, destinationSetting.Filters.RemoveRequestHeaders...)
}
if len(destinationSetting.Filters.RemoveRequestHeaders) > 0 {
validCluster.RequestHeadersToRemove = append(validCluster.RequestHeadersToRemove, destinationSetting.Filters.RemoveRequestHeaders...)
}

Check warning on line 263 in internal/xds/translator/route.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/route.go#L262-L263

Added lines #L262 - L263 were not covered by tests

if len(destinationSetting.Filters.AddResponseHeaders) > 0 {
validCluster.ResponseHeadersToAdd = append(validCluster.ResponseHeadersToAdd, buildXdsAddedHeaders(destinationSetting.Filters.AddResponseHeaders)...)
}
if len(destinationSetting.Filters.AddResponseHeaders) > 0 {
validCluster.ResponseHeadersToAdd = append(validCluster.ResponseHeadersToAdd, buildXdsAddedHeaders(destinationSetting.Filters.AddResponseHeaders)...)
}

Check warning on line 267 in internal/xds/translator/route.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/route.go#L266-L267

Added lines #L266 - L267 were not covered by tests

if len(destinationSetting.Filters.RemoveResponseHeaders) > 0 {
validCluster.ResponseHeadersToRemove = append(validCluster.ResponseHeadersToRemove, destinationSetting.Filters.RemoveResponseHeaders...)
if len(destinationSetting.Filters.RemoveResponseHeaders) > 0 {
validCluster.ResponseHeadersToRemove = append(validCluster.ResponseHeadersToRemove, destinationSetting.Filters.RemoveResponseHeaders...)
}

Check warning on line 271 in internal/xds/translator/route.go

View check run for this annotation

Codecov / codecov/patch

internal/xds/translator/route.go#L270-L271

Added lines #L270 - L271 were not covered by tests
}

weightedClusters = append(weightedClusters, validCluster)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
clusters:
- name: invalid-backend-cluster
weight: 1
- name: first-route-dest
weight: 1
1 change: 1 addition & 0 deletions release-notes/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bug fixes: |
Fixed reference grant from EnvoyExtensionPolicy to referenced ext-proc backend not respected
Fixed BackendTrafficPolicy not applying to Gateway Route when Route has a Request Timeout defined
Fixed proxies connected to the secondary EG were not receiving xDS configuration
Fixed traffic splitting when some backends were invalid

# Enhancements that improve performance.
performance improvements: |
Expand Down
Loading