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 (
|
2015-12-11 01:07:21 +00:00
|
|
|
ErrNotChildProcess = errors.New("containerd: not a child process for container")
|
|
|
|
ErrInvalidContainerType = errors.New("containerd: invalid container type for runtime")
|
|
|
|
ErrCheckpointNotExists = errors.New("containerd: checkpoint does not exist for container")
|
|
|
|
ErrCheckpointExists = errors.New("containerd: checkpoint already exists")
|
|
|
|
ErrContainerExited = errors.New("containerd: container has exited")
|
|
|
|
ErrTerminalsNotSupported = errors.New("containerd: terminals are not supported for runtime")
|
2016-01-06 21:32:46 +00:00
|
|
|
ErrProcessNotExited = errors.New("containerd: process has not exited")
|
|
|
|
ErrProcessExited = errors.New("containerd: process has exited")
|
2016-02-25 20:59:34 +00:00
|
|
|
ErrContainerNotStarted = errors.New("containerd: container not started")
|
2016-03-28 20:30:37 +00:00
|
|
|
ErrContainerStartTimeout = errors.New("containerd: container did not start before the specified timeout")
|
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 (
|
|
|
|
ExitFile = "exit"
|
|
|
|
ExitStatusFile = "exitStatus"
|
|
|
|
StateFile = "state.json"
|
2016-02-02 22:21:25 +00:00
|
|
|
ControlFile = "control"
|
2016-02-01 19:02:41 +00:00
|
|
|
InitProcessID = "init"
|
|
|
|
)
|
|
|
|
|
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"`
|
|
|
|
// Tcp checkpoints open tcp connections
|
|
|
|
Tcp bool `json:"tcp"`
|
|
|
|
// 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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-02-01 19:02:41 +00:00
|
|
|
type State string
|
|
|
|
|
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
|
|
|
|
Memory int64
|
|
|
|
MemoryReservation int64
|
|
|
|
MemorySwap int64
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
type Stat struct {
|
|
|
|
// Timestamp is the time that the statistics where collected
|
|
|
|
Timestamp time.Time
|
|
|
|
// Data is the raw stats
|
|
|
|
// TODO: it is currently an interface because we don't know what type of exec drivers
|
|
|
|
// we will have or what the structure should look like at the moment os the containers
|
|
|
|
// can return what they want and we could marshal to json or whatever.
|
|
|
|
Data interface{}
|
|
|
|
}
|