Merge pull request #966 from baude/exit_code
BUGFIX: Invalid return codes in kpod
This commit is contained in:
commit
06e8fb9fdf
4 changed files with 38 additions and 4 deletions
|
@ -23,7 +23,7 @@ const (
|
||||||
cniBinDir = "/opt/cni/bin/"
|
cniBinDir = "/opt/cni/bin/"
|
||||||
cgroupManager = oci.CgroupfsCgroupsManager
|
cgroupManager = oci.CgroupfsCgroupsManager
|
||||||
lockPath = "/run/crio.lock"
|
lockPath = "/run/crio.lock"
|
||||||
containerExitsDir = "/var/run/kpod/exits"
|
containerExitsDir = oci.ContainerExitsDir
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config represents the entire set of configuration values that can be set for
|
// Config represents the entire set of configuration values that can be set for
|
||||||
|
|
|
@ -3,6 +3,7 @@ package libkpod
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||||
|
@ -22,7 +23,7 @@ type ContainerData struct {
|
||||||
LogPath string
|
LogPath string
|
||||||
Labels fields.Set
|
Labels fields.Set
|
||||||
Annotations fields.Set
|
Annotations fields.Set
|
||||||
State *oci.ContainerState
|
State *ContainerState
|
||||||
Metadata *pb.ContainerMetadata
|
Metadata *pb.ContainerMetadata
|
||||||
BundlePath string
|
BundlePath string
|
||||||
StopSignal string
|
StopSignal string
|
||||||
|
@ -49,6 +50,17 @@ type driverData struct {
|
||||||
Data map[string]string
|
Data map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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"`
|
||||||
|
OOMKilled bool `json:"oomKilled,omitempty"`
|
||||||
|
Error string `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// GetContainerData gets the ContainerData for a container with the given name in the given store.
|
// GetContainerData gets the ContainerData for a container with the given name in the given store.
|
||||||
// If size is set to true, it will also determine the size of the container
|
// If size is set to true, it will also determine the size of the container
|
||||||
func (c *ContainerServer) GetContainerData(name string, size bool) (*ContainerData, error) {
|
func (c *ContainerServer) GetContainerData(name string, size bool) (*ContainerData, error) {
|
||||||
|
@ -110,7 +122,7 @@ func (c *ContainerServer) GetContainerData(name string, size bool) (*ContainerDa
|
||||||
LogPath: ctr.LogPath(),
|
LogPath: ctr.LogPath(),
|
||||||
Labels: ctr.Labels(),
|
Labels: ctr.Labels(),
|
||||||
Annotations: ctr.Annotations(),
|
Annotations: ctr.Annotations(),
|
||||||
State: ctr.State(),
|
State: c.State(ctr),
|
||||||
Metadata: ctr.Metadata(),
|
Metadata: ctr.Metadata(),
|
||||||
BundlePath: ctr.BundlePath(),
|
BundlePath: ctr.BundlePath(),
|
||||||
StopSignal: ctr.GetStopSignal(),
|
StopSignal: ctr.GetStopSignal(),
|
||||||
|
@ -176,3 +188,23 @@ func getBlankSpec() specs.Spec {
|
||||||
Windows: &specs.Windows{},
|
Windows: &specs.Windows{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// State copies the crio container state to ContainerState type for kpod
|
||||||
|
func (c *ContainerServer) State(ctr *oci.Container) *ContainerState {
|
||||||
|
crioState := ctr.State()
|
||||||
|
specState := specs.State{
|
||||||
|
Version: crioState.Version,
|
||||||
|
ID: crioState.ID,
|
||||||
|
Status: crioState.Status,
|
||||||
|
Pid: crioState.Pid,
|
||||||
|
Bundle: crioState.Bundle,
|
||||||
|
Annotations: crioState.Annotations,
|
||||||
|
}
|
||||||
|
cState := &ContainerState{
|
||||||
|
Started: crioState.Started,
|
||||||
|
Created: crioState.Created,
|
||||||
|
Finished: crioState.Finished,
|
||||||
|
}
|
||||||
|
cState.State = specState
|
||||||
|
return cState
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ const (
|
||||||
CgroupfsCgroupsManager = "cgroupfs"
|
CgroupfsCgroupsManager = "cgroupfs"
|
||||||
// SystemdCgroupsManager represents systemd native cgroup manager
|
// SystemdCgroupsManager represents systemd native cgroup manager
|
||||||
SystemdCgroupsManager = "systemd"
|
SystemdCgroupsManager = "systemd"
|
||||||
|
// ContainerExitsDir is the location of container exit dirs
|
||||||
|
ContainerExitsDir = "/var/run/crio/exits"
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates a new Runtime with options provided
|
// New creates a new Runtime with options provided
|
||||||
|
|
|
@ -184,7 +184,7 @@ func New(config *Config) (*Server, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
config.ContainerExitsDir = "/var/run/crio/exits"
|
config.ContainerExitsDir = oci.ContainerExitsDir
|
||||||
|
|
||||||
// This is used to monitor container exits using inotify
|
// This is used to monitor container exits using inotify
|
||||||
if err := os.MkdirAll(config.ContainerExitsDir, 0755); err != nil {
|
if err := os.MkdirAll(config.ContainerExitsDir, 0755); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue