Skip to content

Commit 45c015b

Browse files
committed
fix: check job completion on re-entry to prevent premature pre-init cleanup
The plan.Phase == TaskPlanComplete check at the top of reconcilePreInitializing was bypassing the isJobComplete guard on subsequent reconcile loops, allowing cleanup to proceed while seid was still syncing to halt-height. Add the Job completion check to the re-entry path so cleanup only happens after the Job actually finishes.
1 parent 86834b9 commit 45c015b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

internal/controller/node/pre_init.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ func (r *SeiNodeReconciler) reconcilePreInitializing(ctx context.Context, node *
2424
plan := node.Status.PreInitPlan
2525

2626
if plan.Phase == seiv1alpha1.TaskPlanComplete {
27+
if len(plan.Tasks) > 0 {
28+
job := &batchv1.Job{}
29+
key := types.NamespacedName{Name: preInitJobName(node), Namespace: node.Namespace}
30+
if err := r.Get(ctx, key, job); err == nil && !isJobComplete(job) && !isJobFailed(job) {
31+
log.FromContext(ctx).Info("pre-init plan complete, waiting for seid to reach halt-height", "job", job.Name)
32+
return ctrl.Result{RequeueAfter: taskPollInterval}, nil
33+
}
34+
}
2735
if err := r.cleanupPreInit(ctx, node); err != nil {
2836
return ctrl.Result{}, fmt.Errorf("cleaning up pre-init resources: %w", err)
2937
}

0 commit comments

Comments
 (0)