From c855d0a60a3b413b2a648b964f8891bcc73bd865 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Sat, 27 Jan 2024 15:59:19 +0100 Subject: [PATCH 1/2] reconciler/managed: keep trying to update critical annotation until ctx canceled Signed-off-by: Dr. Stefan Schimanski (cherry picked from commit 7d7a4e927336b3d601dc390d3e8f65358761e2c2) --- pkg/reconciler/managed/api.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/reconciler/managed/api.go b/pkg/reconciler/managed/api.go index 59f52307e..669e4f2d2 100644 --- a/pkg/reconciler/managed/api.go +++ b/pkg/reconciler/managed/api.go @@ -212,7 +212,9 @@ func NewRetryingCriticalAnnotationUpdater(c client.Client) *RetryingCriticalAnno // case of a conflict error. func (u *RetryingCriticalAnnotationUpdater) UpdateCriticalAnnotations(ctx context.Context, o client.Object) error { a := o.GetAnnotations() - err := retry.OnError(retry.DefaultRetry, resource.IsAPIError, func() error { + err := retry.OnError(retry.DefaultRetry, func(err error) bool { + return !errors.Is(err, context.Canceled) + }, func() error { err := u.client.Update(ctx, o) if kerrors.IsConflict(err) { if getErr := u.client.Get(ctx, client.ObjectKeyFromObject(o), o); getErr != nil { From 6a2b7d681d3eef137940e206e126dfe4b058e86a Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Sat, 27 Jan 2024 16:01:56 +0100 Subject: [PATCH 2/2] reconciler/managed: don't brick MR on create conflict Signed-off-by: Dr. Stefan Schimanski (cherry picked from commit 34c3e60a0674e2ed690e77be31c518e4506d5f0a) --- pkg/reconciler/managed/reconciler.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/reconciler/managed/reconciler.go b/pkg/reconciler/managed/reconciler.go index 37dc9507c..dbeb8b2f9 100644 --- a/pkg/reconciler/managed/reconciler.go +++ b/pkg/reconciler/managed/reconciler.go @@ -1051,10 +1051,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu // issue we'll be requeued implicitly when we update our status with // the new error condition. If not, we requeue explicitly, which will trigger backoff. log.Debug("Cannot create external resource", "error", err) - if kerrors.IsConflict(err) { - return reconcile.Result{Requeue: true}, nil + if !kerrors.IsConflict(err) { + record.Event(managed, event.Warning(reasonCannotCreate, err)) } - record.Event(managed, event.Warning(reasonCannotCreate, err)) // We handle annotations specially here because it's // critical that they are persisted to the API server.