@@ -14,6 +14,7 @@ import (
1414 "sigs.k8s.io/aws-load-balancer-controller/pkg/shared_constants"
1515 "sigs.k8s.io/controller-runtime/pkg/client"
1616 gwv1 "sigs.k8s.io/gateway-api/apis/v1"
17+ "strings"
1718)
1819
1920var _ TargetGroupConfigurator = & GatewayBackendConfig {}
@@ -160,8 +161,24 @@ func gatewayLoader(ctx context.Context, k8sClient client.Client, routeIdentifier
160161 // If the ARN is not available, then the backend is not yet usable.
161162 initialErrorMessage := fmt .Sprintf ("Gateway (%s:%s) is not usable yet, LB ARN is not provisioned)" , gwIdentifier .Namespace , gwIdentifier .Name )
162163 wrappedGatewayErrorMessage := generateInvalidMessageWithRouteDetails (initialErrorMessage , routeKind , routeIdentifier )
163- return nil , wrapError (errors .Errorf ("%s" , initialErrorMessage ), gwv1 .GatewayReasonListenersNotValid , gwv1 .RouteReasonBackendNotFound , & wrappedGatewayErrorMessage , nil ), nil
164+ // This needs to be a fatal error, otherwise we will not run another reconcile cycle to pick up the ARN.
165+ return nil , nil , wrapError (errors .Errorf ("%s" , initialErrorMessage ), gwv1 .GatewayReasonListenersNotValid , gwv1 .RouteReasonBackendNotFound , & wrappedGatewayErrorMessage , nil )
166+ }
167+
168+ err = validateGatewayARN (arn )
169+ if err != nil {
170+ wrappedGatewayErrorMessage := generateInvalidMessageWithRouteDetails (err .Error (), routeKind , routeIdentifier )
171+ // This can be a warning, as we know that retrying reconcile will do nothing to fix this situation.
172+ return nil , wrapError (err , gwv1 .GatewayReasonListenersNotValid , gwv1 .RouteReasonBackendNotFound , & wrappedGatewayErrorMessage , nil ), nil
164173 }
165174
166175 return NewGatewayBackendConfig (gw , tgProps , arn , int32 (* backendRef .Port )), nil , nil
167176}
177+
178+ func validateGatewayARN (arn string ) error {
179+ parts := strings .Split (arn , "/" )
180+ if len (parts ) < 2 || parts [1 ] != "app" {
181+ return errors .Errorf ("invalid gateway ARN: %s, the resource type must be application load balancer" , arn )
182+ }
183+ return nil
184+ }
0 commit comments