Skip to content
Open
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
43 changes: 29 additions & 14 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ func (t *Translator) ProcessGRPCRoutes(grpcRoutes []*gwapiv1.GRPCRoute, gateways
return relevantGRPCRoutes
}

// gatewayAcceptedMsg returns the message embedding the Gateway's generation
// so that a gateway-only update changes the message text and breaks the watchable DeepEqual gate
// observedGeneration stays as the route's own generation to remain spec-compliant.
func (t *Translator) gatewayMsg(gw *GatewayContext, base string) string {
if gw != nil && gw.GetGeneration() > 0 {
return fmt.Sprintf("%s (gateway generation: %d)", base, gw.GetGeneration())
}
return base
}

func (t *Translator) processHTTPRouteParentRefs(httpRoute *HTTPRouteContext, resources *resource.Resources, xdsIR resource.XdsIRMap) {
for _, parentRef := range httpRoute.ParentRefs {
// Need to compute Route rules within the parentRef loop because
Expand Down Expand Up @@ -190,7 +200,7 @@ func (t *Translator) processHTTPRouteParentRefs(httpRoute *HTTPRouteContext, res
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonNoMatchingListenerHostname,
"There were no hostname intersections between the HTTPRoute and this parent ref's Listener(s).",
t.gatewayMsg(parentRef.GetGateway(), "There were no hostname intersections between the HTTPRoute and this parent ref's Listener(s)."),
)
}

Expand All @@ -209,7 +219,7 @@ func (t *Translator) processHTTPRouteParentRefs(httpRoute *HTTPRouteContext, res
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRef.GetGateway(), "Route is accepted"),
)
}
}
Expand Down Expand Up @@ -924,7 +934,7 @@ func (t *Translator) processGRPCRouteParentRefs(grpcRoute *GRPCRouteContext, res
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonNoMatchingListenerHostname,
"There were no hostname intersections between the GRPCRoute and this parent ref's Listener(s).",
t.gatewayMsg(parentRef.GetGateway(), "There were no hostname intersections between the GRPCRoute and this parent ref's Listener(s)."),
)
}

Expand All @@ -938,7 +948,7 @@ func (t *Translator) processGRPCRouteParentRefs(grpcRoute *GRPCRouteContext, res
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRef.GetGateway(), "Route is accepted"),
)
}

Expand Down Expand Up @@ -1499,7 +1509,7 @@ func (t *Translator) processTLSRouteParentRefs(tlsRoute *TLSRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonNoMatchingListenerHostname,
"There were no hostname intersections between the TLSRoute and this parent ref's Listener(s).",
t.gatewayMsg(parentRef.GetGateway(), "There were no hostname intersections between the TLSRoute and this parent ref's Listener(s)."),
)
}

Expand All @@ -1518,7 +1528,7 @@ func (t *Translator) processTLSRouteParentRefs(tlsRoute *TLSRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRef.GetGateway(), "Route is accepted"),
)
}
}
Expand Down Expand Up @@ -1659,7 +1669,7 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRef.GetGateway(), "Route is accepted"),
)
}

Expand All @@ -1671,7 +1681,7 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonUnsupportedValue,
"Multiple routes on the same UDP listener",
t.gatewayMsg(parentRef.GetGateway(), "Multiple routes on the same UDP listener"),
)
}
}
Expand Down Expand Up @@ -1822,7 +1832,7 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRef.GetGateway(), "Route is accepted"),
)
}
if !accepted {
Expand All @@ -1833,7 +1843,7 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonUnsupportedValue,
"Multiple routes on the same TCP listener",
t.gatewayMsg(parentRef.GetGateway(), "Multiple routes on the same TCP listener"),
)
}

Expand Down Expand Up @@ -2259,7 +2269,7 @@ func (t *Translator) processAllowedListenersForParentRefs(
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonNoMatchingParent,
"No listeners match this parent ref",
t.gatewayMsg(parentRefCtx.GetGateway(), "No listeners match this parent ref"),
)
continue
}
Expand All @@ -2273,6 +2283,11 @@ func (t *Translator) processAllowedListenersForParentRefs(
}
}

var selectedGateway *GatewayContext
if len(selectedListeners) > 0 {
selectedGateway = selectedListeners[0].gateway
}

if len(allowedListeners) == 0 {
routeStatus := GetRouteStatus(routeContext)
status.SetRouteStatusCondition(routeStatus,
Expand All @@ -2281,7 +2296,7 @@ func (t *Translator) processAllowedListenersForParentRefs(
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
gwapiv1.RouteReasonNotAllowedByListeners,
"No listeners included by this parent ref allowed this attachment.",
t.gatewayMsg(selectedGateway, "No listeners included by this parent ref allowed this attachment."),
)
continue
}
Expand All @@ -2295,7 +2310,7 @@ func (t *Translator) processAllowedListenersForParentRefs(
gwapiv1.RouteConditionAccepted,
metav1.ConditionFalse,
"NoReadyListeners",
"There are no ready listeners for this parent ref",
t.gatewayMsg(parentRefCtx.GetGateway(), "There are no ready listeners for this parent ref"),
)
continue
}
Expand All @@ -2307,7 +2322,7 @@ func (t *Translator) processAllowedListenersForParentRefs(
gwapiv1.RouteConditionAccepted,
metav1.ConditionTrue,
gwapiv1.RouteReasonAccepted,
"Route is accepted",
t.gatewayMsg(parentRefCtx.GetGateway(), "Route is accepted"),
)
}
return relevantRoute
Expand Down
Loading