diff --git a/internal/state/graph/httproute.go b/internal/state/graph/httproute.go index 7124d4b2ef..d00b7878d4 100644 --- a/internal/state/graph/httproute.go +++ b/internal/state/graph/httproute.go @@ -338,7 +338,7 @@ func tryToAttachRouteToListeners( attached := false for _, l := range validListeners { - attached = attached || bind(l) + attached = bind(l) || attached } if !attached { diff --git a/internal/state/graph/httproute_test.go b/internal/state/graph/httproute_test.go index afbb108883..2e62d59232 100644 --- a/internal/state/graph/httproute_test.go +++ b/internal/state/graph/httproute_test.go @@ -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{ @@ -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"}, }, }, }, @@ -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", },