Skip to content

Commit

Permalink
Move where boot option status is set to be consistent:
Browse files Browse the repository at this point in the history
handleJob no longer deals with setting bootOption status,
just conditions.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Oct 10, 2024
1 parent cdd0ad7 commit 604d09b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
16 changes: 8 additions & 8 deletions internal/deprecated/workflow/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ func (s *state) handleJob(ctx context.Context, actions []rufio.Action, name jobN
if err != nil {
return result, err
}
jStatus := s.workflow.Status.BootOptions.Jobs[name.String()]
jStatus.ExistingJobDeleted = true
s.workflow.Status.BootOptions.Jobs[name.String()] = jStatus

return result, nil
}

Expand Down Expand Up @@ -101,6 +99,13 @@ func (s *state) deleteExisting(ctx context.Context, name jobName) (reconcile.Res
return reconcile.Result{}, fmt.Errorf("error deleting job.bmc.tinkerbell.org object: %w", err)
}

jStatus := s.workflow.Status.BootOptions.Jobs[name.String()]
jStatus.ExistingJobDeleted = true
// if we delete an existing job, we need to remove any uid that was set.
jStatus.UID = ""
jStatus.Complete = false
s.workflow.Status.BootOptions.Jobs[name.String()] = jStatus

return reconcile.Result{Requeue: true}, nil
}

Expand Down Expand Up @@ -133,11 +138,6 @@ func (s *state) createJob(ctx context.Context, actions []rufio.Action, name jobN
return reconcile.Result{}, fmt.Errorf("error creating job: %w", err)
}

// update the status with the UID
jStatus := s.workflow.Status.BootOptions.Jobs[name.String()]
jStatus.UID = rj.GetUID()
s.workflow.Status.BootOptions.Jobs[name.String()] = jStatus

return reconcile.Result{Requeue: true}, nil
}

Expand Down
10 changes: 8 additions & 2 deletions internal/deprecated/workflow/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco

return resp, serrors.Join(err, mergePatchStatus(ctx, r.client, stored, wflow))
case v1alpha1.WorkflowStatePreparing:
hw, _ := hardwareFrom(ctx, r.client, wflow)
hw, err := hardwareFrom(ctx, r.client, wflow)
if err != nil {
return reconcile.Result{}, err
}
s := &state{
client: r.client,
workflow: wflow,
Expand All @@ -99,7 +102,10 @@ func (r *Reconciler) Reconcile(ctx context.Context, req reconcile.Request) (reco

return reconcile.Result{}, mergePatchStatus(ctx, r.client, stored, wflow)
case v1alpha1.WorkflowStatePost:
hw, _ := hardwareFrom(ctx, r.client, wflow)
hw, err := hardwareFrom(ctx, r.client, wflow)
if err != nil {
return reconcile.Result{}, err
}
s := &state{
client: r.client,
workflow: wflow,
Expand Down

0 comments on commit 604d09b

Please sign in to comment.