Skip to content

Commit

Permalink
fix(tekton): Allow setting pipeline timeout and set default on Pipeli…
Browse files Browse the repository at this point in the history
…neRun to 240 hours (jenkins-x#4251)

* fix(tekton): Set a default PipelineRun timeout of 10 days

Starting in Tekton Pipelines v0.4.0, the default timeout for
`TaskRun`s of 10 minutes when no timeout is specified is actually
enforced. The only way to specify a timeout for a `TaskRun` is by
setting a timeout on the `PipelineRun`, so until
tektoncd/pipeline#978 and/or
tektoncd/pipeline#979 are addressed, we
should just set a ridiculously high timeout on all `PipelineRun`s.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>

* fix(tekton): Allow configuring Pipeline timeout

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
  • Loading branch information
abayer authored and David Conde committed Apr 7, 2020
1 parent f63b76a commit 7a80085
Show file tree
Hide file tree
Showing 34 changed files with 549 additions and 21 deletions.
10 changes: 9 additions & 1 deletion pkg/cmd/step/create/step_create_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,15 @@ func (o *StepCreateTaskOptions) GenerateTektonCRDs(packsDir string, projectConfi

tasks, pipeline = o.EnhanceTasksAndPipeline(tasks, pipeline, pipelineConfig.Env)
resources := []*pipelineapi.PipelineResource{tekton.GenerateSourceRepoResource(pipelineResourceName, o.GitInfo, o.Revision)}
run := tekton.CreatePipelineRun(resources, pipeline.Name, pipeline.APIVersion, o.labels, o.Trigger, o.ServiceAccount, o.pipelineParams)

var timeout *metav1.Duration
if parsed.Options != nil && parsed.Options.Timeout != nil {
timeout, err = parsed.Options.Timeout.ToDuration()
if err != nil {
return nil, errors.Wrapf(err, "parsing of pipeline timeout failed")
}
}
run := tekton.CreatePipelineRun(resources, pipeline.Name, pipeline.APIVersion, o.labels, o.Trigger, o.ServiceAccount, o.pipelineParams, timeout)

tektonCRDs, err := tekton.NewCRDWrapper(pipeline, tasks, resources, structure, run)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/step/create/step_create_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ func TestGenerateTektonCRDs(t *testing.T) {
branch: "really-long",
kind: "release",
},
{
name: "pipeline-timeout",
language: "none",
repoName: "js-test-repo",
organization: "abayer",
branch: "really-long",
kind: "release",
},
}

k8sObjects := []runtime.Object{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-golang-qs-test-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-jx-demo-qs-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-jx-demo-qs-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-golang-qs-test-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-build-pack
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: jenkins-x-jx-fix-kaniko-special
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-jx-demo-qs-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-jx-demo-qs-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-override-de
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-golang-qs-test-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-jx-demo-qs-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-golang-qs-test-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ spec:
apiVersion: tekton.dev/v1alpha1
name: abayer-golang-qs-test-master
serviceAccount: tekton-bot
timeout: 240h0m0s
trigger:
type: manual
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pipelineConfig:
env:
- name: FRUIT
value: BANANA
pipelines:
release:
pipeline:
env:
- name: GIT_AUTHOR_NAME
value: somebodyelse
options:
timeout:
time: 10
unit: hours
containerOptions:
resources:
requests:
cpu: 0.1
memory: 64Mi
agent:
image: nodejs
stages:
- name: Build-a-really-long-stage-name-please-but-not-too-long-thanks
steps:
- command: echo
args:
- hello world
- command: ls
args:
- -la
env:
- name: ANOTHER_VAR
value: Another value
- name: Second
steps:
- command: echo
args:
- hi ${FRUIT}
options:
containerOptions:
resources:
limits:
cpu: 0.4
memory: 256Mi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
creationTimestamp: null
name: abayer-js-test-repo-really-long-1
namespace: jx
labels:
branch: really-long
owner: abayer
repo: js-test-repo
spec:
params:
- default: 0.0.1
description: the version number for this pipeline which is used as a tag on docker
images and helm charts
name: version
resources:
- name: abayer-js-test-repo-really-long
type: git
tasks:
- name: build-a-really-long-stage-name-please-but-not-too-long-thanks
params:
- name: version
value: ${params.version}
resources:
inputs:
- name: workspace
resource: abayer-js-test-repo-really-long
outputs:
- name: workspace
resource: abayer-js-test-repo-really-long
taskRef:
name: abayer-js-test-repo-really-long-build-a-really-long-stage-nam-1
- name: second
params:
- name: version
value: ${params.version}
resources:
inputs:
- from:
- build-a-really-long-stage-name-please-but-not-too-long-thanks
name: workspace
resource: abayer-js-test-repo-really-long
runAfter:
- build-a-really-long-stage-name-please-but-not-too-long-thanks
taskRef:
name: abayer-js-test-repo-really-long-second-1
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
items:
- apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
creationTimestamp: null
name: abayer-js-test-repo-really-long
spec:
params:
- name: revision
value: v0.0.1
- name: url
value: https://github.com/abayer/js-test-repo
type: git
status: {}
metadata: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
creationTimestamp: null
labels:
branch: really-long
owner: abayer
repo: js-test-repo
name: abayer-js-test-repo-really-long-1
spec:
params:
- name: version
value: 0.0.1
pipelineRef:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long-1
resources:
- name: abayer-js-test-repo-really-long
resourceRef:
apiVersion: tekton.dev/v1alpha1
name: abayer-js-test-repo-really-long
serviceAccount: tekton-bot
timeout: 10h0m0s
trigger:
type: manual
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
metadata:
creationTimestamp: null
name: abayer-js-test-repo-really-long-1
labels:
branch: really-long
owner: abayer
repo: js-test-repo
pipelineRef: null
pipelineRunRef: null
stages:
- depth: 0
name: Build-a-really-long-stage-name-please-but-not-too-long-thanks
taskRef: abayer-js-test-repo-really-long-build-a-really-long-stage-nam-1
- depth: 0
name: Second
previous: Build-a-really-long-stage-name-please-but-not-too-long-thanks
taskRef: abayer-js-test-repo-really-long-second-1
Loading

0 comments on commit 7a80085

Please sign in to comment.