@@ -473,6 +473,14 @@ func (r *routeReconciler) validateRoute(ctx context.Context, route core.Route) e
473473 return fmt .Errorf ("validate route: %w" , err )
474474 }
475475
476+ if core .HasAllParentRefsRejected (route ) {
477+ r .eventRecorder .Event (route .K8sObject (), corev1 .EventTypeWarning ,
478+ k8s .RouteEventReasonFailedBuildModel ,
479+ "No VPC Lattice resources created. Route's parentRefs rejected by all Gateway listeners due to allowedRoutes policies. Check route status conditions for more detail." )
480+ return fmt .Errorf ("%w: route has validation errors, see status" , ErrValidation )
481+ }
482+
483+ // Additional broader validation check for any issues
476484 if r .hasNotAcceptedCondition (route ) {
477485 return fmt .Errorf ("%w: route has validation errors, see status" , ErrValidation )
478486 }
@@ -500,8 +508,9 @@ func (r *routeReconciler) hasNotAcceptedCondition(route core.Route) bool {
500508//
501509// If parent GW exists will check:
502510// - NoMatchingParent: parentRef sectionName and port matches Listener name and port
511+ // - NotAllowedByListeners: listener allowedRoutes.namespaces allows route
512+ // - NotAllowedByListeners: listener allowedRoutes.kinds contains route GroupKind
503513// - TODO: NoMatchingListenerHostname: listener hostname matches one of route hostnames
504- // - TODO: NotAllowedByListeners: listener allowedRoutes contains route GroupKind
505514func (r * routeReconciler ) validateRouteParentRefs (ctx context.Context , route core.Route ) ([]gwv1.RouteParentStatus , error ) {
506515 if len (route .Spec ().ParentRefs ()) == 0 {
507516 return nil , ErrParentRefsNotFound
@@ -516,6 +525,8 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
516525 gw := gws [0 ]
517526 for _ , parentRef := range route .Spec ().ParentRefs () {
518527 noMatchingParent := true
528+ notAllowedByAnyMatchingListener := true
529+
519530 for _ , listener := range gw .Spec .Listeners {
520531 if parentRef .Port != nil && * parentRef .Port != listener .Port {
521532 continue
@@ -524,6 +535,16 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
524535 continue
525536 }
526537 noMatchingParent = false
538+
539+ allowed , err := core .IsRouteAllowedByListener (ctx , r .client , route , gw , listener )
540+ if err != nil {
541+ return nil , err
542+ }
543+
544+ if allowed {
545+ notAllowedByAnyMatchingListener = false
546+ break
547+ }
527548 }
528549
529550 parentStatus := gwv1.RouteParentStatus {
@@ -536,6 +557,9 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
536557 switch {
537558 case noMatchingParent :
538559 cnd = r .newCondition (route , gwv1 .RouteConditionAccepted , gwv1 .RouteReasonNoMatchingParent , "" )
560+ case notAllowedByAnyMatchingListener :
561+ cnd = r .newCondition (route , gwv1 .RouteConditionAccepted , gwv1 .RouteReasonNotAllowedByListeners ,
562+ "No matching listeners allow this route. Check Gateway listener allowedRoutes policies" )
539563 default :
540564 cnd = r .newCondition (route , gwv1 .RouteConditionAccepted , gwv1 .RouteReasonAccepted , "" )
541565 }
0 commit comments