diff --git a/cmd/crioctl/container.go b/cmd/crioctl/container.go index 7788d547..86b96d43 100644 --- a/cmd/crioctl/container.go +++ b/cmd/crioctl/container.go @@ -460,6 +460,7 @@ func ContainerStatus(client pb.RuntimeServiceClient, ID string) error { ftm := time.Unix(0, r.Status.FinishedAt) fmt.Printf("Finished: %v\n", ftm) fmt.Printf("Exit Code: %v\n", r.Status.ExitCode) + fmt.Printf("Reason: %v\n", r.Status.Reason) if r.Status.Image != nil { fmt.Printf("Image: %v\n", r.Status.Image.Image) } diff --git a/oci/container.go b/oci/container.go index 9ffa13ca..03534cf8 100644 --- a/oci/container.go +++ b/oci/container.go @@ -38,10 +38,11 @@ type Container struct { // ContainerState represents the status of a container. type ContainerState struct { specs.State - Created time.Time `json:"created"` - Started time.Time `json:"started,omitempty"` - Finished time.Time `json:"finished,omitempty"` - ExitCode int32 `json:"exitCode,omitempty"` + Created time.Time `json:"created"` + Started time.Time `json:"started,omitempty"` + Finished time.Time `json:"finished,omitempty"` + ExitCode int32 `json:"exitCode,omitempty"` + OOMKilled bool `json:"oomKilled,omitempty"` } // NewContainer creates a container object. diff --git a/oci/oci.go b/oci/oci.go index 85841f1d..c099bc3c 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -552,6 +552,11 @@ func (r *Runtime) UpdateStatus(c *Container) error { } c.state.ExitCode = int32(statusCode) } + + oomFilePath := filepath.Join(c.bundlePath, "oom") + if _, err = os.Stat(oomFilePath); err == nil { + c.state.OOMKilled = true + } } return nil diff --git a/server/container_status.go b/server/container_status.go index d2a500d3..fc8c18ce 100644 --- a/server/container_status.go +++ b/server/container_status.go @@ -98,6 +98,9 @@ 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 { + resp.Status.Reason = "OOMKilled" + } } resp.Status.State = rStatus