diff --git a/pkg/errors/reconcile_test.go b/pkg/errors/reconcile_test.go index e84e1a5..02b8241 100644 --- a/pkg/errors/reconcile_test.go +++ b/pkg/errors/reconcile_test.go @@ -1,5 +1,18 @@ -// Copyright 2023 Upbound Inc. -// All rights reserved +/* +Copyright 2023 The Crossplane Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package errors diff --git a/pkg/reconciler/managed/reconciler.go b/pkg/reconciler/managed/reconciler.go index f340f68..c92b7b0 100644 --- a/pkg/reconciler/managed/reconciler.go +++ b/pkg/reconciler/managed/reconciler.go @@ -22,7 +22,6 @@ import ( "strings" "time" - kerrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" @@ -714,19 +713,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (resu // NOTE(negz): This method is a well over our cyclomatic complexity goal. // Be wary of adding additional complexity. + defer func() { result, err = errors.SilentlyRequeueOnConflict(result, err) }() + log := r.log.WithValues("request", req) - - defer func() { - if kerrors.IsConflict(errors.Cause(err)) { - // conflict errors are transient in Kubernetes and completely normal. - // The right reaction is to requeue, but not record the object as error'ing - // or creating events. - log.Debug("Transient conflict error", "error", err) - result.Requeue = true - err = nil - } - }() - log.Debug("Reconciling") ctx, cancel := context.WithTimeout(ctx, r.timeout+reconcileGracePeriod)