dont scale down
[ZITADOPER-7]
This commit is contained in:
@@ -51,7 +51,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
"k8s.io/utils/ptr"
|
|
||||||
ctrl "sigs.k8s.io/controller-runtime"
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||||
@@ -316,9 +315,6 @@ func (r *ZitadelClusterReconciler) reconcileSetupJob(ctx context.Context, zitade
|
|||||||
if !errors.IsNotFound(err) {
|
if !errors.IsNotFound(err) {
|
||||||
return ctrl.Result{}, fmt.Errorf("error getting SetupJob: %v", 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 job is not found, create the job
|
||||||
if err := r.Create(ctx, desiredSetupJob); err != nil {
|
if err := r.Create(ctx, desiredSetupJob); err != nil {
|
||||||
return ctrl.Result{}, fmt.Errorf("error creating SetupJob: %v", err)
|
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 the images don't match, delete the existing job and wait for deletion
|
||||||
if existingImage != desiredImage {
|
if existingImage != desiredImage {
|
||||||
if err := r.scaleDownDeployment(ctx, zitadel); err != nil {
|
|
||||||
return ctrl.Result{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := r.Delete(ctx, &existingJob); err != nil {
|
if err := r.Delete(ctx, &existingJob); err != nil {
|
||||||
return ctrl.Result{}, fmt.Errorf("error deleting existing SetupJob: %v", err)
|
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
|
// If the job exists and the image matches, no action is needed
|
||||||
return ctrl.Result{}, nil
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
func (r *ZitadelClusterReconciler) scaleDownDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) error {
|
|
||||||
// scale down deployment first
|
// func (r *ZitadelClusterReconciler) scaleDownDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) error {
|
||||||
deploymentKey := client.ObjectKeyFromObject(zitadel)
|
// // scale down deployment first
|
||||||
var existingDep appsv1.Deployment
|
// deploymentKey := client.ObjectKeyFromObject(zitadel)
|
||||||
err := r.Get(ctx, deploymentKey, &existingDep)
|
// var existingDep appsv1.Deployment
|
||||||
if err != nil {
|
// err := r.Get(ctx, deploymentKey, &existingDep)
|
||||||
if errors.IsNotFound(err) {
|
// if err != nil {
|
||||||
} else {
|
// if errors.IsNotFound(err) {
|
||||||
return fmt.Errorf("error getting Deployment: %v", err)
|
// } else {
|
||||||
}
|
// return fmt.Errorf("error getting Deployment: %v", err)
|
||||||
} else {
|
// }
|
||||||
patch := client.MergeFrom(existingDep.DeepCopy())
|
// } else {
|
||||||
existingDep.Spec.Replicas = ptr.To(int32(0))
|
// patch := client.MergeFrom(existingDep.DeepCopy())
|
||||||
if err := r.Patch(ctx, &existingDep, patch); err != nil {
|
// existingDep.Spec.Replicas = ptr.To(int32(0))
|
||||||
return fmt.Errorf("Error scaling down deployment: %v", err)
|
// if err := r.Patch(ctx, &existingDep, patch); err != nil {
|
||||||
}
|
// return fmt.Errorf("Error scaling down deployment: %v", err)
|
||||||
}
|
// }
|
||||||
return nil
|
// }
|
||||||
}
|
// return nil
|
||||||
|
// }
|
||||||
|
|
||||||
func (r *ZitadelClusterReconciler) reconcileDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) {
|
func (r *ZitadelClusterReconciler) reconcileDeployment(ctx context.Context, zitadel *zitadelv1alpha1.ZitadelCluster) (ctrl.Result, error) {
|
||||||
// TODO: Reload on config changed
|
// TODO: Reload on config changed
|
||||||
|
|||||||
Reference in New Issue
Block a user