summaryrefslogtreecommitdiff
path: root/libpod/oci.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-02-19 18:06:05 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-20 14:54:13 +0000
commit8eb5cf74892611f26c0c42c45312cb84e04882a2 (patch)
tree0bcb6f3948ba93a5b2cb0e61936077a8ec6e5aea /libpod/oci.go
parent8d8817e61ebe76022f53caea5a520ea12d825861 (diff)
downloadpodman-8eb5cf74892611f26c0c42c45312cb84e04882a2.tar.gz
podman-8eb5cf74892611f26c0c42c45312cb84e04882a2.tar.bz2
podman-8eb5cf74892611f26c0c42c45312cb84e04882a2.zip
Ensure we don't repeatedly poll disk for exit codes
Change logic for refreshing our state using runc to only poll for conmon exit files when we first transition to the Stopped state. After that, we should already have the exit code stored in the database, so we don't need to look it up again. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #363 Approved by: TomSweeneyRedHat
Diffstat (limited to 'libpod/oci.go')
-rw-r--r--libpod/oci.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 1fa85bda0..4847eceb6 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -308,6 +308,9 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e
func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
state := new(spec.State)
+ // Store old state so we know if we were already stopped
+ oldState := ctr.state.State
+
out, err := exec.Command(r.path, "state", ctr.ID()).Output()
if err != nil {
return errors.Wrapf(err, "error getting container %s state. stderr/out: %s", ctr.ID(), out)
@@ -333,7 +336,9 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
ctr.ID(), state.Status)
}
- if ctr.state.State == ContainerStateStopped {
+ // Only grab exit status if we were not already stopped
+ // If we were, it should already be in the database
+ if ctr.state.State == ContainerStateStopped && oldState != ContainerStateStopped {
exitFile := filepath.Join(r.exitsDir, ctr.ID())
var fi os.FileInfo
err = kwait.ExponentialBackoff(