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

Adds timeout to pipeline start #741

Merged
merged 1 commit into from
Feb 18, 2020
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
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": {}
}