Should not error out if container no longer exists in oci

This prevents you from cleaning up the container database, if
some how runc and friends db gets screwed up.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #725
Approved by: mheon
This commit is contained in:
Daniel J Walsh 2018-05-04 14:25:17 -04:00 committed by Atomic Bot
parent 9cb694e094
commit bb0e7540dc
1 changed files with 7 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import (
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
"syscall"
"time"
@ -399,15 +400,18 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
// 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()
out, err := exec.Command(r.path, "state", ctr.ID()).CombinedOutput()
if err != nil {
if strings.HasSuffix(string(out), "does not exist") {
ctr.removeConmonFiles()
ctr.state.State = ContainerStateConfigured
return nil
}
return errors.Wrapf(err, "error getting container %s state. stderr/out: %s", ctr.ID(), out)
}
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(state); err != nil {
return errors.Wrapf(err, "error decoding container status for container %s", ctr.ID())
}
ctr.state.PID = state.Pid
switch state.Status {