Skip to content

Commit

Permalink
Fix template sync set to Nomcompliant when context cancel
Browse files Browse the repository at this point in the history
Bug: If the template-sync is shutting down and it's in the middle of a reconcile request, it can set the policy to noncompliant with this
Ref: https://issues.redhat.com/browse/ACM-10402
Signed-off-by: Yi Rae Kim <[email protected]>
  • Loading branch information
yiraeChristineKim authored and openshift-merge-bot[bot] committed Mar 21, 2024
1 parent 5aae21c commit 6a8baf3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controllers/templatesync/template_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,11 @@ func (r *PolicyReconciler) Reconcile(ctx context.Context, request reconcile.Requ

// a different error getting template object from cluster
resultError = err

if errors.Is(err, context.Canceled) {
return reconcile.Result{}, fmt.Errorf("failed to get the object in the policy template: %w", err)
}

errMsg := fmt.Sprintf("Failed to get the object in the policy template: %s", err)

_ = r.emitTemplateError(ctx, instance, tIndex, tName, isClusterScoped, errMsg)
Expand Down

0 comments on commit 6a8baf3

Please sign in to comment.