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
This commit is contained in:
Matthew Heon 2018-02-19 18:06:05 -05:00 committed by Atomic Bot
parent 8d8817e61e
commit 8eb5cf7489
1 changed files with 6 additions and 1 deletions

View File

@ -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(