From f03acfd9fbeaa6e3e6d6e132a131f9fb92b1f8aa Mon Sep 17 00:00:00 2001 From: Evyatar Date: Sun, 13 Oct 2024 19:22:06 +0300 Subject: [PATCH] Adding call to error unwrap so we could compare with k8s errors --- src/operator/controllers/iam/webhooks/pod_webhook.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/operator/controllers/iam/webhooks/pod_webhook.go b/src/operator/controllers/iam/webhooks/pod_webhook.go index 495addc..ea36051 100644 --- a/src/operator/controllers/iam/webhooks/pod_webhook.go +++ b/src/operator/controllers/iam/webhooks/pod_webhook.go @@ -85,8 +85,9 @@ func (w *ServiceAccountAnnotatingPodWebhook) handleWithRetriesOnConflictOrNotFou for attempt := 0; attempt < maxRetries; attempt++ { logger.Debugf("Handling pod (attempt %d out of %d)", attempt+1, maxRetries) outputPod, patched, successMsg, err = w.handleOnce(ctx, *pod.DeepCopy(), dryRun) + unwrappedErr := errors.Unwrap(err) if err != nil { - if k8serrors.IsConflict(err) || k8serrors.IsNotFound(err) || k8serrors.IsForbidden(err) { + if k8serrors.IsConflict(unwrappedErr) || k8serrors.IsNotFound(unwrappedErr) || k8serrors.IsForbidden(unwrappedErr) { logger.WithError(err).Errorf("failed to handle pod due to conflict, retrying in 1 second (attempt %d out of %d)", attempt+1, 3) time.Sleep(1 * time.Second) continue