check setup job success before upgrading deployment

[ZITADOPER-7]
This commit is contained in:
Haim Kortovich
2024-12-31 12:10:50 -05:00
parent 4295fb70d8
commit 62fe61e5b9

View File

@@ -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
}