Skip to content

Add pending status support for TaskRun (parity with PipelineRun)#9464

Open
sahilleth wants to merge 4 commits intotektoncd:mainfrom
sahilleth:feat/taskrun-pending-status
Open

Add pending status support for TaskRun (parity with PipelineRun)#9464
sahilleth wants to merge 4 commits intotektoncd:mainfrom
sahilleth:feat/taskrun-pending-status

Conversation

@sahilleth
Copy link
Contributor

@sahilleth sahilleth commented Mar 1, 2026

Changes

Adds pending status support for TaskRun to match the existing PipelineRun pending behavior.

Fixes #9376.

  • Introduces TaskRunPending (spec.status: TaskRunPending) in both v1 and v1beta1 APIs.
  • Adds TaskRunReasonPending and an IsPending() helper.
  • Updates validation to:
    • Allow TaskRunPending on new TaskRuns.
    • Reject TaskRunPending once the TaskRun has already started.
  • Updates the reconciler so that when a TaskRun is pending:
    • No Pod is created.
    • status.startTime is not set.
    • Clearing spec.status starts execution.
    • Setting TaskRunCancelled cancels without running.
  • Documents “Pending TaskRuns” in docs/taskruns.md with use cases and examples.
  • Adds tests:
    • TestReconcileOnPendingTaskRun.
    • Validation tests for valid pending and invalid “pending while running” scenarios.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind feature. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

TaskRun now supports spec.status: TaskRunPending to defer execution.
When pending, no Pod is created and status.startTime is not set.
Clearing spec.status starts execution, or setting TaskRunCancelled cancels without running.

@tekton-robot tekton-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Mar 1, 2026
@tekton-robot tekton-robot requested review from dibyom and twoGiants March 1, 2026 07:19
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 1, 2026
@sahilleth
Copy link
Contributor Author

Release Notes

TaskRun now supports spec.status: TaskRunPending to defer execution.
When pending, no Pod is created and status.startTime is not set.
Clearing spec.status starts execution, or setting TaskRunCancelled cancels without running.

@khrm
Copy link
Contributor

khrm commented Mar 2, 2026

@sahilleth Can you use the same PR format as other PRs?

@waveywaves
Copy link
Member

@sahilleth Thank you for this PR. I would like to echo @khrm s request here as well. Please update this and other PRs of yours based on the pull request template which is available and do go through the contribution guidelines as well. Again ! Thank you for the contrib !

@waveywaves
Copy link
Member

@sahilleth can you please rebase this PR ? Thank you.

@sahilleth sahilleth force-pushed the feat/taskrun-pending-status branch from 16720c5 to fb30378 Compare March 17, 2026 14:30
@sahilleth

This comment was marked as duplicate.

@sahilleth
Copy link
Contributor Author

@waveywaves - Thanks for the guidance, and for reviewing this PR!

I’ve updated this PR (and my other open PRs) to follow the pull request template and have gone through the contribution guidelines to make sure I’m aligned with the project’s expectations. Please let me know if there’s anything I should further adjust.

@vdemeester
Copy link
Member

@sahilleth is it fixing or closing an existing issue ?

@sahilleth
Copy link
Contributor Author

@vdemeester - Yes, this is intended to fix the pending TaskRun support gap tracked in #9376.

I’ve updated the PR description to include “Fixes #9376” so it will be closed automatically when this is merged.

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff. Implementation is clean and correctly mirrors the existing PipelineRun pending pattern:

  • API types (v1 and v1beta1): constants, IsPending() helper — consistent with PipelineRunPending
  • Validation: properly rejects pending on already-started TaskRuns
  • Reconciler: correct ordering (done → cancelled → pending → timeout → pod creation), skips InitializeConditions for pending, returns early with MarkResourceOngoing
  • Timeout handling is safe: HasTimedOut() returns false when StartTime is zero, so pending TaskRuns won't spuriously time out
  • Tests cover the pending reconciliation path and validation for both valid and invalid cases

No issues found.

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 17, 2026
@vdemeester
Copy link
Member

A couple of housekeeping items before this can merge:

  1. CI checks haven't triggered — looks like it needs a /kind label. Based on the PR description, this should be:
    /kind feature
    
  2. The release notes block isn't properly closed (missing the closing triple-backtick), which may be causing the do-not-merge/release-note-label-needed label.

