aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime_ctr.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-09 13:51:20 -0500
committerMatthew Heon <matthew.heon@gmail.com>2017-11-18 12:58:48 -0500
commit763e3726493c122d9722e0e294634ae8d78c426b (patch)
treea2b34450ab0dfe2131786315f393a1f7ca05ffdd /libpod/runtime_ctr.go
parentcb56716fc4bb632db84fab372fff8f5a9007ed3f (diff)
downloadpodman-763e3726493c122d9722e0e294634ae8d78c426b.tar.gz
podman-763e3726493c122d9722e0e294634ae8d78c426b.tar.bz2
podman-763e3726493c122d9722e0e294634ae8d78c426b.zip
Wire SQL backed state into rest of libpod
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r--libpod/runtime_ctr.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index b23c65287..a8a5b789d 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -95,17 +95,21 @@ func (r *Runtime) RemoveContainer(c *Container, force bool) error {
return ErrCtrRemoved
}
- // TODO check container status and unmount storage
- // TODO check that no other containers depend on this container's
- // namespaces
- status, err := c.State()
- if err != nil {
+ // Update the container to get current state
+ if err := r.state.UpdateContainer(c); err != nil {
return err
}
- // A container cannot be removed if it is running
- if status == ContainerStateRunning {
- return errors.Wrapf(ErrCtrStateInvalid, "cannot remove container %s as it is running", c.ID())
+ // Check that the container's in a good state to be removed
+ if !(c.state.State == ContainerStateConfigured ||
+ c.state.State == ContainerStateCreated ||
+ c.state.State == ContainerStateStopped) {
+ return errors.Wrapf(ErrCtrStateInvalid, "cannot remove container %s as it is running or paused", c.ID())
+ }
+
+ // Stop the container's storage
+ if err := c.teardownStorage(); err != nil {
+ return err
}
if err := r.state.RemoveContainer(c); err != nil {