* Bad merge against podman stop, restored overwritten code

Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
Jhon Honce
2019-03-04 11:55:23 -07:00
parent 54eecb02f0
commit ae47a7c47e
2 changed files with 43 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/adapter/shortcuts"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
// GetLatestContainer gets the latest Container and wraps it in an adapter Container
@ -45,9 +46,10 @@ func (r *LocalRuntime) LookupContainer(idOrName string) (*Container, error) {
// StopContainers stops container(s) based on CLI inputs.
// Returns list of successful id(s), map of failed id(s) + error, or error not from container
func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopValues) ([]string, map[string]error, error) {
timeout := uint(0)
if cli.Flags().Changed("timeout") {
timeout = uint(cli.Timeout)
var timeout *uint
if cli.Flags().Changed("timeout") || cli.Flags().Changed("time") {
t := uint(cli.Timeout)
timeout = &t
}
var (
@ -61,11 +63,18 @@ func (r *LocalRuntime) StopContainers(ctx context.Context, cli *cliconfig.StopVa
}
for _, c := range ctrs {
err := c.StopWithTimeout(timeout)
if err != nil && errors.Cause(err) != libpod.ErrCtrStopped {
failures[c.ID()] = err
} else {
if timeout == nil {
t := c.StopTimeout()
timeout = &t
logrus.Debugf("Set timeout to container %s default (%d)", c.ID(), *timeout)
}
if err := c.StopWithTimeout(*timeout); err == nil {
ok = append(ok, c.ID())
} else if errors.Cause(err) == libpod.ErrCtrStopped {
ok = append(ok, c.ID())
logrus.Debugf("Container %s is already stopped", c.ID())
} else {
failures[c.ID()] = err
}
}
return ok, failures, nil