summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2021-10-06 11:17:43 -0400
committerMatthew Heon <matthew.heon@pm.me>2021-10-19 14:13:59 -0400
commitca33df1468b79dc6dc27798a242b22926c220e6d (patch)
tree6dc510a6d85d423b1cff07e2c75c036b8997dad5 /libpod
parent7bbf774e858fa3e535d9d22d72836459608eb095 (diff)
downloadpodman-ca33df1468b79dc6dc27798a242b22926c220e6d.tar.gz
podman-ca33df1468b79dc6dc27798a242b22926c220e6d.tar.bz2
podman-ca33df1468b79dc6dc27798a242b22926c220e6d.zip
Ensure `podman ps --sync` functions
The backend for `ps --sync` has been nonfunctional for a long while now - probably since v2.0. It's questionable how useful the flag is in modern Podman (the original case it was intended to catch, Conmon gone via SIGKILL, should be handled now via pinging the process with a signal to ensure it's still alive) but having the ability to force a refresh of container state from the OCI runtime is still useful. Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go2
-rw-r--r--libpod/oci_conmon_linux.go6
2 files changed, 7 insertions, 1 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index cc845fe2e..c6f459fbd 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -686,7 +686,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 58aa3557a..ea0ef842d 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
}