summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-05-02 20:45:44 +0200
committerGitHub <noreply@github.com>2019-05-02 20:45:44 +0200
commitccf28a89bdded86b044f2fd3aa3389b923a81988 (patch)
tree2acc41efb2ade3f451004a2d00c702eaeba53cad /libpod
parent3cec403268cf311ed21d981089236cabd0bd66f7 (diff)
parent4b339145356e505971aa04773ef733c2938687ff (diff)
downloadpodman-ccf28a89bdded86b044f2fd3aa3389b923a81988.tar.gz
podman-ccf28a89bdded86b044f2fd3aa3389b923a81988.tar.bz2
podman-ccf28a89bdded86b044f2fd3aa3389b923a81988.zip
Merge pull request #3039 from mheon/podman_init
Add podman init command
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go2
-rw-r--r--libpod/container_internal.go16
2 files changed, 12 insertions, 6 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 465b23831..5bfd869b3 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -40,7 +40,7 @@ func (c *Container) Init(ctx context.Context) (err error) {
if !(c.state.State == ContainerStateConfigured ||
c.state.State == ContainerStateStopped ||
c.state.State == ContainerStateExited) {
- return errors.Wrapf(ErrCtrExists, "container %s has already been created in runtime", c.ID())
+ return errors.Wrapf(ErrCtrStateInvalid, "container %s has already been created in runtime", c.ID())
}
// don't recursively start
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 7febf6966..a791df491 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -811,8 +811,9 @@ func (c *Container) cleanupRuntime(ctx context.Context) error {
span.SetTag("struct", "container")
defer span.Finish()
- // If the container is not ContainerStateStopped, do nothing
- if c.state.State != ContainerStateStopped {
+ // If the container is not ContainerStateStopped or
+ // ContainerStateCreated, do nothing.
+ if c.state.State != ContainerStateStopped && c.state.State != ContainerStateCreated {
return nil
}
@@ -825,9 +826,14 @@ func (c *Container) cleanupRuntime(ctx context.Context) error {
return err
}
- // Our state is now Exited, as we've removed ourself from
- // the runtime.
- c.state.State = ContainerStateExited
+ // If we were Stopped, we are now Exited, as we've removed ourself
+ // from the runtime.
+ // If we were Created, we are now Configured.
+ if c.state.State == ContainerStateStopped {
+ c.state.State = ContainerStateExited
+ } else if c.state.State == ContainerStateCreated {
+ c.state.State = ContainerStateConfigured
+ }
if c.valid {
if err := c.save(); err != nil {