server: ignore runc not exist errors

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-05-11 12:41:08 +02:00
parent a41ca975c1
commit 358dac96d4
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
4 changed files with 6 additions and 0 deletions

View file

@ -520,6 +520,9 @@ 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 {
return nil
}
return fmt.Errorf("error getting container state for %s: %s: %q", c.name, err, out) 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 {

View file

@ -21,6 +21,7 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
if err = s.runtime.UpdateStatus(c); err != nil { if err = s.runtime.UpdateStatus(c); err != nil {
return nil, err return nil, err
} }
s.containerStateToDisk(c)
containerID := c.ID() containerID := c.ID()
image := c.Image() image := c.Image()

View file

@ -62,6 +62,7 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque
if err := s.runtime.UpdateStatus(podInfraContainer); err != nil { if err := s.runtime.UpdateStatus(podInfraContainer); err != nil {
return nil, err return nil, err
} }
cState := s.runtime.ContainerStatus(podInfraContainer) cState := s.runtime.ContainerStatus(podInfraContainer)
created := cState.Created.UnixNano() created := cState.Created.UnixNano()
rStatus := pb.PodSandboxState_SANDBOX_NOTREADY rStatus := pb.PodSandboxState_SANDBOX_NOTREADY

View file

@ -19,6 +19,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR
if err = s.runtime.UpdateStatus(podInfraContainer); err != nil { if err = s.runtime.UpdateStatus(podInfraContainer); err != nil {
return nil, err return nil, err
} }
s.containerStateToDisk(podInfraContainer)
cState := s.runtime.ContainerStatus(podInfraContainer) cState := s.runtime.ContainerStatus(podInfraContainer)