github.com/windmilleng/containerd@v0.2.7/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  	errContainerNotFound = errors.New("containerd: container not found")
    30  	errNotImplemented    = errors.New("containerd: not implemented")
    31  )
    32  
    33  const (
    34  	// ExitFile holds the name of the pipe used to monitor process
    35  	// exit
    36  	ExitFile = "exit"
    37  	// ExitStatusFile holds the name of the file where the container
    38  	// exit code is to be written
    39  	ExitStatusFile = "exitStatus"
    40  	// StateFile holds the name of the file where the container state
    41  	// is written
    42  	StateFile = "state.json"
    43  	// ControlFile holds the name of the pipe used to control the shim
    44  	ControlFile = "control"
    45  	// InitProcessID holds the special ID used for the very first
    46  	// container's process
    47  	InitProcessID = "init"
    48  	// StartTimeFile holds the name of the file in which the process
    49  	// start time is saved
    50  	StartTimeFile = "starttime"
    51  
    52  	// UnknownStatus is the value returned when a process exit
    53  	// status cannot be determined
    54  	UnknownStatus = 255
    55  )
    56  
    57  // Checkpoint holds information regarding a container checkpoint
    58  type Checkpoint struct {
    59  	// Timestamp is the time that checkpoint happened
    60  	Created time.Time `json:"created"`
    61  	// Name is the name of the checkpoint
    62  	Name string `json:"name"`
    63  	// TCP checkpoints open tcp connections
    64  	TCP bool `json:"tcp"`
    65  	// UnixSockets persists unix sockets in the checkpoint
    66  	UnixSockets bool `json:"unixSockets"`
    67  	// Shell persists tty sessions in the checkpoint
    68  	Shell bool `json:"shell"`
    69  	// Exit exits the container after the checkpoint is finished
    70  	Exit bool `json:"exit"`
    71  	// EmptyNS tells CRIU to omit a specified namespace
    72  	EmptyNS []string `json:"emptyNS,omitempty"`
    73  }
    74  
    75  // PlatformProcessState container platform-specific fields in the ProcessState structure
    76  type PlatformProcessState struct {
    77  	Checkpoint string `json:"checkpoint"`
    78  	RootUID    int    `json:"rootUID"`
    79  	RootGID    int    `json:"rootGID"`
    80  }
    81  
    82  // State represents a container state
    83  type State string
    84  
    85  // Resource regroups the various container limits that can be updated
    86  type Resource struct {
    87  	CPUShares         int64
    88  	BlkioWeight       uint16
    89  	CPUPeriod         int64
    90  	CPUQuota          int64
    91  	CpusetCpus        string
    92  	CpusetMems        string
    93  	KernelMemory      int64
    94  	KernelTCPMemory   int64
    95  	Memory            int64
    96  	MemoryReservation int64
    97  	MemorySwap        int64
    98  }
    99  
   100  // Possible container states
   101  const (
   102  	Paused  = State("paused")
   103  	Stopped = State("stopped")
   104  	Running = State("running")
   105  )
   106  
   107  type state struct {
   108  	Bundle      string   `json:"bundle"`
   109  	Labels      []string `json:"labels"`
   110  	Stdin       string   `json:"stdin"`
   111  	Stdout      string   `json:"stdout"`
   112  	Stderr      string   `json:"stderr"`
   113  	Runtime     string   `json:"runtime"`
   114  	RuntimeArgs []string `json:"runtimeArgs"`
   115  	Shim        string   `json:"shim"`
   116  	NoPivotRoot bool     `json:"noPivotRoot"`
   117  }
   118  
   119  // ProcessState holds the process OCI specs along with various fields
   120  // required by containerd
   121  type ProcessState struct {
   122  	specs.ProcessSpec
   123  	Exec        bool     `json:"exec"`
   124  	Stdin       string   `json:"containerdStdin"`
   125  	Stdout      string   `json:"containerdStdout"`
   126  	Stderr      string   `json:"containerdStderr"`
   127  	RuntimeArgs []string `json:"runtimeArgs"`
   128  	NoPivotRoot bool     `json:"noPivotRoot"`
   129  
   130  	PlatformProcessState
   131  }