Don't update claim statuses after they've been deleted
Unless someone else added a finalizer (and didn't yet remove it) the claim will cease to exist as soon as the finalizer is removed, so there's nothing to update. Signed-off-by: Nic Cope <negz@rk0n.org>
This commit is contained in:
parent
8f84243a5a
commit
6e49f843c2
|
|
@ -357,12 +357,11 @@ func (r *ClaimReconciler) Reconcile(req reconcile.Request) (reconcile.Result, er
|
||||||
return reconcile.Result{RequeueAfter: aShortWait}, errors.Wrap(r.client.Status().Update(ctx, claim), errUpdateClaimStatus)
|
return reconcile.Result{RequeueAfter: aShortWait}, errors.Wrap(r.client.Status().Update(ctx, claim), errUpdateClaimStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We've successfully processed the delete, so there's no further
|
// We've successfully deleted our claim and removed our finalizer. If we
|
||||||
// reconciliation to do. There's a good chance our claim no longer
|
// assume we were the only controller that added a finalizer to this
|
||||||
// exists, but we try update its status just in case it sticks around,
|
// claim then it should no longer exist and thus there is no point
|
||||||
// for example due to additional finalizers.
|
// trying to update its status.
|
||||||
claim.SetConditions(v1alpha1.Deleting(), v1alpha1.ReconcileSuccess())
|
return reconcile.Result{Requeue: false}, nil
|
||||||
return reconcile.Result{Requeue: false}, errors.Wrap(IgnoreNotFound(r.client.Status().Update(ctx, claim)), errUpdateClaimStatus)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Claim reconcilers (should) watch for either claims with a resource ref,
|
// Claim reconcilers (should) watch for either claims with a resource ref,
|
||||||
|
|
|
||||||
|
|
@ -289,15 +289,6 @@ func TestClaimReconciler(t *testing.T) {
|
||||||
return errUnexpected
|
return errUnexpected
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
MockStatusUpdate: test.NewMockStatusUpdateFn(nil, func(got runtime.Object) error {
|
|
||||||
want := &MockClaim{}
|
|
||||||
want.SetDeletionTimestamp(&now)
|
|
||||||
want.SetConditions(v1alpha1.Deleting(), v1alpha1.ReconcileSuccess())
|
|
||||||
if diff := cmp.Diff(want, got, test.EquateConditions()); diff != "" {
|
|
||||||
t.Errorf("-want, +got:\n%s", diff)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
s: MockSchemeWith(&MockClaim{}, &MockClass{}, &MockManaged{}),
|
s: MockSchemeWith(&MockClaim{}, &MockClass{}, &MockManaged{}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue