From 52bc0037d31974cae452518cb3ba3d18e83a18fc Mon Sep 17 00:00:00 2001 From: Dan Lorenc Date: Mon, 30 Sep 2019 09:49:14 -0500 Subject: [PATCH] Add support for specifiying "0" as no-timeout for PipelineRuns. This was already done in #1040 for TaskRuns, but PipelineRuns seem to have been missed. This fixes #1303. --- pkg/apis/pipeline/v1alpha1/pipelinerun_types.go | 5 +++++ pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go index 7b740c82fac..33c7d120794 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types.go @@ -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" @@ -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 diff --git a/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go b/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go index 6df40728fc5..531c6f8166c 100644 --- a/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go +++ b/pkg/apis/pipeline/v1alpha1/pipelinerun_types_test.go @@ -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) {