Skip to content

Add the ability to override the timeout value for individual pipeline tasks via taskRunSpecs in a pipelineRun #7752

Open
@jvsol459

Description

@jvsol459

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" 

Metadata

Metadata

Labels

area/apiIndicates an issue or PR that deals with the API.kind/featureCategorizes issue or PR as related to a new feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions