Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: job deletion moved to ready state #59

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions internal/controller/store_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Loading