summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-04-01 13:30:28 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-05-03 10:36:16 -0400
commit3fb52f4fbb04781e32f72888c9e509dea5d7b434 (patch)
tree01918e60491ce2ce0e9345a052acfee8546d9fa4 /libpod/container_internal.go
parent0eaba2d56a48c68e1d08e287a1c9eb5405cc743a (diff)
downloadpodman-3fb52f4fbb04781e32f72888c9e509dea5d7b434.tar.gz
podman-3fb52f4fbb04781e32f72888c9e509dea5d7b434.tar.bz2
podman-3fb52f4fbb04781e32f72888c9e509dea5d7b434.zip
Add a StoppedByUser field to the DB
This field indicates that a container was explciitly stopped by an API call, and did not exit naturally. It's used when implementing restart policy for containers. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index a791df491..0b9c5a96a 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -376,6 +376,7 @@ func resetState(state *ContainerState) error {
state.ExecSessions = make(map[string]*ExecSession)
state.NetworkStatus = nil
state.BindMounts = make(map[string]string)
+ state.StoppedByUser = false
return nil
}
@@ -789,6 +790,7 @@ func (c *Container) init(ctx context.Context) error {
c.state.ExitCode = 0
c.state.Exited = false
c.state.State = ContainerStateCreated
+ c.state.StoppedByUser = false
if err := c.save(); err != nil {
return err
@@ -950,6 +952,11 @@ func (c *Container) stop(timeout uint) error {
return err
}
+ c.state.StoppedByUser = true
+ if err := c.save(); err != nil {
+ return errors.Wrapf(err, "error saving container %s state after stopping", c.ID())
+ }
+
// Wait until we have an exit file, and sync once we do
return c.waitForExitFileAndSync()
}