Skip to content

Commit 203902d

Browse files
committed
optimization: replace .Update() with .Patch() for claim updateStatus
1 parent 953032b commit 203902d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

extensions/controllers/sandboxclaim_controller.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,19 @@ func (r *SandboxClaimReconciler) updateStatus(ctx context.Context, oldStatus *ex
289289
return nil
290290
}
291291

292-
if err := r.Status().Update(ctx, claim); err != nil {
293-
logger.Error(err, "Failed to update sandboxclaim status")
292+
oldClaim := claim.DeepCopy()
293+
oldClaim.Status = *oldStatus
294+
295+
claim.SetGroupVersionKind(extensionsv1alpha1.GroupVersion.WithKind("SandboxClaim"))
296+
297+
patch := client.MergeFrom(oldClaim)
298+
299+
if err := r.Status().Patch(ctx, claim, patch); err != nil {
300+
logger.Error(err, "Failed to patch sandboxclaim status")
294301
return err
295302
}
296303

304+
logger.Info("Successfully patched sandboxclaim status")
297305
return nil
298306
}
299307

0 commit comments

Comments
 (0)