container_status: Get latest container status if exit code is -1
Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
parent
37edc50c1d
commit
701e7ff63f
1 changed files with 11 additions and 0 deletions
|
@ -46,6 +46,17 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
|
|||
cState := s.Runtime().ContainerStatus(c)
|
||||
rStatus := pb.ContainerState_CONTAINER_UNKNOWN
|
||||
|
||||
// If we defaulted to exit code -1 earlier then we attempt to
|
||||
// get the exit code from the exit file again.
|
||||
// TODO: We could wait in UpdateStatus for exit file to show up.
|
||||
if cState.ExitCode == -1 {
|
||||
err := s.Runtime().UpdateStatus(c)
|
||||
if err != nil {
|
||||
logrus.Warnf("Failed to UpdateStatus of container %s: %v", c.ID(), err)
|
||||
}
|
||||
cState = s.Runtime().ContainerStatus(c)
|
||||
}
|
||||
|
||||
switch cState.Status {
|
||||
case oci.ContainerStateCreated:
|
||||
rStatus = pb.ContainerState_CONTAINER_CREATED
|
||||
|
|
Loading…
Reference in a new issue