From 62fe61e5b9f732616bc80702baadc5948a0ac939 Mon Sep 17 00:00:00 2001 From: Haim Kortovich Date: Tue, 31 Dec 2024 12:10:50 -0500 Subject: [PATCH] check setup job success before upgrading deployment [ZITADOPER-7] --- src/internal/controller/zitadelcluster_controller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/internal/controller/zitadelcluster_controller.go b/src/internal/controller/zitadelcluster_controller.go index d09b15c..943b2cf 100644 --- a/src/internal/controller/zitadelcluster_controller.go +++ b/src/internal/controller/zitadelcluster_controller.go @@ -349,9 +349,14 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade if err := r.Create(ctx, desiredSetupJob); err != nil { return ctrl.Result{}, fmt.Errorf("error creating new SetupJob: %v", err) } - return ctrl.Result{}, nil + } + if err := r.Get(ctx, key, &existingJob); err != nil { + return ctrl.Result{}, fmt.Errorf("error fetching existing SetupJob status: %v", err) } + if existingJob.Status.Succeeded != 1 { // Replace with actual success condition + return ctrl.Result{}, fmt.Errorf("SetupJob is not successful, current status: %v", existingJob.Status) + } // If the job exists and the image matches, no action is needed return ctrl.Result{}, nil }