diff --git a/pkg/reconciler/managed/reconciler.go b/pkg/reconciler/managed/reconciler.go index 0a9daddfa..3a6a447b5 100644 --- a/pkg/reconciler/managed/reconciler.go +++ b/pkg/reconciler/managed/reconciler.go @@ -616,7 +616,7 @@ func NewReconciler(m manager.Manager, of resource.ManagedKind, o ...ReconcilerOp } // Reconcile a managed resource with an external resource. -func (r *Reconciler) Reconcile(_ context.Context, req reconcile.Request) (result reconcile.Result, err error) { // nolint:gocyclo +func (r *Reconciler) Reconcile(_ context.Context, req reconcile.Request) (reconcile.Result, error) { // nolint:gocyclo // NOTE(negz): This method is a well over our cyclomatic complexity goal. // Be wary of adding additional complexity. @@ -745,13 +745,7 @@ func (r *Reconciler) Reconcile(_ context.Context, req reconcile.Request) (result if disconnectErr := r.external.Disconnect(ctx); disconnectErr != nil { log.Debug("Cannot disconnect from provider", "error", disconnectErr) record.Event(managed, event.Warning(reasonCannotDisconnect, disconnectErr)) - disconnectErr = errors.Wrap(disconnectErr, errReconcileDisconnect) - managed.SetConditions(xpv1.ReconcileError(disconnectErr)) - if err != nil { - err = errors.Wrap(err, disconnectErr.Error()) - } else { - err = disconnectErr - } + managed.SetConditions(xpv1.ReconcileError(errors.Wrap(disconnectErr, errReconcileDisconnect))) } }() diff --git a/pkg/reconciler/managed/reconciler_test.go b/pkg/reconciler/managed/reconciler_test.go index ba16d3d11..525cfe52b 100644 --- a/pkg/reconciler/managed/reconciler_test.go +++ b/pkg/reconciler/managed/reconciler_test.go @@ -287,7 +287,7 @@ func TestReconciler(t *testing.T) { want: want{result: reconcile.Result{Requeue: true}}, }, "ExternalDisconnectError": { - reason: "Errors disconnecting from the provider should return error.", + reason: "Error disconnecting from the provider should not trigger requeue.", args: args{ m: &fake.Manager{ Client: &test.MockClient{ @@ -324,10 +324,7 @@ func TestReconciler(t *testing.T) { WithFinalizer(resource.FinalizerFns{AddFinalizerFn: func(_ context.Context, _ resource.Object) error { return nil }}), }, }, - want: want{ - result: reconcile.Result{RequeueAfter: defaultpollInterval}, - err: errors.Wrap(errors.New("boom"), "disconnect failed"), - }, + want: want{result: reconcile.Result{RequeueAfter: defaultpollInterval}}, }, "ExternalObserveErrorDisconnectError": { reason: "Errors disconnecting from the provider after error observing the external resource should trigger a requeue after a short wait and return error.", @@ -364,10 +361,7 @@ func TestReconciler(t *testing.T) { ), }, }, - want: want{ - result: reconcile.Result{Requeue: true}, - err: errors.Wrap(errors.New("boom"), "disconnect failed"), - }, + want: want{result: reconcile.Result{Requeue: true}}, }, "ExternalObserveError": { reason: "Errors observing the external resource should trigger a requeue after a short wait.",