diff --git a/pkg/reconciler/taskrun/taskrun.go b/pkg/reconciler/taskrun/taskrun.go index 47a254af469..a11942fcb2a 100644 --- a/pkg/reconciler/taskrun/taskrun.go +++ b/pkg/reconciler/taskrun/taskrun.go @@ -783,6 +783,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) @@ -795,7 +801,6 @@ func (c *Reconciler) failTaskRun(ctx context.Context, tr *v1.TaskRun, reason v1. return err } - terminateStepsInPod(tr, reason) return nil }