Skip to content

Commit

Permalink
Mark steps as deleted when TaskRun fails
Browse files Browse the repository at this point in the history
Today this is done after the Pod is handled. If Pod deletion fails
for some reason, the steps are not updated.

Tekton only makes one attempt to delete the Pod to try and avoid
that it keeps running even if the TaskRun failed. If this deletion
fails for whatever reason, Tekton should still update the TaskRun
status to mark the steps as failed, as they are failed from
Tekton POV.

Fixes: tektoncd#8293

Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
  • Loading branch information
afrittoli authored and tekton-robot committed Sep 25, 2024
1 parent 2e6f795 commit 7ee8442
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/reconciler/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1.TaskRun, reason v1.
return nil
}

// When the TaskRun is failed, we mark all running/waiting steps as failed
// This is regardless of what happens with the Pod, which may be cancelled,
// deleted, non existing or fail to delete
// See https://github.com/tektoncd/pipeline/issues/8293 for more details.
terminateStepsInPod(tr, reason)

var err error
if reason == v1.TaskRunReasonCancelled && (config.FromContextOrDefaults(ctx).FeatureFlags.EnableKeepPodOnCancel) {
logger.Infof("Canceling task run %q by entrypoint", tr.Name)
Expand All @@ -818,7 +824,6 @@ func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1.TaskRun, reason v1.
return err
}

terminateStepsInPod(tr, reason)
return nil
}

Expand Down

0 comments on commit 7ee8442

Please sign in to comment.