Skip to content
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
4 changes: 2 additions & 2 deletions internal/dag/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2423,7 +2423,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) {
Spec: gatewayapi_v1beta1.HTTPRouteSpec{
CommonRouteSpec: gatewayapi_v1beta1.CommonRouteSpec{
ParentRefs: []gatewayapi_v1beta1.ParentReference{
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-listener"),
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-listener", 0),
},
},
Hostnames: []gatewayapi_v1beta1.Hostname{
Expand All @@ -2444,7 +2444,7 @@ func TestDAGInsertGatewayAPI(t *testing.T) {

CommonRouteSpec: gatewayapi_v1beta1.CommonRouteSpec{
ParentRefs: []gatewayapi_v1beta1.ParentReference{
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "https-listener"),
gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "https-listener", 0),
},
},
Hostnames: []gatewayapi_v1beta1.Hostname{
Expand Down
13 changes: 10 additions & 3 deletions internal/dag/gatewayapi_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,21 @@ func (p *GatewayAPIProcessor) getListenersForRouteParentRef(
var selectedListeners []*listenerInfo
for _, validListener := range validListeners {
// We've already verified the parent ref is for this Gateway,
// now check if it has a listener name specified.
if routeParentRef.SectionName == nil || *routeParentRef.SectionName == validListener.listener.Name {
// now check if it has a listener name and port specified.
// Both need to match the listener if specified.
if (routeParentRef.SectionName == nil || *routeParentRef.SectionName == validListener.listener.Name) &&
(routeParentRef.Port == nil || *routeParentRef.Port == validListener.listener.Port) {
selectedListeners = append(selectedListeners, validListener)
}
}

if len(selectedListeners) == 0 {
routeParentStatusAccessor.AddCondition(gatewayapi_v1beta1.RouteConditionAccepted, metav1.ConditionFalse, status.ReasonListenersNotReady, "No listeners are ready for this parent ref")
routeParentStatusAccessor.AddCondition(
gatewayapi_v1beta1.RouteConditionAccepted,
metav1.ConditionFalse,
gatewayapi_v1beta1.RouteReasonNoMatchingParent,
"No listeners match this parent ref",
)
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions internal/dag/gatewayapi_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) {
},

"section name specified, matches first listener": {
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-1"),
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-1", 0),
routeNamespace: "projectcontour",
routeKind: "HTTPRoute",
listeners: []*listenerInfo{
Expand Down Expand Up @@ -602,7 +602,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) {
want: []int{0},
},
"section name specified, matches second listener": {
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-2"),
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "http-2", 0),
routeNamespace: "projectcontour",
routeKind: "HTTPRoute",
listeners: []*listenerInfo{
Expand Down Expand Up @@ -632,7 +632,7 @@ func TestGetListenersForRouteParentRef(t *testing.T) {
want: []int{1},
},
"section name specified, does not match listener": {
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "different-listener-name"),
routeParentRef: gatewayapi.GatewayListenerParentRef("projectcontour", "contour", "different-listener-name", 0),
routeNamespace: "projectcontour",
routeKind: "HTTPRoute",
listeners: []*listenerInfo{
Expand Down
Loading