cgroup_unix.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // +build linux freebsd
  2. package configs
  3. type FreezerState string
  4. const (
  5. Undefined FreezerState = ""
  6. Frozen FreezerState = "FROZEN"
  7. Thawed FreezerState = "THAWED"
  8. )
  9. type Cgroup struct {
  10. // Deprecated, use Path instead
  11. Name string `json:"name,omitempty"`
  12. // name of parent of cgroup or slice
  13. // Deprecated, use Path instead
  14. Parent string `json:"parent,omitempty"`
  15. // Path specifies the path to cgroups that are created and/or joined by the container.
  16. // The path is assumed to be relative to the host system cgroup mountpoint.
  17. Path string `json:"path"`
  18. // ScopePrefix decribes prefix for the scope name
  19. ScopePrefix string `json:"scope_prefix"`
  20. // Paths represent the absolute cgroups paths to join.
  21. // This takes precedence over Path.
  22. Paths map[string]string
  23. // Resources contains various cgroups settings to apply
  24. *Resources
  25. }
  26. type Resources struct {
  27. // If this is true allow access to any kind of device within the container. If false, allow access only to devices explicitly listed in the allowed_devices list.
  28. // Deprecated
  29. AllowAllDevices bool `json:"allow_all_devices,omitempty"`
  30. // Deprecated
  31. AllowedDevices []*Device `json:"allowed_devices,omitempty"`
  32. // Deprecated
  33. DeniedDevices []*Device `json:"denied_devices,omitempty"`
  34. Devices []*Device `json:"devices"`
  35. // Memory limit (in bytes)
  36. Memory int64 `json:"memory"`
  37. // Memory reservation or soft_limit (in bytes)
  38. MemoryReservation int64 `json:"memory_reservation"`
  39. // Total memory usage (memory + swap); set `-1` to enable unlimited swap
  40. MemorySwap int64 `json:"memory_swap"`
  41. // Kernel memory limit (in bytes)
  42. KernelMemory int64 `json:"kernel_memory"`
  43. // Kernel memory limit for TCP use (in bytes)
  44. KernelMemoryTCP int64 `json:"kernel_memory_tcp"`
  45. // CPU shares (relative weight vs. other containers)
  46. CpuShares int64 `json:"cpu_shares"`
  47. // CPU hardcap limit (in usecs). Allowed cpu time in a given period.
  48. CpuQuota int64 `json:"cpu_quota"`
  49. // CPU period to be used for hardcapping (in usecs). 0 to use system default.
  50. CpuPeriod int64 `json:"cpu_period"`
  51. // How many time CPU will use in realtime scheduling (in usecs).
  52. CpuRtRuntime int64 `json:"cpu_quota"`
  53. // CPU period to be used for realtime scheduling (in usecs).
  54. CpuRtPeriod int64 `json:"cpu_period"`
  55. // CPU to use
  56. CpusetCpus string `json:"cpuset_cpus"`
  57. // MEM to use
  58. CpusetMems string `json:"cpuset_mems"`
  59. // Process limit; set <= `0' to disable limit.
  60. PidsLimit int64 `json:"pids_limit"`
  61. // Specifies per cgroup weight, range is from 10 to 1000.
  62. BlkioWeight uint16 `json:"blkio_weight"`
  63. // Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
  64. BlkioLeafWeight uint16 `json:"blkio_leaf_weight"`
  65. // Weight per cgroup per device, can override BlkioWeight.
  66. BlkioWeightDevice []*WeightDevice `json:"blkio_weight_device"`
  67. // IO read rate limit per cgroup per device, bytes per second.
  68. BlkioThrottleReadBpsDevice []*ThrottleDevice `json:"blkio_throttle_read_bps_device"`
  69. // IO write rate limit per cgroup per divice, bytes per second.
  70. BlkioThrottleWriteBpsDevice []*ThrottleDevice `json:"blkio_throttle_write_bps_device"`
  71. // IO read rate limit per cgroup per device, IO per second.
  72. BlkioThrottleReadIOPSDevice []*ThrottleDevice `json:"blkio_throttle_read_iops_device"`
  73. // IO write rate limit per cgroup per device, IO per second.
  74. BlkioThrottleWriteIOPSDevice []*ThrottleDevice `json:"blkio_throttle_write_iops_device"`
  75. // set the freeze value for the process
  76. Freezer FreezerState `json:"freezer"`
  77. // Hugetlb limit (in bytes)
  78. HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"`
  79. // Whether to disable OOM Killer
  80. OomKillDisable bool `json:"oom_kill_disable"`
  81. // Tuning swappiness behaviour per cgroup
  82. MemorySwappiness *int64 `json:"memory_swappiness"`
  83. // Set priority of network traffic for container
  84. NetPrioIfpriomap []*IfPrioMap `json:"net_prio_ifpriomap"`
  85. // Set class identifier for container's network packets
  86. NetClsClassid string `json:"net_cls_classid"`
  87. }