delete job if not equal and create new
[ZITADOPER-7]
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -291,10 +292,14 @@ func (r *ZitadelClusterReconciler) reconcileInitJob(ctx context.Context, zitadel
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
patch := client.MergeFrom(existingJob.DeepCopy())
|
||||
existingJob.Spec.Template.Spec = desiredInitJob.Spec.Template.Spec
|
||||
return ctrl.Result{}, r.Patch(ctx, &existingJob, patch)
|
||||
if !reflect.DeepEqual(existingJob.Spec.Template.Spec, desiredInitJob.Spec.Template.Spec) {
|
||||
err := r.Delete(ctx, &existingJob)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
return ctrl.Result{}, r.Create(ctx, desiredInitJob)
|
||||
}
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
func (b *Builder) BuildInitJob(zitadel *zitadelv1alpha1.ZitadelCluster, key types.NamespacedName) (*batchv1.Job, error) {
|
||||
|
||||
backOffLimit := int32(5)
|
||||
ttlAfterFinish := int32(100)
|
||||
activeDeadlineSeconds := int64(300)
|
||||
runAsNonRoot := true
|
||||
enableServiceLinks := false
|
||||
@@ -27,8 +28,9 @@ func (b *Builder) BuildInitJob(zitadel *zitadelv1alpha1.ZitadelCluster, key type
|
||||
Namespace: key.Namespace,
|
||||
},
|
||||
Spec: batchv1.JobSpec{
|
||||
BackoffLimit: &backOffLimit,
|
||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||
BackoffLimit: &backOffLimit,
|
||||
ActiveDeadlineSeconds: &activeDeadlineSeconds,
|
||||
TTLSecondsAfterFinished: &ttlAfterFinish,
|
||||
Template: corev1.PodTemplateSpec{
|
||||
Spec: corev1.PodSpec{
|
||||
RestartPolicy: corev1.RestartPolicyOnFailure,
|
||||
|
||||
Reference in New Issue
Block a user