@@ -140,11 +140,12 @@ func (r *ClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ct
140
140
if err != nil {
141
141
if apierrors .IsNotFound (err ) {
142
142
if ! claim .ObjectMeta .DeletionTimestamp .IsZero () {
143
+ patch := client .MergeFrom (claim .DeepCopy ())
143
144
if err := r .reconcileDelete (ctx , claim ); err != nil {
144
145
return ctrl.Result {}, fmt .Errorf ("reconcile delete: %w" , err )
145
146
}
146
- // we'll need to explicitly update the claim here since we haven't set up a patch helper yet.
147
- if err := r .Client .Update (ctx , claim ); err != nil {
147
+ // we'll need to explicitly patch the claim here since we haven't set up a patch helper yet.
148
+ if err := r .Client .Patch (ctx , claim , patch ); err != nil {
148
149
return ctrl.Result {}, fmt .Errorf ("patch after reconciling delete: %w" , err )
149
150
}
150
151
return ctrl.Result {}, nil
@@ -272,8 +273,9 @@ func (r *ClaimReconciler) reconcileDelete(ctx context.Context, claim *ipamv1.IPA
272
273
273
274
if address .Name != "" {
274
275
var err error
276
+ patch := client .MergeFrom (address .DeepCopy ())
275
277
if controllerutil .RemoveFinalizer (address , ProtectAddressFinalizer ) {
276
- if err = r .Client .Update (ctx , address ); err != nil && ! apierrors .IsNotFound (err ) {
278
+ if err = r .Client .Patch (ctx , address , patch ); err != nil && ! apierrors .IsNotFound (err ) {
277
279
return errors .Wrap (err , "failed to remove address finalizer" )
278
280
}
279
281
}
0 commit comments