summaryrefslogtreecommitdiff
path: root/libkpod
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2017-11-21 15:31:20 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-11-21 22:03:13 +0000
commit768fb6fe0f59467442a1aaaa4ca863d179255020 (patch)
tree0fa500b5edfb9768e52bd935dad9bba967fadb3a /libkpod
parent4ff251d9118dfebde744fce8a2e2069144f259a4 (diff)
downloadpodman-768fb6fe0f59467442a1aaaa4ca863d179255020.tar.gz
podman-768fb6fe0f59467442a1aaaa4ca863d179255020.tar.bz2
podman-768fb6fe0f59467442a1aaaa4ca863d179255020.zip
Update kpod rm to use new container state
kpod rm now uses the new container state and runtime Signed-off-by: Urvashi Mohnani <umohnani@redhat.com> Closes: #58 Approved by: mheon
Diffstat (limited to 'libkpod')
-rw-r--r--libkpod/remove.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/libkpod/remove.go b/libkpod/remove.go
deleted file mode 100644
index 529348840..000000000
--- a/libkpod/remove.go
+++ /dev/null
@@ -1,53 +0,0 @@
-package libkpod
-
-import (
- "os"
- "path/filepath"
-
- "github.com/pkg/errors"
- "github.com/projectatomic/libpod/oci"
- "golang.org/x/net/context"
-)
-
-// Remove removes a container
-func (c *ContainerServer) Remove(ctx context.Context, container string, force bool) (string, error) {
- ctr, err := c.LookupContainer(container)
- if err != nil {
- return "", err
- }
- ctrID := ctr.ID()
-
- cStatus := c.runtime.ContainerStatus(ctr)
- switch cStatus.Status {
- case oci.ContainerStatePaused:
- return "", errors.Errorf("cannot remove paused container %s", ctrID)
- case oci.ContainerStateCreated, oci.ContainerStateRunning:
- if force {
- _, err = c.ContainerStop(ctx, container, 10)
- if err != nil {
- return "", errors.Wrapf(err, "unable to stop container %s", ctrID)
- }
- } else {
- return "", errors.Errorf("cannot remove running container %s", ctrID)
- }
- }
-
- if err := c.runtime.DeleteContainer(ctr); err != nil {
- return "", errors.Wrapf(err, "failed to delete container %s", ctrID)
- }
- if err := os.Remove(filepath.Join(c.Config().RuntimeConfig.ContainerExitsDir, ctrID)); err != nil && !os.IsNotExist(err) {
- return "", errors.Wrapf(err, "failed to remove container exit file %s", ctrID)
- }
- c.RemoveContainer(ctr)
-
- if err := c.storageRuntimeServer.DeleteContainer(ctrID); err != nil {
- return "", errors.Wrapf(err, "failed to delete storage for container %s", ctrID)
- }
-
- c.ReleaseContainerName(ctr.Name())
-
- if err := c.ctrIDIndex.Delete(ctrID); err != nil {
- return "", err
- }
- return ctrID, nil
-}