-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.
Description
Problem
PipelineRun supports a "pending" status (spec.status: PipelineRunPending) that allows creating a PipelineRun without immediately starting execution. This is useful for:
- Scheduling/batch operations where you want to control when execution begins
- External admission control or approval workflows
- Resource management and queuing
However, TaskRun does not support this feature. When a TaskRun is created, it immediately starts execution (Pod creation), with no way to defer it.
Expected Behavior
TaskRun should support a pending status similar to PipelineRun:
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: my-taskrun
spec:
taskRef:
name: my-task
status: "TaskRunPending" # New: defer executionWhen pending:
- The TaskRun is created but no Pod is created
status.startTimeis not set- Condition is set to
Unknownwith reasonTaskRunPending - Clearing
spec.status(or setting to empty) starts execution - Setting
spec.status: TaskRunCancelledcancels without running
Current State
In pkg/apis/pipeline/v1/taskrun_types.go:
const (
// TaskRunSpecStatusCancelled is the only supported spec status
TaskRunSpecStatusCancelled = "TaskRunCancelled"
)In contrast, PipelineRun (pkg/apis/pipeline/v1/pipelinerun_types.go) supports:
PipelineRunSpecStatusPendingPipelineRunSpecStatusCancelledPipelineRunSpecStatusCancelledRunFinallyPipelineRunSpecStatusStoppedRunFinally
Proposed Changes
-
API (
pkg/apis/pipeline/v1/taskrun_types.go):- Add
TaskRunSpecStatusPending = "TaskRunPending"constant - Add
TaskRunReasonPending TaskRunReason = "TaskRunPending"reason - Add
IsPending()helper method
- Add
-
Validation (
pkg/apis/pipeline/v1/taskrun_validation.go):- Validate that TaskRun cannot be marked pending after it has started
- Update
validateSpecStatusto acceptTaskRunPending
-
Reconciler (
pkg/reconciler/taskrun/taskrun.go):- Check for pending status before creating Pod
- Set condition to
Unknownwith reasonTaskRunPending - Skip
StartTimeinitialization when pending - Return early from reconciliation
-
Documentation (
docs/taskruns.md):- Add section similar to "Pending PipelineRuns" in
docs/pipelineruns.md
- Add section similar to "Pending PipelineRuns" in
-
Tests:
- Add
TestReconcileOnPendingTaskRun(similar toTestReconcileOnPendingPipelineRun) - Validation tests for pending state constraints
- Add
Use Cases
- External scheduling: Create TaskRuns in advance, start them based on external triggers
- Approval workflows: Require manual approval before task execution
- Resource management: Queue tasks and start them when resources are available
- Batch operations: Create multiple TaskRuns, start them simultaneously
- Testing/debugging: Create TaskRuns in pending state for inspection before running
Related
- PipelineRun pending was added in commit
fbbcf71392e3(Nov 2020) - Documentation: Pending PipelineRuns
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.
Type
Projects
Status
Todo