Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
976 commits
Select commit Hold shift + click to select a range
7026680
libct/cg: stop using pkg/errors
kolyshkin Jun 11, 2021
0ab2ceb
*: stop using pkg/errors
kolyshkin Jun 11, 2021
4073b41
merge branch 'pr-3011'
cyphar Jun 24, 2021
ca887f2
ci: enable unconvert linter, fix its warnings
kolyshkin Jul 7, 2021
7f33cf1
libct/cg/sd: Don't freeze cgroup on cgroup v2 Set
odinuge Jul 7, 2021
1ff41ec
libct/cg/fs/freezer.GetState: report current cgroup state
odinuge Jul 5, 2021
4a45e7a
libct/cg/sd: Add freezer tests
odinuge Jul 7, 2021
623fcfa
Merge pull request #3070 from kolyshkin/unconvert
Jul 12, 2021
25b976b
merge branch 'pr-3067'
cyphar Jul 13, 2021
4c1e0ee
cgroupv2: ebpf: ignore inaccessible existing programs
cyphar Jul 1, 2021
5ac56a8
Merge pull request #3055 from cyphar/cgroup-bpf-replace-selinux
AkihiroSuda Jul 14, 2021
eb6d552
libct/cg/sd/v1: Set: don't overwrite r.Freezer
kolyshkin Jul 11, 2021
432c05f
libct/cg/sd/v1: Set: avoid unnecessary freeze/thaw
kolyshkin Jul 9, 2021
27d005f
libct/cg/sd: TestFreezePodCgroup: rm explicit freeze
kolyshkin Jul 11, 2021
21256ad
libct/cg/sd: add TestPodSkipDevicesUpdate
kolyshkin Jul 11, 2021
9e09559
Merge pull request #3082 from kolyshkin/freeze-less
Jul 15, 2021
d108677
libct/cg/fscommon: drop go 1.13 compatibility
kolyshkin Jul 19, 2021
49873bf
libct/cg/fs/*_test.go: use t.TempDir
kolyshkin Jul 19, 2021
e242abd
libct/*_test.go: use t.TempDir
kolyshkin Jul 20, 2021
9f3ef8e
Merge pull request #3100 from kolyshkin/drop-go-1.13
kolyshkin Jul 27, 2021
3576c96
libct/cg: move GetAllPids out of utils.go
kolyshkin Aug 5, 2021
c04029e
libct/cg: improve GetAllPids and readProcsFile
kolyshkin Aug 5, 2021
e9d238d
libct/cg: GetAllPids: optimize for go 1.16+
kolyshkin Aug 5, 2021
b3ede91
libct/cg: rm dead code
kolyshkin Aug 8, 2021
f52419f
libct/cg/OpenFile: fix openat2 vs top cgroup dir
kolyshkin Jun 15, 2021
6e370e8
merge branch 'pr-3133'
cyphar Aug 10, 2021
be5cea9
libct/cg/OpenFile: check cgroupFd on error
kolyshkin Jun 15, 2021
d2d73a9
libct/devices: change devices.Type to be a string
thaJeztah Aug 12, 2021
927d9f0
Fix codespell warnings, add codespell to ci
kolyshkin Aug 11, 2021
638e006
libct/cg/sd/v1: Fix unnecessary freeze/thaw
odinuge Aug 10, 2021
7752985
libct/cg/sd/v1: add freezeBeforeSet unit test
kolyshkin Aug 11, 2021
43cc963
libct/cg/sd/v1: add SkipFreezeOnSet knob
kolyshkin Aug 17, 2021
d4ed047
Add support for rdma cgroup introduced in Linux Kernel 4.11
flouthoc Apr 1, 2021
2a4440e
Merge pull request #3159 from thaJeztah/norunes
kolyshkin Aug 23, 2021
2e71cba
libct/cg/devices: stop using regex
kolyshkin Jul 24, 2021
6516311
Merge pull request #3110 from kolyshkin/parse-devices
thaJeztah Aug 24, 2021
5fa7c78
Revert "libct/devices: change devices.Type to be a string"
cyphar Aug 25, 2021
6112fcd
Merge pull request #3136 from kolyshkin/cg-d-c
hqhq Aug 25, 2021
1af0b1d
Merge pull request #3182 from cyphar/revert-3159
thaJeztah Aug 25, 2021
ae929bf
libct/cg/v1: workaround CPU quota period set failure
kolyshkin Jul 28, 2021
ad9d1c9
improve error message when dbus-user-session is not installed
AkihiroSuda Aug 27, 2021
f7248b9
Merge pull request #3090 from kolyshkin/cfq_quota_period
AkihiroSuda Aug 30, 2021
170c372
Merge pull request #2883 from flouthoc/master
kolyshkin Aug 31, 2021
b014568
libct/*: remove linux build tag from some pkgs
kolyshkin Aug 31, 2021
ff9f8e8
libct/cg: rm "unsupported.go" files
kolyshkin Aug 31, 2021
b1f7b30
*: add go-1.17+ go:build tags
kolyshkin Aug 31, 2021
a11d5e6
Merge pull request #3030 from kolyshkin/openat2-improve
thaJeztah Sep 3, 2021
891c22e
merge branch 'pr-3186'
cyphar Sep 9, 2021
f10054e
libct/cg/sd/v*.go: nit
kolyshkin Aug 6, 2021
6db84e5
libct/cg/sd/v1: factor out initPaths
kolyshkin Aug 6, 2021
9af28ef
libct/cg/sd/v1: optimize initPaths
kolyshkin Aug 6, 2021
c3b146d
libct/cg/sd/v1: initPaths: minor optimization
kolyshkin Aug 6, 2021
3a44969
libct/cg/fs: move internal code out of fs.go
kolyshkin Aug 10, 2021
fab7627
libct/cg/fs: micro optimization
kolyshkin Aug 10, 2021
9c7bb7e
libct/cg/fs: rename join to apply
kolyshkin Aug 10, 2021
6cd60e7
libct/cg/fs: refactor
kolyshkin Aug 10, 2021
4fd8c18
libct/cg: replace bitset with std math/big library
zhsj Sep 19, 2021
fe716cd
Merge pull request #3219 from zhsj/simple-bits
AkihiroSuda Sep 20, 2021
f67f721
Merge pull request #3215 from kolyshkin/cgroupv1-opts
kolyshkin Sep 21, 2021
1a7287a
libct/cg: simplify getting cgroup manager
kolyshkin Aug 7, 2021
131d3e2
libct/cg/fs: move paths init to NewManager
kolyshkin Aug 11, 2021
d445479
libct/cg/fs: document path removal
kolyshkin Aug 11, 2021
1e71c2c
libct/cg/sd/v1: move path init to NewLegacyManager
kolyshkin Aug 11, 2021
fe1f428
libct/cg/fs2: minor optimization
kolyshkin Aug 11, 2021
b0782b3
libct/cg/sd/v2: move path init to NewUnifiedManager
kolyshkin Aug 11, 2021
4b97382
libct/cg/sd/v2: move fsMgr init to NewUnifiedManager
kolyshkin Aug 11, 2021
a95abb5
libct/cg: add Resources=nil unit test
kolyshkin Aug 31, 2021
4a73885
libct/cg/fs: rm m.config == nil checks
kolyshkin Sep 23, 2021
f081bf0
Merge pull request #3216 from kolyshkin/manager-new
Sep 23, 2021
789b7f7
libct/cg.WriteCgroupProcs: improve errors
kolyshkin Jun 30, 2021
148ebfb
cgroups: join cgroup v2 when using hybrid mode
mauriciovasquezbernal Feb 5, 2021
c296e53
libct/cg/sd/v2: Destroy: remove cgroups recursively
chenk008 Sep 27, 2021
585d068
Make DevicesGroup's "TestingSkipFinalCheck" attribute public
iholder101 Jun 7, 2021
f199f1a
libct/cg/fs2: fix GetStats for unsupported hugetlb
kolyshkin Oct 5, 2021
a0fddeb
Merge pull request #3059 from kolyshkin/cgroup-clean
kolyshkin Oct 7, 2021
adfa638
Merge pull request #3233 from kolyshkin/hugepage-fix
AkihiroSuda Oct 12, 2021
357631e
Remove io/ioutil use
kolyshkin Oct 13, 2021
7074ebe
Merge pull request #3002 from iholder-redhat/feature/TestingSkipFinal…
AkihiroSuda Oct 16, 2021
52d1145
Merge pull request #3245 from kolyshkin/go116
thaJeztah Oct 17, 2021
8cbe02d
libct/cg: GetHugePageSize -> HugePageSizes
kolyshkin Oct 6, 2021
1d2384d
libct/cg: lazy init for HugePageSizes
kolyshkin Oct 6, 2021
78ba6be
libct/cg: HugePageSizes: simplify code and test
kolyshkin Oct 6, 2021
cb91282
libct/cg: TestGetHugePageSizeImpl: use t.Run
kolyshkin Nov 19, 2021
4821257
chown cgroup to process uid in container namespace
frasertweedale Jun 16, 2021
8201070
libct/cg/devices: addRule: ignore unparam warning
kolyshkin Nov 30, 2021
91cd101
libct/cg/ebpf: drop finalize return value
kolyshkin Nov 30, 2021
b03d901
libct/cg/fs/blkio_test: ignore unparam warning
kolyshkin Nov 30, 2021
14bf64d
Merge pull request #3302 from kolyshkin/ci-unparam
thaJeztah Nov 30, 2021
7f3727a
merge branch 'pr-3057'
cyphar Dec 7, 2021
6f0808d
libct/cg: rm go 1.15 compatibility
kolyshkin Dec 14, 2021
a2a446c
Merge pull request #3325 from kolyshkin/rm-go115
AkihiroSuda Dec 15, 2021
90662fe
libct/cg/sd/v2: fix ENOENT on cgroup delegation
kolyshkin Feb 21, 2022
af38d5f
libct/cg/sd: escape dbus address value
kolyshkin Feb 1, 2022
59ae2e6
libct/cg/sd: simplify DetectUserDbusSessionBusAddress
kolyshkin Jan 28, 2022
10fb55d
Format sources using gofumpt 0.2.1
kolyshkin Feb 9, 2022
1cb0ecb
Merge pull request #3370 from kolyshkin/bump-gofumpt
thaJeztah Mar 8, 2022
8c760e1
Merge pull request #3356 from kolyshkin/user-dbus
thaJeztah Mar 9, 2022
20a9ba4
libcontainer: remove LinuxFactory
kolyshkin Feb 11, 2022
52343ac
Merge pull request #3373 from kolyshkin/less-interfaces
thaJeztah Mar 23, 2022
4cbff4b
libct/cg: IsCgroup2HybridMode: don't panic
kolyshkin Mar 27, 2022
e944c32
Merge pull request #3433 from kolyshkin/dont-panic
AkihiroSuda Mar 28, 2022
ab4e720
Remove tun/tap from the default device rules
kolyshkin May 4, 2022
c82d483
libct/cg/sd: factor out devices.go
kolyshkin Mar 23, 2022
69937c0
Decouple cgroup devices handling
kolyshkin Apr 7, 2022
8a90b8b
libct/cg/dev: privatize some functions
kolyshkin Apr 9, 2022
6341145
libct/cg/sd: check dbus.ErrClosed instead of isDbusError
chenk008 May 20, 2022
b7c58cc
Merge pull request #3475 from chenk008/fix_dbus_connection_closed
kolyshkin May 20, 2022
a621c5d
Merge pull request #3452 from kolyshkin/separate-devices
AkihiroSuda May 25, 2022
56b65d5
vendor: bump cilium/ebpf to v0.9.0
kolyshkin May 26, 2022
c11b544
cgroups: systemd: skip adding device paths that don't exist
cyphar Jun 2, 2022
533250a
libct: fixes for godoc 1.19
kolyshkin Aug 3, 2022
9d17e2b
Fix failed exec after systemctl daemon-reload
kolyshkin Aug 11, 2022
b478680
Merge pull request #3559 from kolyshkin/fix-dev-pts
kolyshkin Aug 18, 2022
f8c64d8
libcontainer/cgroups: return concrete types
thaJeztah Oct 6, 2022
2e5c224
Fixes inability to use /dev/null when inside a container
evanphx Oct 3, 2022
57ab7d6
merge branch 'pr-3623'
cyphar Oct 12, 2022
5bd5132
cgroups: cpuset: fix byte order while parsing cpuset range to bits
yukariatlas Sep 26, 2022
6ab1603
Merge pull request #3626 from thaJeztah/more_idiomatic
Oct 13, 2022
af2cbec
Merge pull request #3611 from yukariatlas/main
Oct 13, 2022
f9572fc
runc update: implement memory.checkBeforeUpdate
kolyshkin Aug 29, 2022
e177f56
Merge pull request #3579 from kolyshkin/v2-low-mem
kolyshkin Nov 3, 2022
7807000
libct/cg/sd: stop using regex, fix systemdVersionAtoi
kolyshkin Apr 14, 2022
2050629
support SCHED_IDLE for runc cgroupfs
wineway May 12, 2022
92f54ad
Merge pull request #3377 from wineway/main
kolyshkin Feb 1, 2023
657cdec
Merge pull request #3460 from kolyshkin/no-regexp
thaJeztah Feb 6, 2023
3869859
tests: Fix weird error on centos-9
rata Feb 10, 2023
7d34ccd
Merge pull request #3740 from kinvolk/rata/fix-basename-test
AkihiroSuda Feb 11, 2023
dcf5844
libct/cg/dev: skip flaky test of CentOS 7
kolyshkin Mar 22, 2023
8f5ed78
libctr/cgroups: don't take init's cgroup into account
haircommander Mar 24, 2023
1d7f1ff
libct/cg: rm EnterPid
kolyshkin Mar 29, 2023
1992d5e
libct/cg/sd: refactor startUnit
kolyshkin Mar 23, 2023
61a734b
libct/cg/sd: ignore UnitExists only for Apply(-1)
kolyshkin Mar 23, 2023
ce6e16a
libct/cg/sd: reset-failed and retry startUnit on UnitExists
kolyshkin Mar 23, 2023
3ae4557
Merge pull request #3797 from kolyshkin/enter-pid
kolyshkin Mar 31, 2023
2cb713e
Merge pull request #3782 from kolyshkin/fix-sd-start
kolyshkin Apr 3, 2023
15d3a89
libct/cg/sd/v2: unifiedResToSystemdProps nit
kolyshkin Mar 28, 2023
da26a05
libct/cg/sd: support setting cpu.idle via systemd
kolyshkin Mar 27, 2023
268766d
Merge pull request #3788 from kolyshkin/systemd-cpu-idle
mrunalp Apr 4, 2023
69d683a
Merge pull request #3784 from haircommander/root-cgroup-no-init
kolyshkin Apr 4, 2023
68248e6
libct/cg: rm GetInitCgroup[Path]
kolyshkin Apr 4, 2023
5616809
libct/cg: add misc controller to v1 drivers
kolyshkin Apr 5, 2023
5db3a9e
libct/cg/sd: use systemd version when generating dev props
kolyshkin Apr 24, 2023
47e64cf
Merge pull request #3842 from kolyshkin/rm-warning
mrunalp Apr 25, 2023
2a6abbf
libct/cg/dev: optimize and test findDeviceGroup
kolyshkin Jan 28, 2022
3941251
Merge pull request #3357 from kolyshkin/more-bytes-less-strings
thaJeztah Apr 27, 2023
9726a5d
libct/cg/sd/v1: do not update non-frozen cgroup after frozen failed.
jiusanzhou Apr 3, 2023
1aabfdb
libct/cg/stats: support PSI for cgroup v2
dqminh Jan 28, 2022
1fd0c88
libct/cg: IsCgroup2UnifiedMode: don't panic
kolyshkin Apr 13, 2023
720e855
libct/cg/sd: remove logging from resetFailedUnit
kolyshkin Jun 6, 2023
0d271cc
runc delete: call systemd's reset-failed
kolyshkin Jun 5, 2023
4e5ca2c
Merge pull request #3900 from kolyshkin/psi
lifubang Jul 14, 2023
a59b37a
libct/cg/sd: use systemd v240+ new MAJOR:* syntax
kolyshkin Apr 25, 2023
747208d
Merge pull request #3843 from kolyshkin/skip-proc-devices
lifubang Jul 30, 2023
db0bb80
libct/cg/fs2: use `file` + `anon` + `swap` for usage
alexeldeib Jul 10, 2023
ad496fb
ci: fix TestNilResources when systemd not available
kolyshkin Aug 3, 2023
813716e
ci: fix TestOpenat2 when no systemd is used
kolyshkin Aug 3, 2023
11f046f
Merge pull request #3960 from kolyshkin/local-ci-v2
AkihiroSuda Aug 3, 2023
74b0b1b
Remove nolint annotations for unix errno comparisons
kolyshkin Aug 25, 2023
bbbf05a
Fix File to Close
Sep 1, 2023
1022b11
Merge pull request #4004 from hangscer8/fix_file_to_close
kolyshkin Sep 1, 2023
bd437d5
libct/cg: add CFS bandwidth burst for CPU
kailun-qin Sep 9, 2021
620801c
Handle kmem.limit_in_bytes removal
jrife Sep 16, 2023
1ea1059
libct/cg/stats: support misc for cgroup v2
mythi Aug 4, 2023
f07d11a
ci: skip TestPodSkipDevicesUpdate on CentOS 7
kolyshkin Oct 6, 2023
a0d4fbc
libct/cg/dev: add sync.Once to test case
kolyshkin Oct 10, 2023
e2ef2d4
libct/cg: support hugetlb rsvd
kolyshkin Mar 21, 2023
6401d20
Merge pull request #4073 from kolyshkin/hugetlb-rsvd
mrunalp Oct 19, 2023
a016e94
libct/cg: remove retry on EINTR in
kolyshkin Oct 20, 2023
5a88499
Merge pull request #4084 from kolyshkin/no-retry
lifubang Oct 23, 2023
cdcf7d4
libct/cg/fs.Set: fix error message
kolyshkin Oct 20, 2023
72d151c
Merge pull request #4085 from kolyshkin/fix-check_cgroup_value
kolyshkin Oct 24, 2023
3f0000b
libct/cg: add swapOnlyUsage in MemoryStats
HeRaNO Sep 9, 2023
9d0dde0
Merge pull request #3972 from mythi/misc-stats
lifubang Oct 25, 2023
3dab061
Merge pull request #4010 from HeRaNO/use-peak
lifubang Oct 25, 2023
a441f15
libct/cgroups.OpenFile: clean "file" argument
kolyshkin Oct 25, 2023
7ea666f
internal/testutil: create, add SkipOnCentOS
kolyshkin Oct 23, 2023
f1cc740
libct/cg: skip TestWriteCgroupFileHandlesInterrupt on CentOS 7
kolyshkin Oct 27, 2023
41e4922
fix some unit test error after bump ebpf to 0.12.3
lifubang Nov 10, 2023
e09c657
merge #4119 into opencontainers/runc:main
cyphar Nov 11, 2023
164bcb1
libct/cg: improve cgroup removal logic
kolyshkin Nov 9, 2023
29aafee
tree-wide: use /proc/thread-self for thread-local state
cyphar Aug 24, 2023
8f731c2
cgroup: plug leaks of /sys/fs/cgroup handle
cyphar Dec 26, 2023
7d56d1d
Set temporary single CPU affinity before cgroup cpuset transition.
cclerget Jun 30, 2023
355b36e
Merge pull request #3923 from cclerget/issue-3922
kolyshkin Apr 16, 2024
abcb0df
libct: decouple libct/cg/devices
kolyshkin Apr 17, 2024
eb64f52
libct/cg/fs: don't write cpu_burst twice on ENOENT
kolyshkin Apr 25, 2024
794d670
libct/cg/fs: fix setting rt_period vs rt_runtime
kolyshkin Apr 25, 2024
befafa5
libct/cg/dev: fix TestSetV1Allow panic
kolyshkin May 30, 2024
45d5dc0
libct/cg/fs/v2: ignore setting swap in some cases
kolyshkin Mar 26, 2024
3109ce0
Merge pull request #4188 from kolyshkin/ci-swap
lifubang Jun 7, 2024
9cb3e95
libct/cg: use clear built-in
kolyshkin May 25, 2024
54e1787
libct/cg: write unified resources line by line
kolyshkin Feb 2, 2024
dccc016
Merge pull request #4186 from kolyshkin/multi-line
AkihiroSuda Jun 9, 2024
2f35b31
Revert "Set temporary single CPU affinity..."
kolyshkin May 18, 2024
405e8ae
Merge pull request #4283 from kolyshkin/revert-cpu-aff
lifubang Jun 9, 2024
1c29266
Bump golangci-lint to v1.60, fix new warnings
kolyshkin Aug 14, 2024
f2323e5
Merge pull request #4360 from kolyshkin/go123
lifubang Aug 15, 2024
ed3dcf2
Upgrade Cilium's eBPF library version to 0.16
rafaelroquetto Sep 12, 2024
14b41a3
runc create/run: warn on rootless + shared pidns + no cgroup
kolyshkin Sep 12, 2024
b1af30d
libcontainer/cgroups/fs: remove todo since strings.Fields performs well
Stavrospanakakis Sep 15, 2024
d7ffc11
Merge pull request #4403 from Stavrospanakakis/replace-fields-splitn-…
kolyshkin Sep 27, 2024
8eba4f0
replace strings.SplitN with strings.Cut
amghazanfari Sep 28, 2024
9127eb1
Merge pull request #4405 from amghazanfari/main
kolyshkin Oct 4, 2024
45019d2
libcontainer/userns: migrate to github.com/moby/sys/userns
thaJeztah Jul 25, 2024
46110e6
merge #4350 into opencontainers/runc:main
cyphar Oct 9, 2024
1147f0e
libct/cg: improve ConvertMemorySwapToCgroupV2Value
kolyshkin Sep 12, 2024
322fddc
runc update: fix updating swap for cgroup v2
kolyshkin Jul 22, 2024
7760f51
ci: rm "skip on CentOS 7" kludges
kolyshkin Nov 5, 2024
a4ea83d
runc delete: fix for rootless cgroup + ro cgroupfs
kolyshkin Nov 12, 2024
3945cf4
libct/cg: RemovePath: simplify logic
kolyshkin Nov 12, 2024
0b2216e
libct/cg: RemovePath: improve comments
kolyshkin Nov 12, 2024
06d8305
Merge pull request #4523 from kolyshkin/fix-4518
thaJeztah Nov 12, 2024
2f0a7be
libct/cg: add test for remove a non-existent dir in a ro mount point
lifubang Nov 12, 2024
49dac8c
Merge pull request #4526 from lifubang/test-cgroup-removepath
kolyshkin Nov 15, 2024
8572588
cgroups: ebpf: use link.Anchor to check for BPF_F_REPLACE support
cyphar Dec 6, 2024
123c9ca
cgroups: ebpf: also check for ebpf.ErrNotSupported
cyphar Dec 6, 2024
d0816db
cgroup: ebpf: make unexpected errors in haveBpfProgReplace louder
cyphar Dec 6, 2024
65ddd96
libct/cg/fs2: fix some revive linter warnings
kolyshkin Dec 12, 2024
92d1706
libct/configs: move cgroup stuff to libct/cgroups
kolyshkin Oct 23, 2024
49cd3bd
libct/cgroups/*: switch from configs to cgroups
kolyshkin Oct 23, 2024
5145727
Re-add tun/tap to default device rules
kolyshkin Dec 16, 2024
bba8f5a
merge #4555 into opencontainers/runc:main
cyphar Dec 17, 2024
050e8eb
support cgroup v1 mounted with noprefix
tomaszduda23 Dec 8, 2024
439e675
libct/devices: move config to libct/cg/devices/config
kolyshkin Jan 4, 2025
8fbd9fe
libct: switch from libct/devices to libct/cgroups/devices/config
kolyshkin Jan 4, 2025
b250834
Merge pull request #4577 from kolyshkin/libct-dev
kolyshkin Feb 1, 2025
24bf68c
libct/cg/sd: set the DeviceAllow property before DevicePolicy
kolyshkin Feb 5, 2025
e0d47d4
libct/cg/fs: getPercpuUsage: rm TODO
kolyshkin Oct 23, 2024
d193d0a
libct/cg/fs: refactor getCpusetStat
kolyshkin Oct 23, 2024
cf1a33a
libcontainer/cgroups/fs: some refactoring
kolyshkin Oct 23, 2024
4e53ad7
libct/cg/fs2: simplify parseCgroupFromReader
kolyshkin Oct 23, 2024
e7ddbd0
libct/cg/fs2: use strings.Cut in setUnified
kolyshkin Oct 23, 2024
87e1b47
libct/cg/fs2: use strings.Cut in parsePSIData
kolyshkin Oct 23, 2024
9c21a45
libct/cg/fscommon: use strings.Cut in RDMA parser
kolyshkin Oct 23, 2024
796f000
libct/cg/fscommon: ParseKeyValue: use strings.Cut
kolyshkin Oct 23, 2024
d339953
libct/cg/fscommon: GetValueByKey: use strings.CutPrefix
kolyshkin Jan 6, 2025
556bb98
libct/cg/fscommon: ParseKeyValue: stricter check
kolyshkin Jan 6, 2025
62de3a4
libct/cg/fscommon: GetCgroupParam*: unify
kolyshkin Jan 6, 2025
03f714e
libct: use strings.CutPrefix where possible
kolyshkin Jan 7, 2025
c3df699
libct/cg: stop using utils.ProcThreadSelf
kolyshkin Feb 13, 2025
8ded681
libct/cg/fs2: rm _defaultDirPath
kolyshkin Feb 13, 2025
f13517e
libct/cg: add internal/path.Inner
kolyshkin Feb 13, 2025
35f5017
libct/cg: don't use utils.CleanPath
kolyshkin Feb 13, 2025
bf11eba
libct/cg/dev: remove specconv dependency
kolyshkin Feb 14, 2025
145f43f
Merge pull request #4633 from kolyshkin/libct-cg-sep
lifubang Feb 25, 2025
b1c8cf4
merge #4513 into opencontainers/runc:main
cyphar Feb 25, 2025
d36d371
Fix import paths
kolyshkin Feb 26, 2025
9d86f4b
go.mod: add
kolyshkin Feb 26, 2025
5ceb477
Export libcontainer/cgroups from runc
kolyshkin Feb 26, 2025
574c6e4
MAINTAINERS: populate
kolyshkin Feb 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions MAINTAINERS
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
This meta-project is maintained by the union of MAINTAINERS for all OCI Projects [1].

Other OCI Projects should list one maintainer per line, with a name, email address, and GitHub username:

Random J Developer <[email protected]> (@RandomJDeveloperExample)
A. U. Thor <[email protected]> (@AUThorExample)

[1]: https://github.com/opencontainers/
Akihiro Suda <[email protected]> (@AkihiroSuda)
Aleksa Sarai <[email protected]> (@cyphar)
Kir Kolyshkin <[email protected]> (@kolyshkin)
Mrunal Patel <[email protected]> (@mrunalp)
Sebastiaan van Stijn <[email protected]> (@thaJeztah)
Odin Ugedal <[email protected]> (@odinuge)
Peter Hunt <[email protected]> (@haircommander)
Davanum Srinivas <davanum@gmail.com> (@dims)
78 changes: 78 additions & 0 deletions cgroups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package cgroups
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way we can maintain git history while also adding this to pkg/cgroups directory? it feels to me as being more idomatic modern go. I'm not terribly attached to it though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a way, but this repo is called github.com/opencontainers/cgroups, so what could be done is something like github.com/opencontainers/cgroups/pkg/cgroups which does not look good to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was unsure about that too. fine with me


import (
"errors"
)

var (
// ErrDevicesUnsupported is an error returned when a cgroup manager
// is not configured to set device rules.
ErrDevicesUnsupported = errors.New("cgroup manager is not configured to set device rules")

// ErrRootless is returned by [Manager.Apply] when there is an error
// creating cgroup directory, and cgroup.Rootless is set. In general,
// this error is to be ignored.
ErrRootless = errors.New("cgroup manager can not access cgroup (rootless container)")

// DevicesSetV1 and DevicesSetV2 are functions to set devices for
// cgroup v1 and v2, respectively. Unless
// [github.com/opencontainers/cgroups/devices]
// package is imported, it is set to nil, so cgroup managers can't
// manage devices.
DevicesSetV1 func(path string, r *Resources) error
DevicesSetV2 func(path string, r *Resources) error
)

type Manager interface {
// Apply creates a cgroup, if not yet created, and adds a process
// with the specified pid into that cgroup. A special value of -1
// can be used to merely create a cgroup.
Apply(pid int) error

// GetPids returns the PIDs of all processes inside the cgroup.
GetPids() ([]int, error)

// GetAllPids returns the PIDs of all processes inside the cgroup
// any all its sub-cgroups.
GetAllPids() ([]int, error)

// GetStats returns cgroups statistics.
GetStats() (*Stats, error)

// Freeze sets the freezer cgroup to the specified state.
Freeze(state FreezerState) error

// Destroy removes cgroup.
Destroy() error

// Path returns a cgroup path to the specified controller/subsystem.
// For cgroupv2, the argument is unused and can be empty.
Path(string) string

// Set sets cgroup resources parameters/limits. If the argument is nil,
// the resources specified during Manager creation (or the previous call
// to Set) are used.
Set(r *Resources) error

// GetPaths returns cgroup path(s) to save in a state file in order to
// restore later.
//
// For cgroup v1, a key is cgroup subsystem name, and the value is the
// path to the cgroup for this subsystem.
//
// For cgroup v2 unified hierarchy, a key is "", and the value is the
// unified path.
GetPaths() map[string]string

// GetCgroups returns the cgroup data as configured.
GetCgroups() (*Cgroup, error)

// GetFreezerState retrieves the current FreezerState of the cgroup.
GetFreezerState() (FreezerState, error)

// Exists returns whether the cgroup path exists or not.
Exists() bool

// OOMKillCount reports OOM kill count for the cgroup.
OOMKillCount() (uint64, error)
}
21 changes: 21 additions & 0 deletions cgroups_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cgroups

import (
"testing"
)

func TestParseCgroups(t *testing.T) {
// We don't need to use /proc/thread-self here because runc always runs
// with every thread in the same cgroup. This lets us avoid having to do
// runtime.LockOSThread.
cgroups, err := ParseCgroupFile("/proc/self/cgroup")
if err != nil {
t.Fatal(err)
}
if IsCgroup2UnifiedMode() {
return
}
if _, ok := cgroups["cpu"]; !ok {
t.Fail()
}
}
66 changes: 66 additions & 0 deletions config_blkio_device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package cgroups

import "fmt"

// BlockIODevice holds major:minor format supported in blkio cgroup.
type BlockIODevice struct {
// Major is the device's major number
Major int64 `json:"major"`
// Minor is the device's minor number
Minor int64 `json:"minor"`
}

// WeightDevice struct holds a `major:minor weight`|`major:minor leaf_weight` pair
type WeightDevice struct {
BlockIODevice
// Weight is the bandwidth rate for the device, range is from 10 to 1000
Weight uint16 `json:"weight"`
// LeafWeight is the bandwidth rate for the device while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
LeafWeight uint16 `json:"leafWeight"`
}

// NewWeightDevice returns a configured WeightDevice pointer
func NewWeightDevice(major, minor int64, weight, leafWeight uint16) *WeightDevice {
wd := &WeightDevice{}
wd.Major = major
wd.Minor = minor
wd.Weight = weight
wd.LeafWeight = leafWeight
return wd
}

// WeightString formats the struct to be writable to the cgroup specific file
func (wd *WeightDevice) WeightString() string {
return fmt.Sprintf("%d:%d %d", wd.Major, wd.Minor, wd.Weight)
}

// LeafWeightString formats the struct to be writable to the cgroup specific file
func (wd *WeightDevice) LeafWeightString() string {
return fmt.Sprintf("%d:%d %d", wd.Major, wd.Minor, wd.LeafWeight)
}

// ThrottleDevice struct holds a `major:minor rate_per_second` pair
type ThrottleDevice struct {
BlockIODevice
// Rate is the IO rate limit per cgroup per device
Rate uint64 `json:"rate"`
}

// NewThrottleDevice returns a configured ThrottleDevice pointer
func NewThrottleDevice(major, minor int64, rate uint64) *ThrottleDevice {
td := &ThrottleDevice{}
td.Major = major
td.Minor = minor
td.Rate = rate
return td
}

// String formats the struct to be writable to the cgroup specific file
func (td *ThrottleDevice) String() string {
return fmt.Sprintf("%d:%d %d", td.Major, td.Minor, td.Rate)
}

// StringName formats the struct to be writable to the cgroup specific file
func (td *ThrottleDevice) StringName(name string) string {
return fmt.Sprintf("%d:%d %s=%d", td.Major, td.Minor, name, td.Rate)
}
9 changes: 9 additions & 0 deletions config_hugepages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cgroups

type HugepageLimit struct {
// which type of hugepage to limit.
Pagesize string `json:"page_size"`

// usage limit for hugepage.
Limit uint64 `json:"limit"`
}
14 changes: 14 additions & 0 deletions config_ifprio_map.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cgroups

import (
"fmt"
)

type IfPrioMap struct {
Interface string `json:"interface"`
Priority int64 `json:"priority"`
}

func (i *IfPrioMap) CgroupString() string {
return fmt.Sprintf("%s %d", i.Interface, i.Priority)
}
169 changes: 169 additions & 0 deletions config_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package cgroups

import (
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
devices "github.com/opencontainers/cgroups/devices/config"
)

type FreezerState string

const (
Undefined FreezerState = ""
Frozen FreezerState = "FROZEN"
Thawed FreezerState = "THAWED"
)

// Cgroup holds properties of a cgroup on Linux.
type Cgroup struct {
// Name specifies the name of the cgroup
Name string `json:"name,omitempty"`

// Parent specifies the name of parent of cgroup or slice
Parent string `json:"parent,omitempty"`

// Path specifies the path to cgroups that are created and/or joined by the container.
// The path is assumed to be relative to the host system cgroup mountpoint.
Path string `json:"path"`

// ScopePrefix describes prefix for the scope name
ScopePrefix string `json:"scope_prefix"`

// Resources contains various cgroups settings to apply
*Resources

// Systemd tells if systemd should be used to manage cgroups.
Systemd bool

// SystemdProps are any additional properties for systemd,
// derived from org.systemd.property.xxx annotations.
// Ignored unless systemd is used for managing cgroups.
SystemdProps []systemdDbus.Property `json:"-"`

// Rootless tells if rootless cgroups should be used.
Rootless bool

// The host UID that should own the cgroup, or nil to accept
// the default ownership. This should only be set when the
// cgroupfs is to be mounted read/write.
// Not all cgroup manager implementations support changing
// the ownership.
OwnerUID *int `json:"owner_uid,omitempty"`
}

type Resources struct {
// Devices is the set of access rules for devices in the container.
Devices []*devices.Rule `json:"devices"`

// Memory limit (in bytes)
Memory int64 `json:"memory"`

// Memory reservation or soft_limit (in bytes)
MemoryReservation int64 `json:"memory_reservation"`

// Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwap int64 `json:"memory_swap"`

// CPU shares (relative weight vs. other containers)
CpuShares uint64 `json:"cpu_shares"`

// CPU hardcap limit (in usecs). Allowed cpu time in a given period.
CpuQuota int64 `json:"cpu_quota"`

// CPU hardcap burst limit (in usecs). Allowed accumulated cpu time additionally for burst in a given period.
CpuBurst *uint64 `json:"cpu_burst"` //nolint:revive

// CPU period to be used for hardcapping (in usecs). 0 to use system default.
CpuPeriod uint64 `json:"cpu_period"`

// How many time CPU will use in realtime scheduling (in usecs).
CpuRtRuntime int64 `json:"cpu_rt_quota"`

// CPU period to be used for realtime scheduling (in usecs).
CpuRtPeriod uint64 `json:"cpu_rt_period"`

// CPU to use
CpusetCpus string `json:"cpuset_cpus"`

// MEM to use
CpusetMems string `json:"cpuset_mems"`

// cgroup SCHED_IDLE
CPUIdle *int64 `json:"cpu_idle,omitempty"`

// Process limit; set <= `0' to disable limit.
PidsLimit int64 `json:"pids_limit"`

// Specifies per cgroup weight, range is from 10 to 1000.
BlkioWeight uint16 `json:"blkio_weight"`

// Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
BlkioLeafWeight uint16 `json:"blkio_leaf_weight"`

// Weight per cgroup per device, can override BlkioWeight.
BlkioWeightDevice []*WeightDevice `json:"blkio_weight_device"`

// IO read rate limit per cgroup per device, bytes per second.
BlkioThrottleReadBpsDevice []*ThrottleDevice `json:"blkio_throttle_read_bps_device"`

// IO write rate limit per cgroup per device, bytes per second.
BlkioThrottleWriteBpsDevice []*ThrottleDevice `json:"blkio_throttle_write_bps_device"`

// IO read rate limit per cgroup per device, IO per second.
BlkioThrottleReadIOPSDevice []*ThrottleDevice `json:"blkio_throttle_read_iops_device"`

// IO write rate limit per cgroup per device, IO per second.
BlkioThrottleWriteIOPSDevice []*ThrottleDevice `json:"blkio_throttle_write_iops_device"`

// set the freeze value for the process
Freezer FreezerState `json:"freezer"`

// Hugetlb limit (in bytes)
HugetlbLimit []*HugepageLimit `json:"hugetlb_limit"`

// Whether to disable OOM Killer
OomKillDisable bool `json:"oom_kill_disable"`

// Tuning swappiness behaviour per cgroup
MemorySwappiness *uint64 `json:"memory_swappiness"`

// Set priority of network traffic for container
NetPrioIfpriomap []*IfPrioMap `json:"net_prio_ifpriomap"`

// Set class identifier for container's network packets
NetClsClassid uint32 `json:"net_cls_classid_u"`

// Rdma resource restriction configuration
Rdma map[string]LinuxRdma `json:"rdma"`

// Used on cgroups v2:

// CpuWeight sets a proportional bandwidth limit.
CpuWeight uint64 `json:"cpu_weight"`

// Unified is cgroupv2-only key-value map.
Unified map[string]string `json:"unified"`

// SkipDevices allows to skip configuring device permissions.
// Used by e.g. kubelet while creating a parent cgroup (kubepods)
// common for many containers, and by runc update.
//
// NOTE it is impossible to start a container which has this flag set.
SkipDevices bool `json:"-"`

// SkipFreezeOnSet is a flag for cgroup manager to skip the cgroup
// freeze when setting resources. Only applicable to systemd legacy
// (i.e. cgroup v1) manager (which uses freeze by default to avoid
// spurious permission errors caused by systemd inability to update
// device rules in a non-disruptive manner).
//
// If not set, a few methods (such as looking into cgroup's
// devices.list and querying the systemd unit properties) are used
// during Set() to figure out whether the freeze is required. Those
// methods may be relatively slow, thus this flag.
SkipFreezeOnSet bool `json:"-"`

// MemoryCheckBeforeUpdate is a flag for cgroup v2 managers to check
// if the new memory limits (Memory and MemorySwap) being set are lower
// than the current memory usage, and reject if so.
MemoryCheckBeforeUpdate bool `json:"memory_check_before_update"`
}
9 changes: 9 additions & 0 deletions config_rdma.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cgroups

// LinuxRdma for Linux cgroup 'rdma' resource management (Linux 4.11)
type LinuxRdma struct {
// Maximum number of HCA handles that can be opened. Default is "no limit".
HcaHandles *uint32 `json:"hca_handles,omitempty"`
// Maximum number of HCA objects that can be created. Default is "no limit".
HcaObjects *uint32 `json:"hca_objects,omitempty"`
}
8 changes: 8 additions & 0 deletions config_unsupported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !linux

package cgroups

// Cgroup holds properties of a cgroup on Linux
// TODO Windows: This can ultimately be entirely factored out on Windows as
// cgroups are a Unix-specific construct.
type Cgroup struct{}
Loading