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