Code-wise this looks good to go 👍

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 17, 2026
@sahilleth
Copy link
Contributor Author

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 18, 2026
@sahilleth
Copy link
Contributor Author

@vdemeester -
Thanks for the review and the pointers!

I’ve added /kind feature, fixed the release-notes block (closing the ```release-note fence), and updated the description to include “Fixes #9376”. Please let me know if you spot anything else that needs adjustment.

@sahilleth sahilleth force-pushed the feat/taskrun-pending-status branch from fb30378 to 7546e79 Compare March 18, 2026 14:05
@sahilleth
Copy link
Contributor Author

I’ve updated the branch to be up to date with main. Please let me know if anything else is needed.

@sahilleth
Copy link
Contributor Author

/assign @vdemeester

Thanks for the review ! I believe all feedback has been addressed and the PR is ready for merge.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Mar 19, 2026
@tekton-robot tekton-robot removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Mar 19, 2026
@sahilleth
Copy link
Contributor Author

Updated the release-note block to match the required format.

@sahilleth sahilleth force-pushed the feat/taskrun-pending-status branch 2 times, most recently from 4220fd5 to 7546e79 Compare March 19, 2026 18:27
TaskRun now supports spec.status: TaskRunPending to defer execution.
When pending, no Pod is created and StartTime is not set. Clearing
spec.status starts execution; setting TaskRunCancelled cancels without running.

- Add TaskRunSpecStatusPending and TaskRunReasonPending to v1 and v1beta1
- Update validation to accept TaskRunPending and reject it after start
- Update reconciler to handle pending (no Pod creation, set Unknown condition)
- Add docs/taskruns.md Pending TaskRuns section
- Add reconcile and validation tests

Fixes tektoncd#9376
@sahilleth sahilleth force-pushed the feat/taskrun-pending-status branch from 7546e79 to 6efc4fb Compare March 19, 2026 18:29
@sahilleth
Copy link
Contributor Author

sahilleth commented Mar 20, 2026

@vdemeester -
All checks are green - could you /lgtm so Tide can pick this up?
Thanks!

@sahilleth
Copy link
Contributor Author

Hi @twoGiants, just a gentle follow-up - I’ve updated the release-note block to match the required format.
Would appreciate a review whenever you get a chance.

@vdemeester
Copy link
Member

@sahilleth lgtm needs to be set by someone else than me indeed 😛

@sahilleth
Copy link
Contributor Author

Ahh got it @vdemeester - thanks!
(Therefore I tagged (@) twoGiants a moment ago . )

Copy link
Member

@waveywaves waveywaves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

3 inline comments. The concept is correct and mirrors PipelineRun's pending support. A few things to consider around reconciler ordering, test coverage, and timeout behavior.

@vdemeester vdemeester added this to the v1.11.0 milestone Mar 25, 2026
Covers Pending->Running and Pending->Cancelled transitions to ensure reconciler behavior stays correct.
Copy link
Contributor Author

@sahilleth sahilleth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and the detailed feedback @waveywaves !
I’ve added follow-up tests to cover the missing lifecycle transitions:

  • pending → running (clearing spec.status resumes execution and creates the Pod)
  • pending → cancelled (ensures it cancels without starting)
  • I also updated the docs to clarify that the timeout does not start while the TaskRun is pending and only begins once execution starts.

Please let me know if you’d like any further refinements.

@sahilleth
Copy link
Contributor Author

/retest

@sahilleth
Copy link
Contributor Author

sahilleth commented Mar 27, 2026

ci / e2e-tests / e2e tests (ubuntu-latest, k8s-latest, alpha) (pull_request) failed due to cluster metrics API unavailability, not TaskRun logic changes.
Failure shows:

  • FailedGetResourceMetric / FailedComputeMetricsReplicas on horizontalpodautoscaler/tekton-pipelines-webhook
  • unable to fetch metrics ... (get pods.metrics.k8s.io)

This indicates metrics-server/metrics.k8s.io was unavailable in the e2e kind cluster for that run.

@sahilleth
Copy link
Contributor Author

Hello @waveywaves ,
It looks like my /retest comment didn’t trigger the chatops workflow (possibly permission-related).
Could you please run /retest on this PR?
Thanks!

@vdemeester
Copy link
Member

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pending status support for TaskRun (parity with PipelineRun)

5 participants