Skip to content

Commit

Permalink
Tune timeouts
Browse files Browse the repository at this point in the history
Signed-off-by: Zander Mackie <[email protected]>
  • Loading branch information
zmackie committed Mar 30, 2020
1 parent 4841580 commit d34037d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PACKAGE_BASE=github.com/buildpacks/pack
PACKAGES:=$(shell $(GOCMD) list ./... | grep -v /testdata/)
SRC:=$(shell find . -type f -name '*.go' -not -path "*/vendor/*")
ARCHIVE_NAME=pack-$(PACK_VERSION)
TEST_TIMEOUT?=60s
TEST_TIMEOUT?=600s
UNIT_TIMEOUT?=$(TEST_TIMEOUT)
ACCEPTANCE_TIMEOUT?=$(TEST_TIMEOUT)

Expand Down
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Client struct {

type ClientOption func(c *Client)

var ClientTimeout = 1 * time.Minute

// WithLogger supply your own logger.
func WithLogger(l logging.Logger) ClientOption {
return func(c *Client) {
Expand Down Expand Up @@ -107,7 +109,7 @@ func NewClient(opts ...ClientOption) (*Client, error) {
client.docker, err = dockerClient.NewClientWithOpts(
dockerClient.FromEnv,
dockerClient.WithVersion("1.38"),
dockerClient.WithTimeout(10*time.Second),
dockerClient.WithTimeout(ClientTimeout),
)
if err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions cmd/pack/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"os"
"time"

"github.com/heroku/color"
"github.com/pkg/errors"
Expand Down Expand Up @@ -80,7 +79,7 @@ func main() {
rootCmd.Version = cmd.Version
rootCmd.SetVersionTemplate(`{{.Version}}{{"\n"}}`)

ctx := commands.CreateTimeoutContext(10 * time.Second)
ctx := commands.CreateCancellableContext()
if err := rootCmd.ExecuteContext(ctx); err != nil {
if commands.IsSoftError(err) {
os.Exit(2)
Expand Down
5 changes: 2 additions & 3 deletions internal/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"os/signal"
"syscall"
"time"

"github.com/spf13/cobra"

Expand All @@ -29,10 +28,10 @@ func AddHelpFlag(cmd *cobra.Command, commandName string) {
cmd.Flags().BoolP("help", "h", false, fmt.Sprintf("Help for '%s'", commandName))
}

func CreateTimeoutContext(timeout time.Duration) context.Context {
func CreateCancellableContext() context.Context {
signals := make(chan os.Signal)
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
ctx, cancel := context.WithCancel(context.Background())

go func() {
<-signals
Expand Down

0 comments on commit d34037d

Please sign in to comment.