2015-12-01 19:56:08 +00:00
|
|
|
package runtime
|
2015-11-05 23:29:53 +00:00
|
|
|
|
2016-02-01 19:02:41 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"time"
|
2016-02-29 18:48:39 +00:00
|
|
|
|
|
|
|
"github.com/docker/containerd/specs"
|
2016-02-01 19:02:41 +00:00
|
|
|
)
|
2015-12-01 20:00:11 +00:00
|
|
|
|
|
|
|
var (
|
2016-06-03 22:00:49 +00:00
|
|
|
// ErrContainerExited is returned when access to an exited
|
|
|
|
// container is attempted
|
|
|
|
ErrContainerExited = errors.New("containerd: container has exited")
|
2016-06-22 06:23:32 +00:00
|
|
|
// ErrProcessNotExited is returned when trying to retrieve the exit
|
2016-06-03 22:00:49 +00:00
|
|
|
// status of an alive process
|
|
|
|
ErrProcessNotExited = errors.New("containerd: process has not exited")
|
|
|
|
// ErrContainerNotStarted is returned when a container fails to
|
|
|
|
// start without error from the shim or the OCI runtime
|
|
|
|
ErrContainerNotStarted = errors.New("containerd: container not started")
|
|
|
|
// ErrContainerStartTimeout is returned if a container takes too
|
|
|
|
// long to start
|
2016-03-28 20:30:37 +00:00
|
|
|
ErrContainerStartTimeout = errors.New("containerd: container did not start before the specified timeout")
|
2016-06-24 19:02:53 +00:00
|
|
|
// ErrShimExited is returned if the shim or the contianer's init process
|
|
|
|
// exits before completing
|
|
|
|
ErrShimExited = errors.New("containerd: shim exited before container process was started")
|
2015-11-10 22:57:10 +00:00
|
|
|
|
2016-02-25 20:59:34 +00:00
|
|
|
errNoPidFile = errors.New("containerd: no process pid file found")
|
2016-03-18 06:53:23 +00:00
|
|
|
errInvalidPidInt = errors.New("containerd: process pid is invalid")
|
2016-01-06 21:32:46 +00:00
|
|
|
errNotImplemented = errors.New("containerd: not implemented")
|
|
|
|
)
|
2016-02-01 19:02:41 +00:00
|
|
|
|
|
|
|
const (
|
2016-06-03 22:00:49 +00:00
|
|
|
// ExitFile holds the name of the pipe used to monitor process
|
|
|
|
// exit
|
|
|
|
ExitFile = "exit"
|
|
|
|
// ExitStatusFile holds the name of the file where the container
|
|
|
|
// exit code is to be written
|
2016-02-01 19:02:41 +00:00
|
|
|
ExitStatusFile = "exitStatus"
|
2016-06-03 22:00:49 +00:00
|
|
|
// StateFile holds the name of the file where the container state
|
|
|
|
// is written
|
|
|
|
StateFile = "state.json"
|
|
|
|
// ControlFile holds the name of the pipe used to control the shim
|
|
|
|
ControlFile = "control"
|
|
|
|
// InitProcessID holds the special ID used for the very first
|
|
|
|
// container's process
|
|
|
|
InitProcessID = "init"
|
2016-09-07 22:20:30 +00:00
|
|
|
// StartTimeFile holds the name of the file in which the process
|
|
|
|
// start time is saved
|
|
|
|
StartTimeFile = "starttime"
|
2016-09-19 18:46:33 +00:00
|
|
|
|
|
|
|
// UnknownStatus is the value returned when a process exit
|
|
|
|
// status cannot be determined
|
|
|
|
UnknownStatus = 255
|
2016-02-01 19:02:41 +00:00
|
|
|
)
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// Checkpoint holds information regarding a container checkpoint
|
2016-04-26 20:29:35 +00:00
|
|
|
type Checkpoint struct {
|
|
|
|
// Timestamp is the time that checkpoint happened
|
|
|
|
Created time.Time `json:"created"`
|
|
|
|
// Name is the name of the checkpoint
|
|
|
|
Name string `json:"name"`
|
2016-06-03 22:00:49 +00:00
|
|
|
// TCP checkpoints open tcp connections
|
|
|
|
TCP bool `json:"tcp"`
|
2016-04-26 20:29:35 +00:00
|
|
|
// UnixSockets persists unix sockets in the checkpoint
|
|
|
|
UnixSockets bool `json:"unixSockets"`
|
|
|
|
// Shell persists tty sessions in the checkpoint
|
|
|
|
Shell bool `json:"shell"`
|
|
|
|
// Exit exits the container after the checkpoint is finished
|
|
|
|
Exit bool `json:"exit"`
|
2016-06-07 20:25:54 +00:00
|
|
|
// EmptyNS tells CRIU to omit a specified namespace
|
|
|
|
EmptyNS []string `json:"emptyNS,omitempty"`
|
2016-04-26 20:29:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PlatformProcessState container platform-specific fields in the ProcessState structure
|
|
|
|
type PlatformProcessState struct {
|
|
|
|
Checkpoint string `json:"checkpoint"`
|
|
|
|
RootUID int `json:"rootUID"`
|
|
|
|
RootGID int `json:"rootGID"`
|
|
|
|
}
|
2016-06-03 22:00:49 +00:00
|
|
|
|
|
|
|
// State represents a container state
|
2016-02-01 19:02:41 +00:00
|
|
|
type State string
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// Resource regroups the various container limits that can be updated
|
2016-03-07 23:23:52 +00:00
|
|
|
type Resource struct {
|
|
|
|
CPUShares int64
|
|
|
|
BlkioWeight uint16
|
|
|
|
CPUPeriod int64
|
|
|
|
CPUQuota int64
|
|
|
|
CpusetCpus string
|
|
|
|
CpusetMems string
|
|
|
|
KernelMemory int64
|
2016-06-06 18:26:07 +00:00
|
|
|
KernelTCPMemory int64
|
2016-03-07 23:23:52 +00:00
|
|
|
Memory int64
|
|
|
|
MemoryReservation int64
|
|
|
|
MemorySwap int64
|
|
|
|
}
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// Possible container states
|
2016-02-01 19:02:41 +00:00
|
|
|
const (
|
|
|
|
Paused = State("paused")
|
2016-02-25 20:59:34 +00:00
|
|
|
Stopped = State("stopped")
|
2016-02-01 19:02:41 +00:00
|
|
|
Running = State("running")
|
|
|
|
)
|
|
|
|
|
|
|
|
type state struct {
|
2016-03-24 20:30:27 +00:00
|
|
|
Bundle string `json:"bundle"`
|
|
|
|
Labels []string `json:"labels"`
|
|
|
|
Stdin string `json:"stdin"`
|
|
|
|
Stdout string `json:"stdout"`
|
|
|
|
Stderr string `json:"stderr"`
|
|
|
|
Runtime string `json:"runtime"`
|
|
|
|
RuntimeArgs []string `json:"runtimeArgs"`
|
2016-04-06 06:42:47 +00:00
|
|
|
Shim string `json:"shim"`
|
2016-03-30 21:25:42 +00:00
|
|
|
NoPivotRoot bool `json:"noPivotRoot"`
|
2016-02-03 21:56:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-03 22:00:49 +00:00
|
|
|
// ProcessState holds the process OCI specs along with various fields
|
|
|
|
// required by containerd
|
2016-02-03 21:56:15 +00:00
|
|
|
type ProcessState struct {
|
2016-02-29 18:48:39 +00:00
|
|
|
specs.ProcessSpec
|
2016-03-24 20:30:27 +00:00
|
|
|
Exec bool `json:"exec"`
|
|
|
|
Stdin string `json:"containerdStdin"`
|
|
|
|
Stdout string `json:"containerdStdout"`
|
|
|
|
Stderr string `json:"containerdStderr"`
|
|
|
|
RuntimeArgs []string `json:"runtimeArgs"`
|
2016-03-30 21:25:42 +00:00
|
|
|
NoPivotRoot bool `json:"noPivotRoot"`
|
2016-02-26 02:39:03 +00:00
|
|
|
|
|
|
|
PlatformProcessState
|
2016-02-01 19:02:41 +00:00
|
|
|
}
|