Skip to content

Commit

Permalink
Merge pull request #45 from shopware/remove-del-for-jobs
Browse files Browse the repository at this point in the history
fix: remove deletions of containers after job finishes
  • Loading branch information
TrayserCassa authored Oct 7, 2024
2 parents d560c02 + 55434e1 commit b368cba
Showing 1 changed file with 8 additions and 34 deletions.
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

0 comments on commit b368cba

Please sign in to comment.