do not replace initjob
[ZITADOPER-7]
This commit is contained in:
@@ -296,38 +296,6 @@ func (r *ZitadelClusterReconciler) reconcileInitJob(ctx context.Context, zitadel
|
|||||||
}
|
}
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare the image in the existing job with the desired image
|
|
||||||
existingImage := existingJob.Spec.Template.Spec.Containers[0].Image
|
|
||||||
desiredImage := desiredInitJob.Spec.Template.Spec.Containers[0].Image
|
|
||||||
|
|
||||||
// If the images don't match, delete the existing job and wait for deletion
|
|
||||||
if existingImage != desiredImage {
|
|
||||||
if err := r.Delete(ctx, &existingJob); err != nil {
|
|
||||||
return ctrl.Result{}, fmt.Errorf("error deleting existing InitJob: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the job to be fully deleted before creating a new one
|
|
||||||
for {
|
|
||||||
err := r.Get(ctx, key, &existingJob)
|
|
||||||
if errors.IsNotFound(err) {
|
|
||||||
break // Job has been deleted, we can proceed
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return ctrl.Result{}, fmt.Errorf("error checking if InitJob is deleted: %v", err)
|
|
||||||
}
|
|
||||||
// Sleep for a short interval to avoid tight loop
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now create the new InitJob
|
|
||||||
if err := r.Create(ctx, desiredInitJob); err != nil {
|
|
||||||
return ctrl.Result{}, fmt.Errorf("error creating new InitJob: %v", err)
|
|
||||||
}
|
|
||||||
return ctrl.Result{}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the job exists and the image matches, no action is needed
|
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user