build(deps): bump github.com/opencontainers/cgroups from 0.0.3 to 0.0.4

Bumps [github.com/opencontainers/cgroups](https://github.com/opencontainers/cgroups) from 0.0.3 to 0.0.4.
- [Release notes](https://github.com/opencontainers/cgroups/releases)
- [Changelog](https://github.com/opencontainers/cgroups/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/cgroups/compare/v0.0.3...v0.0.4)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/cgroups
  dependency-version: 0.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-07-15 06:35:26 +00:00
committed by GitHub
parent 2a6e143c5f
commit fc8162e60e
5 changed files with 31 additions and 14 deletions

2
go.mod
View File

@@ -14,7 +14,7 @@ require (
github.com/moby/sys/user v0.4.0 github.com/moby/sys/user v0.4.0
github.com/moby/sys/userns v0.1.0 github.com/moby/sys/userns v0.1.0
github.com/mrunalp/fileutils v0.5.1 github.com/mrunalp/fileutils v0.5.1
github.com/opencontainers/cgroups v0.0.3 github.com/opencontainers/cgroups v0.0.4
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67 github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67
github.com/opencontainers/selinux v1.12.0 github.com/opencontainers/selinux v1.12.0
github.com/seccomp/libseccomp-golang v0.11.0 github.com/seccomp/libseccomp-golang v0.11.0

4
go.sum
View File

@@ -45,8 +45,8 @@ github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q= github.com/mrunalp/fileutils v0.5.1 h1:F+S7ZlNKnrwHfSwdlgNSkKo67ReVf8o9fel6C3dkm/Q=
github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mrunalp/fileutils v0.5.1/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
github.com/opencontainers/cgroups v0.0.3 h1:Jc9dWh/0YLGjdy6J/9Ln8NM5BfTA4W2BY0GMozy3aDU= github.com/opencontainers/cgroups v0.0.4 h1:XVj8P/IHVms/j+7eh8ggdkTLAxjz84ZzuFyGoE28DR4=
github.com/opencontainers/cgroups v0.0.3/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs= github.com/opencontainers/cgroups v0.0.4/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67 h1:Q+KewUGTMamIe6Q39xCD/T1NC1POmaTlWnhjikCrZHA= github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67 h1:Q+KewUGTMamIe6Q39xCD/T1NC1POmaTlWnhjikCrZHA=
github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opencontainers/runtime-spec v1.2.2-0.20250401095657-e935f995dd67/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.12.0 h1:6n5JV4Cf+4y0KNXW48TLj5DwfXpvWlxXplUkdTrmPb8= github.com/opencontainers/selinux v1.12.0 h1:6n5JV4Cf+4y0KNXW48TLj5DwfXpvWlxXplUkdTrmPb8=

View File

@@ -53,12 +53,9 @@ func setFreezer(dirPath string, state cgroups.FreezerState) error {
func getFreezer(dirPath string) (cgroups.FreezerState, error) { func getFreezer(dirPath string) (cgroups.FreezerState, error) {
fd, err := cgroups.OpenFile(dirPath, "cgroup.freeze", unix.O_RDONLY) fd, err := cgroups.OpenFile(dirPath, "cgroup.freeze", unix.O_RDONLY)
if err != nil { if err != nil {
// If the kernel is too old, then we just treat the freezer as being in // If the kernel is too old, then we just treat the freezer as
// an "undefined" state. // being in an "undefined" state and ignore the error.
if os.IsNotExist(err) || errors.Is(err, unix.ENODEV) { return cgroups.Undefined, ignoreNotExistOrNoDeviceError(err)
err = nil
}
return cgroups.Undefined, err
} }
defer fd.Close() defer fd.Close()
@@ -67,11 +64,15 @@ func getFreezer(dirPath string) (cgroups.FreezerState, error) {
func readFreezer(dirPath string, fd *os.File) (cgroups.FreezerState, error) { func readFreezer(dirPath string, fd *os.File) (cgroups.FreezerState, error) {
if _, err := fd.Seek(0, 0); err != nil { if _, err := fd.Seek(0, 0); err != nil {
return cgroups.Undefined, err // If the cgroup path is deleted at this point, then we just treat the freezer as
// being in an "undefined" state and ignore the error.
return cgroups.Undefined, ignoreNotExistOrNoDeviceError(err)
} }
state := make([]byte, 2) state := make([]byte, 2)
if _, err := fd.Read(state); err != nil { if _, err := fd.Read(state); err != nil {
return cgroups.Undefined, err // If the cgroup path is deleted at this point, then we just treat the freezer as
// being in an "undefined" state and ignore the error.
return cgroups.Undefined, ignoreNotExistOrNoDeviceError(err)
} }
switch string(state) { switch string(state) {
case "0\n": case "0\n":
@@ -83,6 +84,21 @@ func readFreezer(dirPath string, fd *os.File) (cgroups.FreezerState, error) {
} }
} }
// ignoreNotExistOrNoDeviceError checks if the error is either a "not exist" error
// or a "no device" error, and returns nil in those cases. Otherwise, it returns the error.
func ignoreNotExistOrNoDeviceError(err error) error {
// We can safely ignore the error in the following two common situations:
// 1. The cgroup path does not exist at the time of opening(eg: the kernel is too old)
// — indicated by os.IsNotExist.
// 2. The cgroup path is deleted during the seek/read operation — indicated by
// errors.Is(err, unix.ENODEV).
// These conditions are expected and do not require special handling.
if os.IsNotExist(err) || errors.Is(err, unix.ENODEV) {
return nil
}
return err
}
// waitFrozen polls cgroup.events until it sees "frozen 1" in it. // waitFrozen polls cgroup.events until it sees "frozen 1" in it.
func waitFrozen(dirPath string) (cgroups.FreezerState, error) { func waitFrozen(dirPath string) (cgroups.FreezerState, error) {
fd, err := cgroups.OpenFile(dirPath, "cgroup.events", unix.O_RDONLY) fd, err := cgroups.OpenFile(dirPath, "cgroup.events", unix.O_RDONLY)

View File

@@ -43,10 +43,11 @@ func setHugeTlb(dirPath string, r *cgroups.Resources) error {
func statHugeTlb(dirPath string, stats *cgroups.Stats) error { func statHugeTlb(dirPath string, stats *cgroups.Stats) error {
hugetlbStats := cgroups.HugetlbStats{} hugetlbStats := cgroups.HugetlbStats{}
rsvd := ".rsvd" rsvd := ".rsvd"
for _, pagesize := range cgroups.HugePageSizes() { for _, pagesize := range cgroups.HugePageSizes() {
prefix := "hugetlb." + pagesize
again: again:
prefix := "hugetlb." + pagesize + rsvd value, err := fscommon.GetCgroupParamUint(dirPath, prefix+rsvd+".current")
value, err := fscommon.GetCgroupParamUint(dirPath, prefix+".current")
if err != nil { if err != nil {
if rsvd != "" && errors.Is(err, os.ErrNotExist) { if rsvd != "" && errors.Is(err, os.ErrNotExist) {
rsvd = "" rsvd = ""

2
vendor/modules.txt vendored
View File

@@ -51,7 +51,7 @@ github.com/moby/sys/userns
# github.com/mrunalp/fileutils v0.5.1 # github.com/mrunalp/fileutils v0.5.1
## explicit; go 1.13 ## explicit; go 1.13
github.com/mrunalp/fileutils github.com/mrunalp/fileutils
# github.com/opencontainers/cgroups v0.0.3 # github.com/opencontainers/cgroups v0.0.4
## explicit; go 1.23.0 ## explicit; go 1.23.0
github.com/opencontainers/cgroups github.com/opencontainers/cgroups
github.com/opencontainers/cgroups/devices github.com/opencontainers/cgroups/devices