Skip to content

Commit

Permalink
Adds timeout to pipeline start
Browse files Browse the repository at this point in the history
Close #706

This adds a timeout option to `tkn pipeline start` command
timeout is string variable and value can be in format `1h10m2s`
default timeout value is `1h`

Signed-off-by: Pradeep Kumar <pradkuma@redhat.com>
  • Loading branch information
pradeepitm12 authored and tekton-robot committed Feb 18, 2020
1 parent 6850371 commit 89b475a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/cmd/tkn_pipeline_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ two parameters (foo and bar)
-s, --serviceaccount string pass the serviceaccount name
--showlog show logs right after starting the pipeline
--task-serviceaccount strings pass the service account corresponding to the task
--timeout string timeout for pipelinerun (default "1h")
--use-pipelinerun string use this pipelinerun values to re-run the pipeline.
```

Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/tkn-pipeline-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ Parameters, at least those that have no default value
\fB\-\-task\-serviceaccount\fP=[]
pass the service account corresponding to the task

.PP
\fB\-\-timeout\fP="1h"
timeout for pipelinerun

.PP
\fB\-\-use\-pipelinerun\fP=""
use this pipelinerun values to re\-run the pipeline.
Expand Down
11 changes: 10 additions & 1 deletion pkg/cmd/pipeline/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os"
"strings"
"time"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
Expand Down Expand Up @@ -67,6 +68,7 @@ type startOptions struct {
DryRun bool
Output string
PrefixName string
TimeOut string
}

type resourceOptionsFilter struct {
Expand Down Expand Up @@ -161,6 +163,7 @@ like cat,foo,bar
c.Flags().BoolVarP(&opt.DryRun, "dry-run", "", false, "preview pipelinerun without running it")
c.Flags().StringVarP(&opt.Output, "output", "", "", "format of pipelinerun dry-run (yaml or json)")
c.Flags().StringVarP(&opt.PrefixName, "prefix-name", "", "", "specify a prefix for the pipelinerun name (must be lowercase alphanumeric characters)")
c.Flags().StringVarP(&opt.TimeOut, "timeout", "", "1h", "timeout for pipelinerun")

_ = c.MarkZshCompPositionalArgumentCustom(1, "__tkn_get_pipeline")

Expand Down Expand Up @@ -413,6 +416,12 @@ func (opt *startOptions) startPipeline(pName string) error {
},
}

timeoutDuration, err := time.ParseDuration(opt.TimeOut)
if err != nil {
return err
}
pr.Spec.Timeout = &metav1.Duration{Duration: timeoutDuration}

cs, err := opt.cliparams.Clients()
if err != nil {
return err
Expand Down Expand Up @@ -485,7 +494,7 @@ func (opt *startOptions) startPipeline(pName string) error {
return nil
}

fmt.Fprintf(opt.stream.Out, "Showing logs...\n")
fmt.Fprintf(opt.stream.Out, "Waiting for logs to be available...\n")
runLogOpts := &options.LogOptions{
PipelineName: pName,
PipelineRunName: prCreated.Name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ spec:
resourceRef:
name: scaffold-git
serviceAccountName: svc1
timeout: 1h0m0s
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"value": "value1"
}
],
"serviceAccountName": "svc1"
"serviceAccountName": "svc1",
"timeout": "1h0m0s"
},
"status": {}
}

0 comments on commit 89b475a

Please sign in to comment.