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: remove deletions of containers after job finishes #45

Merged
merged 1 commit into from
Oct 7, 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
42 changes: 8 additions & 34 deletions internal/controller/store_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ 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 job because sidecars are used")
if err := r.completeJobs(ctx, store); err != nil {
return fmt.Errorf("Can't cleanup setup and migration jobs: %w", err)
}
}
// if len(store.Spec.Container.ExtraContainers) > 0 {
// log.Info("Delete setup job because sidecars are used")
// if err := r.completeJobs(ctx, store); err != nil {
// return fmt.Errorf("Can't cleanup setup and migration jobs: %w", err)
// }
// }

log.Info("reconcile deployment")
if err := r.reconcileDeployment(ctx, store); err != nil {
Expand Down Expand Up @@ -221,34 +223,6 @@ func (r *StoreReconciler) doReconcile(
return nil
}

func (r *StoreReconciler) completeJobs(ctx context.Context, store *v1.Store) error {
done, err := job.IsSetupJobCompleted(ctx, r.Client, store)
if err != nil {
return err
}

// The job is not completed because active containers are running
if !done {
if err = job.DeleteSetupJob(ctx, r.Client, store); err != nil {
return err
}
}

done, err = job.IsMigrationJobCompleted(ctx, r.Client, store)
if err != nil {
return err
}

// The job is not completed because active containers are running
if !done {
if err = job.DeleteAllMigrationJobs(ctx, r.Client, store); err != nil {
return err
}
}

return nil
}

// func (r *StoreReconciler) applyFinalizers(ctx context.Context, store *v1.Store) error {
// log := log.FromContext(ctx).WithName(store.Name)
// log.Info("Applying finalizers")
Expand Down
Loading