1package configs
2
3import (
4	systemdDbus "github.com/coreos/go-systemd/v22/dbus"
5	"github.com/opencontainers/runc/libcontainer/devices"
6)
7
8type FreezerState string
9
10const (
11	Undefined FreezerState = ""
12	Frozen    FreezerState = "FROZEN"
13	Thawed    FreezerState = "THAWED"
14)
15
16type Cgroup struct {
17	// Deprecated, use Path instead
18	Name string `json:"name,omitempty"`
19
20	// name of parent of cgroup or slice
21	// Deprecated, use Path instead
22	Parent string `json:"parent,omitempty"`
23
24	// Path specifies the path to cgroups that are created and/or joined by the container.
25	// The path is assumed to be relative to the host system cgroup mountpoint.
26	Path string `json:"path"`
27
28	// ScopePrefix describes prefix for the scope name
29	ScopePrefix string `json:"scope_prefix"`
30
31	// Paths represent the absolute cgroups paths to join.
32	// This takes precedence over Path.
33	Paths map[string]string
34
35	// Resources contains various cgroups settings to apply
36	*Resources
37
38	// SystemdProps are any additional properties for systemd,
39	// derived from org.systemd.property.xxx annotations.
40	// Ignored unless systemd is used for managing cgroups.
41	SystemdProps []systemdDbus.Property `json:"-"`
42}
43
44type Resources struct {
45	// Devices is the set of access rules for devices in the container.
46	Devices []*devices.Rule `json:"devices"`
47
48	// Memory limit (in bytes)
49	Memory int64 `json:"memory"`
50
51	// Memory reservation or soft_limit (in bytes)
52	MemoryReservation int64 `json:"memory_reservation"`
53
54	// Total memory usage (memory + swap); set `-1` to enable unlimited swap
55	MemorySwap int64 `json:"memory_swap"`
56
57	// Kernel memory limit (in bytes)
58	KernelMemory int64 `json:"kernel_memory"`
59
60	// Kernel memory limit for TCP use (in bytes)
61	KernelMemoryTCP int64 `json:"kernel_memory_tcp"`
62
63	// CPU shares (relative weight vs. other containers)
64	CpuShares uint64 `json:"cpu_shares"`
65
66	// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
67	CpuQuota int64 `json:"cpu_quota"`
68
69	// CPU period to be used for hardcapping (in usecs). 0 to use system default.
70	CpuPeriod uint64 `json:"cpu_period"`
71
72	// How many time CPU will use in realtime scheduling (in usecs).
73	CpuRtRuntime int64 `json:"cpu_rt_quota"`
74
75	// CPU period to be used for realtime scheduling (in usecs).
76	CpuRtPeriod uint64 `json:"cpu_rt_period"`
77
78	// CPU to use
79	CpusetCpus string `json:"cpuset_cpus"`
80
81	// MEM to use
82	CpusetMems string `json:"cpuset_mems"`
83
84	// Process limit; set <= `0' to disable limit.
85	PidsLimit int64 `json:"pids_limit"`
86
87	// Specifies per cgroup weight, range is from 10 to 1000.
88	BlkioWeight uint16 `json:"blkio_weight"`
89
90	// Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
91	BlkioLeafWeight uint16 `json:"blkio_leaf_weight"`
92
93	// Weight per cgroup per device, can override BlkioWeight.
94	BlkioWeightDevice []*WeightDevice `json:"blkio_weight_device"`
95
96	// IO read rate limit per cgroup per device, bytes per second.
97	BlkioThrottleReadBpsDevice []*ThrottleDevice `json:"blkio_throttle_read_bps_device"`
98
99	// IO write rate limit per cgroup per device, bytes per second.
100	BlkioThrottleWriteBpsDevice []*ThrottleDevice `json:"blkio_throttle_write_bps_device"`
101
102	// IO read rate limit per cgroup per device, IO per second.
103	BlkioThrottleReadIOPSDevice []*ThrottleDevice `json:"blkio_throttle_read_iops_device"`
104
105	// IO write rate limit per cgroup per device, IO per second.
106	BlkioThrottleWriteIOPSDevice []*ThrottleDevice `json:"blkio_throttle_write_iops_device"`
107
108	// set the freeze value for the process
109	Freezer FreezerState `json:"freezer"`
110
111	// Hugetlb limit (in bytes)
112	HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"`
113
114	// Whether to disable OOM Killer
115	OomKillDisable bool `json:"oom_kill_disable"`
116
117	// Tuning swappiness behaviour per cgroup
118	MemorySwappiness *uint64 `json:"memory_swappiness"`
119
120	// Set priority of network traffic for container
121	NetPrioIfpriomap []*IfPrioMap `json:"net_prio_ifpriomap"`
122
123	// Set class identifier for container's network packets
124	NetClsClassid uint32 `json:"net_cls_classid_u"`
125
126	// Used on cgroups v2:
127
128	// CpuWeight sets a proportional bandwidth limit.
129	CpuWeight uint64 `json:"cpu_weight"`
130
131	// Unified is cgroupv2-only key-value map.
132	Unified map[string]string `json:"unified"`
133
134	// SkipDevices allows to skip configuring device permissions.
135	// Used by e.g. kubelet while creating a parent cgroup (kubepods)
136	// common for many containers.
137	//
138	// NOTE it is impossible to start a container which has this flag set.
139	SkipDevices bool `json:"skip_devices"`
140}
141