Skip to content

Commit

Permalink
Always set ResolvedRefs
Browse files Browse the repository at this point in the history
Incorporates check added by kubernetes-sigs/gateway-api#1668

Signed-off-by: Arko Dasgupta <[email protected]>
  • Loading branch information
arkodg committed Mar 15, 2023
1 parent 1661a89 commit f219076
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/gatewayapi/contexts.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,3 +670,15 @@ func (r *RouteParentContext) IsAccepted(route RouteContext) bool {

return false
}

func (r *RouteParentContext) HasUnResolvedRefs(route RouteContext) bool {
var conditions []metav1.Condition
routeStatus := route.GetRouteStatus()
conditions = routeStatus.Parents[r.routeParentStatusIdx].Conditions
for _, cond := range conditions {
if cond.Type == string(v1beta1.RouteConditionResolvedRefs) && cond.Status == metav1.ConditionFalse {
return true
}
}
return false
}
52 changes: 52 additions & 0 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ func (t *Translator) processHTTPRouteParentRefs(httpRoute *HTTPRouteContext, res
"Route is accepted",
)
}

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasUnResolvedRefs(httpRoute) {
parentRef.SetCondition(httpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionTrue,
v1beta1.RouteReasonResolvedRefs,
"Resolved all the Object references for the Route",
)
}
}
}

Expand Down Expand Up @@ -303,6 +313,16 @@ func (t *Translator) processGRPCRouteParentRefs(grpcRoute *GRPCRouteContext, res
"Route is accepted",
)
}

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasUnResolvedRefs(grpcRoute) {
parentRef.SetCondition(grpcRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionTrue,
v1beta1.RouteReasonResolvedRefs,
"Resolved all the Object references for the Route",
)
}
}
}

Expand Down Expand Up @@ -613,6 +633,16 @@ func (t *Translator) processTLSRouteParentRefs(tlsRoute *TLSRouteContext, resour
"Route is accepted",
)
}

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasUnResolvedRefs(tlsRoute) {
parentRef.SetCondition(tlsRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionTrue,
v1beta1.RouteReasonResolvedRefs,
"Resolved all the Object references for the Route",
)
}
}
}

Expand Down Expand Up @@ -730,6 +760,7 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
"Route is accepted",
)
}

if !accepted {
parentRef.SetCondition(udpRoute,
v1beta1.RouteConditionAccepted,
Expand All @@ -738,6 +769,17 @@ func (t *Translator) processUDPRouteParentRefs(udpRoute *UDPRouteContext, resour
"Multiple routes on the same UDP listener",
)
}

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasUnResolvedRefs(udpRoute) {
parentRef.SetCondition(udpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionTrue,
v1beta1.RouteReasonResolvedRefs,
"Resolved all the Object references for the Route",
)
}

}
}

Expand Down Expand Up @@ -863,6 +905,16 @@ func (t *Translator) processTCPRouteParentRefs(tcpRoute *TCPRouteContext, resour
"Multiple routes on the same TCP listener",
)
}

// If no negative condition has been set for ResolvedRefs, set "ResolvedRefs=True"
if !parentRef.HasUnResolvedRefs(tcpRoute) {
parentRef.SetCondition(tcpRoute,
v1beta1.RouteConditionResolvedRefs,
metav1.ConditionTrue,
v1beta1.RouteReasonResolvedRefs,
"Resolved all the Object references for the Route",
)
}
}
}

Expand Down

0 comments on commit f219076

Please sign in to comment.