From e6e778bba3e704bc27895ba4996237d586313ce9 Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Fri, 1 Mar 2024 16:13:22 -0600 Subject: [PATCH] provider: don't re-use 'err' variable in job creation Signed-off-by: Jose A. Rivera --- controllers/storagecluster/provider_server.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/storagecluster/provider_server.go b/controllers/storagecluster/provider_server.go index 8516abc57c..b9bb7a15ae 100644 --- a/controllers/storagecluster/provider_server.go +++ b/controllers/storagecluster/provider_server.go @@ -496,9 +496,12 @@ func (o *ocsProviderServer) createJob(r *StorageClusterReconciler, instance *ocs if errors.IsNotFound(err) { onboardingSecretGeneratorJob := getOnboardingJobObject(instance) - err = r.Client.Create(context.Background(), onboardingSecretGeneratorJob) - } - if err != nil { + jobErr := r.Client.Create(context.Background(), onboardingSecretGeneratorJob) + if jobErr != nil && !errors.IsAlreadyExists(jobErr) { + r.Log.Error(jobErr, "failed to create onboarding job") + return reconcile.Result{}, jobErr + } + } else if err != nil { r.Log.Error(err, "failed to create/ensure secret") return reconcile.Result{}, err }