Skip to content

Commit 5492b06

Browse files
committed
fix: r
Signed-off-by: ashing <[email protected]>
1 parent 97e9411 commit 5492b06

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

internal/controller/httproute_controller.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ func (r *HTTPRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
223223
parentStatus.Conditions = MergeCondition(parentStatus.Conditions, condition)
224224
}
225225
SetRouteConditionAccepted(&parentStatus, hr.GetGeneration(), acceptStatus.status, acceptStatus.msg)
226-
227-
// Use the stored backend reference error directly with our new function
228-
SetRouteConditionResolvedRefsWithError(&parentStatus, hr.GetGeneration(), backendRefErr)
226+
SetRouteConditionResolvedRefs(&parentStatus, hr.GetGeneration(), backendRefErr)
229227

230228
hr.Status.Parents = append(hr.Status.Parents, parentStatus)
231229
}
@@ -444,7 +442,11 @@ func (r *HTTPRouteReconciler) processHTTPRouteBackendRefs(tctx *provider.Transla
444442

445443
var service corev1.Service
446444
if err := r.Get(tctx, serviceNS, &service); err != nil {
447-
terr = NewBackendNotFoundError(namespace, name)
445+
if client.IgnoreNotFound(err) == nil {
446+
terr = NewBackendNotFoundError(namespace, name)
447+
} else {
448+
terr = err
449+
}
448450
continue
449451
}
450452
if service.Spec.Type == corev1.ServiceTypeExternalName {

internal/controller/utils.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -242,32 +242,8 @@ func SetRouteConditionAccepted(routeParentStatus *gatewayv1.RouteParentStatus, g
242242
}
243243
}
244244

245-
func SetRouteConditionResolvedRefs(routeParentStatus *gatewayv1.RouteParentStatus, generation int64, status bool, message string) {
246-
reason := string(gatewayv1.RouteReasonResolvedRefs)
247-
// check if the error message contains InvalidKind
248-
if !status && strings.Contains(message, string(gatewayv1.RouteReasonInvalidKind)) {
249-
reason = string(gatewayv1.RouteReasonInvalidKind)
250-
}
251-
if !status && strings.Contains(message, "Service") && strings.Contains(message, "not found") {
252-
reason = string(gatewayv1.RouteReasonBackendNotFound)
253-
}
254-
255-
condition := metav1.Condition{
256-
Type: string(gatewayv1.RouteConditionResolvedRefs),
257-
Status: ConditionStatus(status),
258-
Reason: reason,
259-
ObservedGeneration: generation,
260-
Message: message,
261-
LastTransitionTime: metav1.Now(),
262-
}
263-
264-
if !IsConditionPresentAndEqual(routeParentStatus.Conditions, condition) {
265-
routeParentStatus.Conditions = MergeCondition(routeParentStatus.Conditions, condition)
266-
}
267-
}
268-
269-
// SetRouteConditionResolvedRefsWithError sets the ResolvedRefs condition with proper reason based on error type
270-
func SetRouteConditionResolvedRefsWithError(routeParentStatus *gatewayv1.RouteParentStatus, generation int64, err error) {
245+
// SetRouteConditionResolvedRefs sets the ResolvedRefs condition with proper reason based on error type
246+
func SetRouteConditionResolvedRefs(routeParentStatus *gatewayv1.RouteParentStatus, generation int64, err error) {
271247
var (
272248
reason string
273249
status = metav1.ConditionTrue

0 commit comments

Comments
 (0)