diff --git a/oci/oci.go b/oci/oci.go index b04c60bd..bd3cac3b 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -520,6 +520,9 @@ func (r *Runtime) UpdateStatus(c *Container) error { defer c.opLock.Unlock() out, err := exec.Command(r.Path(c), "state", c.name).CombinedOutput() if err != nil { + if err := unix.Kill(c.state.Pid, 0); err == syscall.ESRCH { + 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 { diff --git a/server/container_status.go b/server/container_status.go index d946e9ae..febe7060 100644 --- a/server/container_status.go +++ b/server/container_status.go @@ -21,6 +21,7 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq if err = s.runtime.UpdateStatus(c); err != nil { return nil, err } + s.containerStateToDisk(c) containerID := c.ID() image := c.Image() diff --git a/server/sandbox_list.go b/server/sandbox_list.go index 9e4b3562..155c3d59 100644 --- a/server/sandbox_list.go +++ b/server/sandbox_list.go @@ -62,6 +62,7 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque if err := s.runtime.UpdateStatus(podInfraContainer); err != nil { return nil, err } + cState := s.runtime.ContainerStatus(podInfraContainer) created := cState.Created.UnixNano() rStatus := pb.PodSandboxState_SANDBOX_NOTREADY diff --git a/server/sandbox_status.go b/server/sandbox_status.go index 9a8c864f..d8e2453f 100644 --- a/server/sandbox_status.go +++ b/server/sandbox_status.go @@ -19,6 +19,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR if err = s.runtime.UpdateStatus(podInfraContainer); err != nil { return nil, err } + s.containerStateToDisk(podInfraContainer) cState := s.runtime.ContainerStatus(podInfraContainer)