diff --git a/src/internal/controller/zitadelcluster_controller.go b/src/internal/controller/zitadelcluster_controller.go index d501f07..c82d730 100644 --- a/src/internal/controller/zitadelcluster_controller.go +++ b/src/internal/controller/zitadelcluster_controller.go @@ -51,7 +51,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -316,9 +315,6 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade if !errors.IsNotFound(err) { return ctrl.Result{}, fmt.Errorf("error getting SetupJob: %v", err) } - if err := r.scaleDownDeployment(ctx, zitadel); err != nil { - return ctrl.Result{}, err - } // If job is not found, create the job if err := r.Create(ctx, desiredSetupJob); err != nil { return ctrl.Result{}, fmt.Errorf("error creating SetupJob: %v", err) @@ -332,9 +328,6 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade // If the images don't match, delete the existing job and wait for deletion if existingImage != desiredImage { - if err := r.scaleDownDeployment(ctx, zitadel); err != nil { - return ctrl.Result{}, err - } if err := r.Delete(ctx, &existingJob); err != nil { return ctrl.Result{}, fmt.Errorf("error deleting existing SetupJob: %v", err) @@ -368,25 +361,26 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade // If the job exists and the image matches, no action is needed return ctrl.Result{}, nil } -func (r *ZitadelClusterReconciler) scaleDownDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) error { - // scale down deployment first - deploymentKey := client.ObjectKeyFromObject(zitadel) - var existingDep appsv1.Deployment - err := r.Get(ctx, deploymentKey, &existingDep) - if err != nil { - if errors.IsNotFound(err) { - } else { - return fmt.Errorf("error getting Deployment: %v", err) - } - } else { - patch := client.MergeFrom(existingDep.DeepCopy()) - existingDep.Spec.Replicas = ptr.To(int32(0)) - if err := r.Patch(ctx, &existingDep, patch); err != nil { - return fmt.Errorf("Error scaling down deployment: %v", err) - } - } - return nil -} + +// func (r *ZitadelClusterReconciler) scaleDownDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) error { +// // scale down deployment first +// deploymentKey := client.ObjectKeyFromObject(zitadel) +// var existingDep appsv1.Deployment +// err := r.Get(ctx, deploymentKey, &existingDep) +// if err != nil { +// if errors.IsNotFound(err) { +// } else { +// return fmt.Errorf("error getting Deployment: %v", err) +// } +// } else { +// patch := client.MergeFrom(existingDep.DeepCopy()) +// existingDep.Spec.Replicas = ptr.To(int32(0)) +// if err := r.Patch(ctx, &existingDep, patch); err != nil { +// return fmt.Errorf("Error scaling down deployment: %v", err) +// } +// } +// return nil +// } func (r *ZitadelClusterReconciler) reconcileDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) { // TODO: Reload on config changed