Skip to content

Commit

Permalink
Fix binding to multiple listeners with empty section name (#730)
Browse files Browse the repository at this point in the history
Problem: If an HTTPRoute has a parentRef with an empty section name,
and the referenced gateway has multiple valid listeners, the route would
only bind to the first listener.

Solution: Attempt to bind to every valid listener in the referenced Gateway.
  • Loading branch information
kate-osborn authored Jun 9, 2023
1 parent 77a9357 commit e74a5c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/state/graph/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func tryToAttachRouteToListeners(

attached := false
for _, l := range validListeners {
attached = attached || bind(l)
attached = bind(l) || attached
}

if !attached {
Expand Down
10 changes: 10 additions & 0 deletions internal/state/graph/httproute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ func TestBindRouteToListeners(t *testing.T) {
Valid: true,
Listeners: map[string]*Listener{
"listener-80-1": createListener("listener-80-1"),
"listener-80-2": createModifiedListener("listener-80-2", func(l *Listener) {
l.Source.Hostname = nil
}),
},
},
expectedSectionNameRefs: []ParentRef{
Expand All @@ -761,6 +764,7 @@ func TestBindRouteToListeners(t *testing.T) {
Attached: true,
AcceptedHostnames: map[string][]string{
"listener-80-1": {"foo.example.com"},
"listener-80-2": {"foo.example.com"},
},
},
},
Expand All @@ -771,6 +775,12 @@ func TestBindRouteToListeners(t *testing.T) {
client.ObjectKeyFromObject(hr): routeWithEmptySectionName,
}
}),
"listener-80-2": createModifiedListener("listener-80-2", func(l *Listener) {
l.Routes = map[types.NamespacedName]*Route{
client.ObjectKeyFromObject(hr): routeWithEmptySectionName,
}
l.Source.Hostname = nil
}),
},
name: "section name is empty",
},
Expand Down

0 comments on commit e74a5c4

Please sign in to comment.