github.com/bowei/containerd@v0.2.5/runtime/runtime.go (about) 1 package runtime 2 3 import ( 4 "errors" 5 "time" 6 7 "github.com/docker/containerd/specs" 8 ) 9 10 var ( 11 // ErrContainerExited is returned when access to an exited 12 // container is attempted 13 ErrContainerExited = errors.New("containerd: container has exited") 14 // ErrProcessNotExited is returned when trying to retrieve the exit 15 // status of an alive process 16 ErrProcessNotExited = errors.New("containerd: process has not exited") 17 // ErrContainerNotStarted is returned when a container fails to 18 // start without error from the shim or the OCI runtime 19 ErrContainerNotStarted = errors.New("containerd: container not started") 20 // ErrContainerStartTimeout is returned if a container takes too 21 // long to start 22 ErrContainerStartTimeout = errors.New("containerd: container did not start before the specified timeout") 23 // ErrShimExited is returned if the shim or the contianer's init process 24 // exits before completing 25 ErrShimExited = errors.New("containerd: shim exited before container process was started") 26 27 errNoPidFile = errors.New("containerd: no process pid file found") 28 errInvalidPidInt = errors.New("containerd: process pid is invalid") 29 errNotImplemented = errors.New("containerd: not implemented") 30 ) 31 32 const ( 33 // ExitFile holds the name of the pipe used to monitor process 34 // exit 35 ExitFile = "exit" 36 // ExitStatusFile holds the name of the file where the container 37 // exit code is to be written 38 ExitStatusFile = "exitStatus" 39 // StateFile holds the name of the file where the container state 40 // is written 41 StateFile = "state.json" 42 // ControlFile holds the name of the pipe used to control the shim 43 ControlFile = "control" 44 // InitProcessID holds the special ID used for the very first 45 // container's process 46 InitProcessID = "init" 47 // StartTimeFile holds the name of the file in which the process 48 // start time is saved 49 StartTimeFile = "starttime" 50 51 // UnknownStatus is the value returned when a process exit 52 // status cannot be determined 53 UnknownStatus = 255 54 ) 55 56 // Checkpoint holds information regarding a container checkpoint 57 type Checkpoint struct { 58 // Timestamp is the time that checkpoint happened 59 Created time.Time `json:"created"` 60 // Name is the name of the checkpoint 61 Name string `json:"name"` 62 // TCP checkpoints open tcp connections 63 TCP bool `json:"tcp"` 64 // UnixSockets persists unix sockets in the checkpoint 65 UnixSockets bool `json:"unixSockets"` 66 // Shell persists tty sessions in the checkpoint 67 Shell bool `json:"shell"` 68 // Exit exits the container after the checkpoint is finished 69 Exit bool `json:"exit"` 70 // EmptyNS tells CRIU to omit a specified namespace 71 EmptyNS []string `json:"emptyNS,omitempty"` 72 } 73 74 // PlatformProcessState container platform-specific fields in the ProcessState structure 75 type PlatformProcessState struct { 76 Checkpoint string `json:"checkpoint"` 77 RootUID int `json:"rootUID"` 78 RootGID int `json:"rootGID"` 79 } 80 81 // State represents a container state 82 type State string 83 84 // Resource regroups the various container limits that can be updated 85 type Resource struct { 86 CPUShares int64 87 BlkioWeight uint16 88 CPUPeriod int64 89 CPUQuota int64 90 CpusetCpus string 91 CpusetMems string 92 KernelMemory int64 93 KernelTCPMemory int64 94 Memory int64 95 MemoryReservation int64 96 MemorySwap int64 97 } 98 99 // Possible container states 100 const ( 101 Paused = State("paused") 102 Stopped = State("stopped") 103 Running = State("running") 104 ) 105 106 type state struct { 107 Bundle string `json:"bundle"` 108 Labels []string `json:"labels"` 109 Stdin string `json:"stdin"` 110 Stdout string `json:"stdout"` 111 Stderr string `json:"stderr"` 112 Runtime string `json:"runtime"` 113 RuntimeArgs []string `json:"runtimeArgs"` 114 Shim string `json:"shim"` 115 NoPivotRoot bool `json:"noPivotRoot"` 116 } 117 118 // ProcessState holds the process OCI specs along with various fields 119 // required by containerd 120 type ProcessState struct { 121 specs.ProcessSpec 122 Exec bool `json:"exec"` 123 Stdin string `json:"containerdStdin"` 124 Stdout string `json:"containerdStdout"` 125 Stderr string `json:"containerdStderr"` 126 RuntimeArgs []string `json:"runtimeArgs"` 127 NoPivotRoot bool `json:"noPivotRoot"` 128 129 PlatformProcessState 130 }