Skip to content

Commit

Permalink
chore: Add comments on calls to kubeClient Update() (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Mar 27, 2024
1 parent b770a19 commit 23c4af9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/controllers/nodeclaim/disruption/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ func (c *Controller) Reconcile(ctx context.Context, nodeClaim *v1beta1.NodeClaim
results = append(results, res)
}
if !equality.Semantic.DeepEqual(stored, nodeClaim) {
// We call Update() here rather than Patch() because patching a list with a JSON merge patch
// can cause races due to the fact that it fully replaces the list on a change
// Here, we are updating the status condition list
if err := c.kubeClient.Status().Update(ctx, nodeClaim); err != nil {
if errors.IsConflict(err) {
return reconcile.Result{Requeue: true}, nil
Expand Down
3 changes: 3 additions & 0 deletions pkg/controllers/nodeclaim/termination/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ func (c *Controller) Finalize(ctx context.Context, nodeClaim *v1beta1.NodeClaim)
}
controllerutil.RemoveFinalizer(nodeClaim, v1beta1.TerminationFinalizer)
if !equality.Semantic.DeepEqual(stored, nodeClaim) {
// We call Update() here rather than Patch() because patching a list with a JSON merge patch
// can cause races due to the fact that it fully replaces the list on a change
// https://github.com/kubernetes/kubernetes/issues/111643#issuecomment-2016489732
if err = c.kubeClient.Update(ctx, nodeClaim); err != nil {
if errors.IsConflict(err) {
return reconcile.Result{Requeue: true}, nil
Expand Down

0 comments on commit 23c4af9

Please sign in to comment.