server: ignore runc not exist errors
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
03da0fe03e
commit
e4200d3313
5 changed files with 9 additions and 6 deletions
|
@ -486,6 +486,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 strings.Contains(string(out), "does not exist") {
|
||||
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 {
|
||||
|
|
|
@ -66,9 +66,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
|||
}
|
||||
|
||||
for _, ctr := range ctrList {
|
||||
if err := s.runtime.UpdateStatus(ctr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.runtime.UpdateStatus(ctr)
|
||||
|
||||
podSandboxID := ctr.Sandbox()
|
||||
cState := s.runtime.ContainerStatus(ctr)
|
||||
|
|
|
@ -20,6 +20,7 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
|
|||
|
||||
// best effort if container is still in runc store...
|
||||
s.runtime.UpdateStatus(c)
|
||||
s.containerStateToDisk(c)
|
||||
|
||||
containerID := c.ID()
|
||||
image := c.Image()
|
||||
|
|
|
@ -59,9 +59,8 @@ func (s *Server) ListPodSandbox(ctx context.Context, req *pb.ListPodSandboxReque
|
|||
// it's better not to panic
|
||||
continue
|
||||
}
|
||||
if err := s.runtime.UpdateStatus(podInfraContainer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.runtime.UpdateStatus(podInfraContainer)
|
||||
|
||||
cState := s.runtime.ContainerStatus(podInfraContainer)
|
||||
created := cState.Created.UnixNano()
|
||||
rStatus := pb.PodSandboxState_SANDBOX_NOTREADY
|
||||
|
|
|
@ -18,6 +18,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR
|
|||
podInfraContainer := sb.infraContainer
|
||||
// best effort if container is still in runc store...
|
||||
s.runtime.UpdateStatus(podInfraContainer)
|
||||
s.containerStateToDisk(podInfraContainer)
|
||||
|
||||
cState := s.runtime.ContainerStatus(podInfraContainer)
|
||||
|
||||
|
@ -32,6 +33,7 @@ func (s *Server) PodSandboxStatus(ctx context.Context, req *pb.PodSandboxStatusR
|
|||
}
|
||||
|
||||
rStatus := pb.PodSandboxState_SANDBOX_NOTREADY
|
||||
|
||||
if cState.Status == oci.ContainerStateRunning {
|
||||
rStatus = pb.PodSandboxState_SANDBOX_READY
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue