From bb0e7540dcdcd77747418658058767c2705ad0a0 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Fri, 4 May 2018 14:25:17 -0400 Subject: 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 Closes: #725 Approved by: mheon --- libpod/oci.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libpod/oci.go') diff --git a/libpod/oci.go b/libpod/oci.go index 9c842f2c9..a07aa8d86 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -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 { -- cgit v1.2.3-54-g00ecf