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 }