runtime.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package runtime
  2. import (
  3. "errors"
  4. "time"
  5. "github.com/docker/containerd/specs"
  6. )
  7. var (
  8. ErrNotChildProcess = errors.New("containerd: not a child process for container")
  9. ErrInvalidContainerType = errors.New("containerd: invalid container type for runtime")
  10. ErrCheckpointNotExists = errors.New("containerd: checkpoint does not exist for container")
  11. ErrCheckpointExists = errors.New("containerd: checkpoint already exists")
  12. ErrContainerExited = errors.New("containerd: container has exited")
  13. ErrTerminalsNotSupported = errors.New("containerd: terminals are not supported for runtime")
  14. ErrProcessNotExited = errors.New("containerd: process has not exited")
  15. ErrProcessExited = errors.New("containerd: process has exited")
  16. ErrContainerNotStarted = errors.New("containerd: container not started")
  17. ErrContainerStartTimeout = errors.New("containerd: container did not start before the specified timeout")
  18. errNoPidFile = errors.New("containerd: no process pid file found")
  19. errInvalidPidInt = errors.New("containerd: process pid is invalid")
  20. errNotImplemented = errors.New("containerd: not implemented")
  21. )
  22. const (
  23. ExitFile = "exit"
  24. ExitStatusFile = "exitStatus"
  25. StateFile = "state.json"
  26. ControlFile = "control"
  27. InitProcessID = "init"
  28. )
  29. type Checkpoint struct {
  30. // Timestamp is the time that checkpoint happened
  31. Created time.Time `json:"created"`
  32. // Name is the name of the checkpoint
  33. Name string `json:"name"`
  34. // Tcp checkpoints open tcp connections
  35. Tcp bool `json:"tcp"`
  36. // UnixSockets persists unix sockets in the checkpoint
  37. UnixSockets bool `json:"unixSockets"`
  38. // Shell persists tty sessions in the checkpoint
  39. Shell bool `json:"shell"`
  40. // Exit exits the container after the checkpoint is finished
  41. Exit bool `json:"exit"`
  42. }
  43. // PlatformProcessState container platform-specific fields in the ProcessState structure
  44. type PlatformProcessState struct {
  45. Checkpoint string `json:"checkpoint"`
  46. RootUID int `json:"rootUID"`
  47. RootGID int `json:"rootGID"`
  48. }
  49. type State string
  50. type Resource struct {
  51. CPUShares int64
  52. BlkioWeight uint16
  53. CPUPeriod int64
  54. CPUQuota int64
  55. CpusetCpus string
  56. CpusetMems string
  57. KernelMemory int64
  58. Memory int64
  59. MemoryReservation int64
  60. MemorySwap int64
  61. }
  62. const (
  63. Paused = State("paused")
  64. Stopped = State("stopped")
  65. Running = State("running")
  66. )
  67. type state struct {
  68. Bundle string `json:"bundle"`
  69. Labels []string `json:"labels"`
  70. Stdin string `json:"stdin"`
  71. Stdout string `json:"stdout"`
  72. Stderr string `json:"stderr"`
  73. Runtime string `json:"runtime"`
  74. RuntimeArgs []string `json:"runtimeArgs"`
  75. Shim string `json:"shim"`
  76. NoPivotRoot bool `json:"noPivotRoot"`
  77. }
  78. type ProcessState struct {
  79. specs.ProcessSpec
  80. Exec bool `json:"exec"`
  81. Stdin string `json:"containerdStdin"`
  82. Stdout string `json:"containerdStdout"`
  83. Stderr string `json:"containerdStderr"`
  84. RuntimeArgs []string `json:"runtimeArgs"`
  85. NoPivotRoot bool `json:"noPivotRoot"`
  86. PlatformProcessState
  87. }