Description
Feature request
Provide the ability to override the timeout
value for individual pipeline tasks via taskRunSpecs in a pipelineRun. Alternatively, allow parameter interpolation in timeout
fields, so timeouts can be overriden via parameters.
Use case
Consider the following pipeline, which is stored remotely and consumed by the pipelineRuns also noted below.
If it's a weekday, it is fine to consume the daily-routine as is and work eight hours, decompress eight hours, and sleep for eight hours. If it's a weekday, we also need to make sure we do not perform any of these tasks for more than 8 hours; hence, the timeout value is set for each task.
On the weekend, we only want to work for one hour, decompress for 14, and sleep for nine; however, our decompress and sleep tasks are going to timeout after eight hours, and there is no way to override the task timeout values in the remote pipeline.
We could remove the timeout values for tasks, but then the global task timeout value of 60 minutes will kick-in. We could also set the timeout for all tasks to 0 to disable the timeout, and use timeouts
for the pipelineRun to control the timeout for all tasks, but that does not solve the problem of being able to override individual task timeouts.
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: daily-routine
spec:
params:
- name: work
default: '8h'
- name: decompress
default: '8h'
- name: sleep
default: '8h'
tasks:
- name: work
timeout: "8h0m0s"
params:
- name: duration
value: $(params.work)
taskSpec:
params:
- name: duration
type: string
steps:
- name: sleep
image: registry.access.redhat.com/ubi9/ubi-micro
script: |
echo "**********************"
echo "Working for $(params.duration)"
sleep "$(params.duration)"
echo "**********************"
- name: decompress
timeout: "8h0m0s"
runAfter: [work]
params:
- name: duration
value: $(params.decompress)
taskSpec:
params:
- name: duration
type: string
steps:
- name: sleep
image: registry.access.redhat.com/ubi9/ubi-micro
script: |
echo "**********************"
echo "Relaxing for $(params.duration)"
sleep "$(params.duration)"
echo "**********************"
- name: sleep
timeout: "8h0m0s"
runAfter: [decompress]
params:
- name: duration
value: $(params.sleep)
taskSpec:
params:
- name: duration
type: string
steps:
- name: sleep
image: registry.access.redhat.com/ubi9/ubi-micro
script: |
echo "**********************"
echo "Sleeping for $(params.duration)"
sleep "$(params.duration)"
echo "**********************"
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: weekday
spec:
pipelineRef:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/jvsol459/test/main/daily-routine.yaml
timeouts:
pipeline: "24h0m0s"
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: weekend
spec:
pipelineRef:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/jvsol459/test/main/daily-routine.yaml
params:
- name: work
value: '1h'
- name: decompress
value: '14h'
- name: sleep
value: '9h'
timeouts:
pipeline: "24h0m0s"
Possible solution:
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: weekend
spec:
pipelineRef:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/jvsol459/test/main/daily-routine.yaml
params:
- name: work
value: '1h'
- name: decompress
value: '14h'
- name: sleep
value: '9h'
timeouts:
pipeline: "24h0m0s"
taskRunSpecs:
- pipelineTaskName: work
timeout: "1h0m0s"
- pipelineTaskName: decompress
timeout: "14h0m0s"
- pipelineTaskName: sleep
timeout: "9h0m0s"