@@ -41,9 +41,11 @@ import (
4141 securejoin "github.com/cyphar/filepath-securejoin"
4242 "github.com/fluxcd/cli-utils/pkg/kstatus/polling"
4343 "github.com/fluxcd/cli-utils/pkg/object"
44+ apiacl "github.com/fluxcd/pkg/apis/acl"
4445 eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
4546 "github.com/fluxcd/pkg/apis/meta"
4647 "github.com/fluxcd/pkg/http/fetch"
48+ "github.com/fluxcd/pkg/runtime/acl"
4749 runtimeClient "github.com/fluxcd/pkg/runtime/client"
4850 "github.com/fluxcd/pkg/runtime/conditions"
4951 "github.com/fluxcd/pkg/runtime/patch"
@@ -150,6 +152,20 @@ func (r *KCLRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
150152
151153 source , err := r .getSource (ctx , & obj )
152154 if err != nil {
155+ conditions .MarkFalse (& obj , meta .ReadyCondition , meta .ArtifactFailedReason , "%s" , err )
156+ if apierrors .IsNotFound (err ) {
157+ msg := fmt .Sprintf ("Source '%s' not found" , obj .Spec .SourceRef .String ())
158+ log .Info (msg )
159+ return ctrl.Result {RequeueAfter : obj .GetRetryInterval ()}, nil
160+ }
161+
162+ if acl .IsAccessDenied (err ) {
163+ conditions .MarkFalse (& obj , meta .ReadyCondition , apiacl .AccessDeniedReason , "%s" , err )
164+ log .Error (err , "Access denied to cross-namespace source" )
165+ r .event (& obj , "unknown" , eventv1 .EventSeverityError , err .Error (), nil )
166+ return ctrl.Result {RequeueAfter : obj .GetRetryInterval ()}, nil
167+ }
168+ // Retry with backoff on transient errors.
153169 return ctrl.Result {}, err
154170 }
155171 artifact := source .GetArtifact ()
0 commit comments