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