From 185a6e54f9094c4fe17d9c021e2e13846331128c Mon Sep 17 00:00:00 2001 From: Ori Shoshan Date: Sun, 15 Sep 2024 18:19:21 +0300 Subject: [PATCH] Handle issue where DB secret already exists by requeueing and restarting the flow (#157) --- .../poduserpassword/db_credentials_pod_reconciler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/operator/controllers/poduserpassword/db_credentials_pod_reconciler.go b/src/operator/controllers/poduserpassword/db_credentials_pod_reconciler.go index fe8792c..f663f7d 100644 --- a/src/operator/controllers/poduserpassword/db_credentials_pod_reconciler.go +++ b/src/operator/controllers/poduserpassword/db_credentials_pod_reconciler.go @@ -185,6 +185,9 @@ func (e *Reconciler) ensurePodUserAndPasswordSecret(ctx context.Context, pod *v1 secret := buildUserAndPasswordCredentialsSecret(secretName, pod.Namespace, username, password) log.WithField("secret", secretName).Debug("Creating new secret with user-password credentials") if err := e.client.Create(ctx, secret); err != nil { + if apierrors.IsAlreadyExists(err) { + return ctrl.Result{Requeue: true}, false, "", nil + } return ctrl.Result{}, false, "", errors.Wrap(err) } return ctrl.Result{}, true, password, nil