Skip to content

Commit

Permalink
Add support for specifiying "0" as no-timeout for PipelineRuns.
Browse files Browse the repository at this point in the history
This was already done in #1040 for TaskRuns, but PipelineRuns seem to have been missed.
This fixes #1303.
  • Loading branch information
dlorenc authored and tekton-robot committed Sep 30, 2019
1 parent 4b75911 commit 52bc003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/apis/pipeline/v1alpha1/pipelinerun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"fmt"
"time"

"github.com/tektoncd/pipeline/pkg/apis/config"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down Expand Up @@ -257,6 +259,9 @@ func (pr *PipelineRun) IsTimedOut() bool {

if !startTime.IsZero() && pipelineTimeout != nil {
timeout := pipelineTimeout.Duration
if timeout == config.NoTimeoutDuration {
return false
}
runtime := time.Since(startTime.Time)
if runtime > timeout {
return true
Expand Down
8 changes: 7 additions & 1 deletion pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ func TestPipelineRunHasTimedOut(t *testing.T) {
timeout: 25 * time.Hour,
starttime: time.Now().AddDate(0, 0, -1),
expected: false,
}}
}, {
name: "notimeoutspecified",
timeout: 0 * time.Second,
starttime: time.Now().AddDate(0, 0, -1),
expected: false,
},
}

for _, tc := range tcs {
t.Run(t.Name(), func(t *testing.T) {
Expand Down

0 comments on commit 52bc003

Please sign in to comment.