From 9e81f9daa4af9802088530a35a72814172430a36 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 21 Sep 2018 09:40:30 -0400 Subject: Refactor Wait() to not require a timeout We added a timeout for convenience, but most invocations don't care about it. Refactor it into WaitWithTimeout() and add a Wait() that doesn't require a timeout and uses the default. Signed-off-by: Matthew Heon Closes: #1527 Approved by: mheon --- cmd/podman/run.go | 2 +- cmd/podman/start.go | 2 +- cmd/podman/wait.go | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/run.go b/cmd/podman/run.go index ce7d0c40f..f9a96e4a6 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -121,7 +121,7 @@ func runCmd(c *cli.Context) error { return err } - if ecode, err := ctr.Wait(libpod.WaitTimeout); err != nil { + if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { // The container may have been removed // Go looking for an exit file diff --git a/cmd/podman/start.go b/cmd/podman/start.go index a80d0e1e8..cb65ec6d4 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -115,7 +115,7 @@ func startCmd(c *cli.Context) error { return errors.Wrapf(err, "unable to start container %s", ctr.ID()) } - if ecode, err := ctr.Wait(libpod.WaitTimeout); err != nil { + if ecode, err := ctr.Wait(); err != nil { logrus.Errorf("unable to get exit code of container %s: %q", ctr.ID(), err) } else { exitCode = int(ecode) diff --git a/cmd/podman/wait.go b/cmd/podman/wait.go index 48d3885e7..07db20eee 100644 --- a/cmd/podman/wait.go +++ b/cmd/podman/wait.go @@ -6,7 +6,6 @@ import ( "time" "github.com/containers/libpod/cmd/podman/libpodruntime" - "github.com/containers/libpod/libpod" "github.com/pkg/errors" "github.com/urfave/cli" ) @@ -21,7 +20,7 @@ var ( cli.UintFlag{ Name: "interval, i", Usage: "Milliseconds to wait before polling for completion", - Value: uint(libpod.WaitTimeout), + Value: 250, }, LatestFlag, } @@ -69,7 +68,7 @@ func waitCmd(c *cli.Context) error { if c.Uint("interval") == 0 { return errors.Errorf("interval must be greater then 0") } - returnCode, err := ctr.Wait(time.Duration(c.Uint("interval"))) + returnCode, err := ctr.WaitWithInterval(time.Duration(c.Uint("interval")) * time.Millisecond) if err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) -- cgit v1.2.3-54-g00ecf