Merge pull request #543 from runcom/fix-ctr-status-reasons
[e2e fix] server: correctly fill ctr termination reason
This commit is contained in:
commit
5ed79fb5cd
3 changed files with 68 additions and 5 deletions
|
@ -13,14 +13,14 @@ const (
|
|||
containerTypeContainer = "container"
|
||||
)
|
||||
|
||||
func (s *Server) getContainerFromRequest(containerID string) (*oci.Container, error) {
|
||||
if containerID == "" {
|
||||
func (s *Server) getContainerFromRequest(cid string) (*oci.Container, error) {
|
||||
if cid == "" {
|
||||
return nil, fmt.Errorf("container ID should not be empty")
|
||||
}
|
||||
|
||||
containerID, err := s.ctrIDIndex.Get(containerID)
|
||||
containerID, err := s.ctrIDIndex.Get(cid)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("container with ID starting with %s not found: %v", containerID, err)
|
||||
return nil, fmt.Errorf("container with ID starting with %s not found: %v", cid, err)
|
||||
}
|
||||
|
||||
c := s.state.containers.Get(containerID)
|
||||
|
|
|
@ -98,8 +98,13 @@ func (s *Server) ContainerStatus(ctx context.Context, req *pb.ContainerStatusReq
|
|||
finished := cState.Finished.UnixNano()
|
||||
resp.Status.FinishedAt = finished
|
||||
resp.Status.ExitCode = cState.ExitCode
|
||||
if cState.OOMKilled {
|
||||
switch {
|
||||
case cState.OOMKilled:
|
||||
resp.Status.Reason = "OOMKilled"
|
||||
case cState.ExitCode == 0:
|
||||
resp.Status.Reason = "Completed"
|
||||
default:
|
||||
resp.Status.Reason = "Error"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue