From e690ab6df57ebc52a2f7c2faab5b5ed5f06980d9 Mon Sep 17 00:00:00 2001 From: Patrick Derks Date: Mon, 21 Oct 2024 16:45:30 +0200 Subject: [PATCH] fix: job deletion moved to ready state --- internal/controller/store_controller.go | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/controller/store_controller.go b/internal/controller/store_controller.go index c68c42d..789a2c8 100644 --- a/internal/controller/store_controller.go +++ b/internal/controller/store_controller.go @@ -162,17 +162,6 @@ func (r *StoreReconciler) doReconcile( // State Initializing if store.IsState(v1.StateInitializing) { - // When setup job is still running we will kill it now. This happens when sidecars are used - // EDIT: This makes more problems then it will help. So we process the way of terminating to - // the user to close all sidecars correctly. - // Check if sidecars are active - if len(store.Spec.Container.ExtraContainers) > 0 { - log.Info("Delete setup/migration job if they are finished because sidecars are used") - if err := r.completeJobs(ctx, store); err != nil { - log.Error(err, "Can't cleanup setup and migration jobs") - } - } - log.Info("reconcile deployment") if err := r.reconcileDeployment(ctx, store); err != nil { return fmt.Errorf("deployment: %w", err) @@ -201,6 +190,17 @@ func (r *StoreReconciler) doReconcile( } } + // When setup job is still running we will kill it now. This happens when sidecars are used + // EDIT: This makes more problems then it will help. So we process the way of terminating to + // the user to close all sidecars correctly. + // Check if sidecars are active + if len(store.Spec.Container.ExtraContainers) > 0 { + log.Info("Delete setup/migration job if they are finished because sidecars are used") + if err := r.completeJobs(ctx, store); err != nil { + log.Error(err, "Can't cleanup setup and migration jobs") + } + } + log.Info("reconcile deployment") if err := r.reconcileDeployment(ctx, store); err != nil { return fmt.Errorf("deployment: %w", err) @@ -454,7 +454,7 @@ func (r *StoreReconciler) completeJobs(ctx context.Context, store *v1.Store) err return err } // The job is not completed because active containers are running - if !done { + if done { if err = job.DeleteSetupJob(ctx, r.Client, store); err != nil { return err } @@ -464,7 +464,7 @@ func (r *StoreReconciler) completeJobs(ctx context.Context, store *v1.Store) err return err } // The job is not completed because active containers are running - if !done { + if done { if err = job.DeleteAllMigrationJobs(ctx, r.Client, store); err != nil { return err }