cgroup_linux.go 4.2 KB

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