@@ -51,7 +51,6 @@ import (
5151 "github.com/aws/aws-application-networking-k8s/pkg/k8s"
5252 "github.com/aws/aws-application-networking-k8s/pkg/model/core"
5353 lattice_runtime "github.com/aws/aws-application-networking-k8s/pkg/runtime"
54- "github.com/aws/aws-application-networking-k8s/pkg/utils"
5554 k8sutils "github.com/aws/aws-application-networking-k8s/pkg/utils"
5655 "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"
5756)
@@ -388,6 +387,25 @@ func (r *routeReconciler) reconcileUpsert(ctx context.Context, req ctrl.Request,
388387 return backendRefIPFamiliesErr
389388 }
390389
390+ if _ , err := r .buildAndDeployModel (ctx , route ); err != nil {
391+ if services .IsConflictError (err ) {
392+ // Stop reconciliation of this route if the route cannot be owned / has conflict
393+ route .Status ().UpdateParentRefs (route .Spec ().ParentRefs ()[0 ], config .LatticeGatewayControllerName )
394+ route .Status ().UpdateRouteCondition (metav1.Condition {
395+ Type : string (gwv1 .RouteConditionAccepted ),
396+ Status : metav1 .ConditionFalse ,
397+ ObservedGeneration : route .K8sObject ().GetGeneration (),
398+ Reason : "Conflicted" ,
399+ Message : err .Error (),
400+ })
401+ if err = r .client .Status ().Update (ctx , route .K8sObject ()); err != nil {
402+ return fmt .Errorf ("failed to update route status for conflict due to err %w" , err )
403+ }
404+ return nil
405+ }
406+ return err
407+ }
408+
391409 r .eventRecorder .Event (route .K8sObject (), corev1 .EventTypeNormal ,
392410 k8s .RouteEventReasonDeploySucceed , "Adding/Updating reconcile Done!" )
393411
@@ -554,20 +572,6 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
554572 if gw == nil {
555573 continue // ignore status update if gw not found
556574 }
557- gwClass := & gwv1.GatewayClass {}
558- gwClassName := types.NamespacedName {
559- Namespace : defaultNamespace ,
560- Name : string (gw .Spec .GatewayClassName ),
561- }
562- err = r .client .Get (ctx , gwClassName , gwClass )
563- if err != nil {
564- r .ukaiLog (ctx , "Ignore Route not controlled by any GatewayClass %s, %s" , route .Name (), route .Namespace ())
565- continue
566- }
567- if gwClass .Spec .ControllerName != config .LatticeGatewayControllerName {
568- r .ukaiLog (ctx , "Ignore non aws-vpc-lattice Route %s, %s" , route .Name (), route .Namespace ())
569- continue
570- }
571575
572576 noMatchingParent := true
573577 for _ , listener := range gw .Spec .Listeners {
@@ -599,12 +603,9 @@ func (r *routeReconciler) validateRouteParentRefs(ctx context.Context, route cor
599603
600604 return parentStatuses , nil
601605}
602- func (r * routeReconciler ) ukaiLog (ctx context.Context , template string , args ... interface {}) {
603- r .log .Infof (ctx , "u-kai: " + template , args ... )
604- }
605606
606607// set of valid Kinds for Route Backend References
607- var validBackendKinds = utils .NewSet ("Service" , "ServiceImport" )
608+ var validBackendKinds = k8sutils .NewSet ("Service" , "ServiceImport" )
608609
609610// validate route's backed references, will return non-accepted
610611// condition if at least one backendRef not in a valid state
0 commit comments