summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-06 20:09:04 +0200
committerGitHub <noreply@github.com>2021-10-06 20:09:04 +0200
commit470e52f272a4a8541e867fb2c6477e722175066c (patch)
treedd50e4672729412a0ceb9cd30d83cf7a9726e965 /libpod
parent03c17e94078236531b02ab437721853a09df119f (diff)
parent8bd9f58d1d0db76406dca53907095648f4091f9f (diff)
downloadpodman-470e52f272a4a8541e867fb2c6477e722175066c.tar.gz
podman-470e52f272a4a8541e867fb2c6477e722175066c.tar.bz2
podman-470e52f272a4a8541e867fb2c6477e722175066c.zip
Merge pull request #11878 from mheon/stop_stopping
Allow `podman stop` to be run on Stopping containers
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go4
-rw-r--r--libpod/oci_conmon_linux.go6
2 files changed, 8 insertions, 2 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 50be0eea4..38223316e 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -184,7 +184,7 @@ func (c *Container) StopWithTimeout(timeout uint) error {
return define.ErrCtrStopped
}
- if !c.ensureState(define.ContainerStateCreated, define.ContainerStateRunning) {
+ if !c.ensureState(define.ContainerStateCreated, define.ContainerStateRunning, define.ContainerStateStopping) {
return errors.Wrapf(define.ErrCtrStateInvalid, "can only stop created or running containers. %s is in state %s", c.ID(), c.state.State.String())
}
@@ -690,7 +690,7 @@ func (c *Container) Sync() error {
// If runtime knows about the container, update its status in runtime
// And then save back to disk
- if c.ensureState(define.ContainerStateCreated, define.ContainerStateRunning, define.ContainerStatePaused, define.ContainerStateStopped) {
+ if c.ensureState(define.ContainerStateCreated, define.ContainerStateRunning, define.ContainerStatePaused, define.ContainerStateStopped, define.ContainerStateStopping) {
oldState := c.state.State
if err := c.ociRuntime.UpdateContainerStatus(c); err != nil {
return err
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index 29ec4a92a..0369a9977 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -351,6 +351,12 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
return ctr.handleExitFile(exitFile, fi)
}
+ // Handle ContainerStateStopping - keep it unless the container
+ // transitioned to no longer running.
+ if oldState == define.ContainerStateStopping && (ctr.state.State == define.ContainerStatePaused || ctr.state.State == define.ContainerStateRunning) {
+ ctr.state.State = define.ContainerStateStopping
+ }
+
return nil
}