Skip to content

Commit

Permalink
Merge pull request #59 from shopware/fix-job-deletion
Browse files Browse the repository at this point in the history
fix: job deletion moved to ready state
  • Loading branch information
TrayserCassa authored Oct 21, 2024
2 parents e6dda55 + e690ab6 commit 7714515
Showing 1 changed file with 13 additions and 13 deletions.
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

0 comments on commit 7714515

Please sign in to comment.