Skip to content

Commit

Permalink
Use StrategicMergeFrom to update finalizers (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
orishavit authored Sep 29, 2024
1 parent 12c9aaf commit ef821aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/operator/controllers/iam/pods/pods_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ func (r *PodReconciler) handlePodCleanup(ctx context.Context, pod corev1.Pod) (c

updatedPod := pod.DeepCopy()
if controllerutil.RemoveFinalizer(updatedPod, r.agent.FinalizerName()) || controllerutil.RemoveFinalizer(updatedPod, metadata.DeprecatedIAMRoleFinalizer) {
err := r.Patch(ctx, updatedPod, client.MergeFrom(&pod))
err := r.Patch(ctx, updatedPod, client.StrategicMergeFrom(&pod))
if err != nil {
if apierrors.IsConflict(err) || apierrors.IsNotFound(err) || apierrors.IsForbidden(err) {
if apierrors.IsConflict(err) || apierrors.IsNotFound(err) || apierrors.IsForbidden(err) || apierrors.IsInvalid(err) {
// These are all errors that can happen because the pod is already being deleted, requeuing
// should solve them all in a classy way
return ctrl.Result{Requeue: true}, nil
Expand Down

0 comments on commit ef821aa

Please sign in to comment.