oci: do not error out on runtime state failure
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
a37dd46654
commit
88fb9094d0
1 changed files with 10 additions and 7 deletions
|
@ -550,14 +550,17 @@ func (r *Runtime) UpdateStatus(c *Container) error {
|
||||||
defer c.opLock.Unlock()
|
defer c.opLock.Unlock()
|
||||||
out, err := exec.Command(r.Path(c), "state", c.name).CombinedOutput()
|
out, err := exec.Command(r.Path(c), "state", c.name).CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err := unix.Kill(c.state.Pid, 0); err == syscall.ESRCH {
|
// there are many code paths that could lead to have a bad state in the
|
||||||
|
// underlying runtime.
|
||||||
|
// On any error like a container went away or we rebooted and containers
|
||||||
|
// went away we do not error out stopping kubernetes to recover.
|
||||||
|
// We always populate the fields below so kube can restart/reschedule
|
||||||
|
// containers failing.
|
||||||
c.state.Status = ContainerStateStopped
|
c.state.Status = ContainerStateStopped
|
||||||
c.state.Finished = time.Now()
|
c.state.Finished = time.Now()
|
||||||
c.state.ExitCode = 255
|
c.state.ExitCode = 255
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("error getting container state for %s: %s: %q", c.name, err, out)
|
|
||||||
}
|
|
||||||
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(&c.state); err != nil {
|
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(&c.state); err != nil {
|
||||||
return fmt.Errorf("failed to decode container status for %s: %s", c.name, err)
|
return fmt.Errorf("failed to decode container status for %s: %s", c.name, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue