Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tekton): Allow setting pipeline timeout and set default on PipelineRun to 240 hours #4251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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