diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 23 | ||||
-rw-r--r-- | libpod/container_api.go | 4 | ||||
-rw-r--r-- | libpod/container_internal.go | 6 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 4 | ||||
-rw-r--r-- | libpod/oci.go | 1 |
5 files changed, 33 insertions, 5 deletions
diff --git a/libpod/container.go b/libpod/container.go index 6d5e063ab..523e571b1 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -401,6 +401,29 @@ func (t ContainerStatus) String() string { return "bad state" } +// StringToContainerStatus converts a string representation of a containers +// status into an actual container status type +func StringToContainerStatus(status string) (ContainerStatus, error) { + switch status { + case ContainerStateUnknown.String(): + return ContainerStateUnknown, nil + case ContainerStateConfigured.String(): + return ContainerStateConfigured, nil + case ContainerStateCreated.String(): + return ContainerStateCreated, nil + case ContainerStateRunning.String(): + return ContainerStateRunning, nil + case ContainerStateStopped.String(): + return ContainerStateStopped, nil + case ContainerStatePaused.String(): + return ContainerStatePaused, nil + case ContainerStateExited.String(): + return ContainerStateExited, nil + default: + return ContainerStateUnknown, errors.Wrapf(ErrInvalidArg, "unknown container state: %s", status) + } +} + // Config accessors // Unlocked diff --git a/libpod/container_api.go b/libpod/container_api.go index 2a2381923..465b23831 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -15,7 +15,7 @@ import ( "github.com/containers/libpod/pkg/lookup" "github.com/containers/storage/pkg/stringid" "github.com/docker/docker/oci/caps" - opentracing "github.com/opentracing/opentracing-go" + "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/util/wait" @@ -174,7 +174,7 @@ func (c *Container) StopWithTimeout(timeout uint) error { if c.state.State == ContainerStateConfigured || c.state.State == ContainerStateUnknown || c.state.State == ContainerStatePaused { - return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers") + return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers. %s in state %s", c.ID(), c.state.State.String()) } if c.state.State == ContainerStateStopped || diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 22df36c11..3c7319963 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -948,7 +948,7 @@ func (c *Container) start() error { // Internal, non-locking function to stop container func (c *Container) stop(timeout uint) error { - logrus.Debugf("Stopping ctr %s with timeout %d", c.ID(), timeout) + logrus.Debugf("Stopping ctr %s (timeout %d)", c.ID(), timeout) if err := c.runtime.ociRuntime.stopContainer(c, timeout); err != nil { return err @@ -1064,14 +1064,16 @@ func (c *Container) mountStorage() (string, error) { func (c *Container) cleanupStorage() error { if !c.state.Mounted { // Already unmounted, do nothing - logrus.Debugf("Storage is already unmounted, skipping...") + logrus.Debugf("Container %s storage is already unmounted, skipping...", c.ID()) return nil } + for _, mount := range c.config.Mounts { if err := c.unmountSHM(mount); err != nil { return err } } + if c.config.Rootfs != "" { return nil } diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 4d6bf61a3..eeffa4705 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -30,7 +30,7 @@ import ( spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/generate" "github.com/opencontainers/selinux/go-selinux/label" - opentracing "github.com/opentracing/opentracing-go" + "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" "golang.org/x/sys/unix" @@ -48,6 +48,8 @@ func (c *Container) unmountSHM(mount string) error { if err := unix.Unmount(mount, unix.MNT_DETACH); err != nil { if err != syscall.EINVAL { logrus.Warnf("container %s failed to unmount %s : %v", c.ID(), mount, err) + } else { + logrus.Debugf("container %s failed to unmount %s : %v", c.ID(), mount, err) } } return nil diff --git a/libpod/oci.go b/libpod/oci.go index 62331b879..189359753 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -143,6 +143,7 @@ func waitContainerStop(ctr *Container, timeout time.Duration) error { return nil case <-time.After(timeout): close(chControl) + logrus.Debugf("container %s did not die within timeout %d", ctr.ID(), timeout) return errors.Errorf("container %s did not die within timeout", ctr.ID()) } } |