Skip to content

Commit

Permalink
Fix default-timeout from config not correctly set 😓
Browse files Browse the repository at this point in the history
Make sure we always read from the config-default map to set the
timeout on PipelineRun and TaskRun.
Remove the pre 0.5.0 behavior, it has been 6 release since then.

Signed-off-by: Vincent Demeester <[email protected]>
(cherry picked from commit 44ccf4d)
  • Loading branch information
vdemeester authored and Scott committed Apr 8, 2020
1 parent 6303ce9 commit 82e2758
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
12 changes: 1 addition & 11 deletions pkg/apis/pipeline/v1beta1/pipelinerun_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/contexts"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)
Expand All @@ -35,16 +34,7 @@ func (pr *PipelineRun) SetDefaults(ctx context.Context) {
func (prs *PipelineRunSpec) SetDefaults(ctx context.Context) {
cfg := config.FromContextOrDefaults(ctx)
if prs.Timeout == nil {
var timeout *metav1.Duration
if contexts.IsUpgradeViaDefaulting(ctx) {
// This case is for preexisting `TaskRun` before 0.5.0, so let's
// add the old default timeout.
// Most likely those TaskRun passing here are already done and/or already running
timeout = &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}
} else {
timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}
prs.Timeout = timeout
prs.Timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}

defaultSA := cfg.Defaults.DefaultServiceAccount
Expand Down
12 changes: 1 addition & 11 deletions pkg/apis/pipeline/v1beta1/taskrun_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"time"

"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/contexts"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)
Expand All @@ -39,16 +38,7 @@ func (trs *TaskRunSpec) SetDefaults(ctx context.Context) {
}

if trs.Timeout == nil {
var timeout *metav1.Duration
if contexts.IsUpgradeViaDefaulting(ctx) {
// This case is for preexisting `TaskRun` before 0.5.0, so let's
// add the old default timeout.
// Most likely those TaskRun passing here are already done and/or already running
timeout = &metav1.Duration{Duration: config.DefaultTimeoutMinutes * time.Minute}
} else {
timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}
trs.Timeout = timeout
trs.Timeout = &metav1.Duration{Duration: time.Duration(cfg.Defaults.DefaultTimeoutMinutes) * time.Minute}
}

defaultSA := cfg.Defaults.DefaultServiceAccount
Expand Down

0 comments on commit 82e2758

Please sign in to comment.