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

Gateway API: fix bug with routes having multiple listener refs #4558

Merged
merged 2 commits into from
Jun 6, 2022
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
1 change: 1 addition & 0 deletions changelogs/unreleased/4558-skriss-small.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gateway API: fixes a bug where routes with multiple parent refs to listeners would not attach to all listeners correctly.
4 changes: 3 additions & 1 deletion internal/dag/gatewayapi_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,9 @@ func routeSelectsGatewayListener(gateway *gatewayapi_v1alpha2.Gateway, listener
}

// section name specified: it must match the listener name
return *ref.SectionName == listener.Name
if *ref.SectionName == listener.Name {
return true
}
}
}

Expand Down
16 changes: 16 additions & 0 deletions internal/dag/gatewayapi_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,22 @@ func TestRouteSelectsGatewayListener(t *testing.T) {
listener: gatewayapi_v1alpha2.Listener{Name: *gatewayapi.SectionNamePtr("http-listener")},
want: false,
},
"multiple parentRefs with section names specified, first listener": {
routeParentRefs: []gatewayapi_v1alpha2.ParentRef{
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "listener-1"),
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "listener-2"),
},
listener: gatewayapi_v1alpha2.Listener{Name: *gatewayapi.SectionNamePtr("listener-1")},
want: true,
},
"multiple parentRefs with section names specified, second listener": {
routeParentRefs: []gatewayapi_v1alpha2.ParentRef{
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "listener-1"),
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "listener-2"),
},
listener: gatewayapi_v1alpha2.Listener{Name: *gatewayapi.SectionNamePtr("listener-2")},
want: true,
},
}

for name, tc := range tests {
Expand Down