diff --git a/go.mod b/go.mod index 47036bfd7..15e97fddc 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/uptrace/bun/dialect/sqlitedialect v1.1.12 github.com/wagslane/go-password-validator v0.3.0 github.com/yuin/goldmark v1.5.4 - go.uber.org/automaxprocs v1.5.1 + go.uber.org/automaxprocs v1.5.2 golang.org/x/crypto v0.7.0 golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d golang.org/x/image v0.6.0 diff --git a/go.sum b/go.sum index 6d7ce49a3..9e9d7cf3e 100644 --- a/go.sum +++ b/go.sum @@ -643,8 +643,8 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/automaxprocs v1.5.1 h1:e1YG66Lrk73dn4qhg8WFSvhF0JuFQF0ERIp4rpuV8Qk= -go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= +go.uber.org/automaxprocs v1.5.2 h1:2LxUOGiR3O6tw8ui5sZa2LAaHnsviZdVOUZw4fvbnME= +go.uber.org/automaxprocs v1.5.2/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= diff --git a/vendor/go.uber.org/automaxprocs/internal/cgroups/cgroups2.go b/vendor/go.uber.org/automaxprocs/internal/cgroups/cgroups2.go index 66930d0ac..3ac10c8b6 100644 --- a/vendor/go.uber.org/automaxprocs/internal/cgroups/cgroups2.go +++ b/vendor/go.uber.org/automaxprocs/internal/cgroups/cgroups2.go @@ -59,6 +59,7 @@ // CGroups2 provides access to cgroups data for systems using cgroups2. type CGroups2 struct { mountPoint string + groupPath string cpuMaxFile string } @@ -66,10 +67,10 @@ type CGroups2 struct { // // This returns ErrNotV2 if the system is not using cgroups2. func NewCGroups2ForCurrentProcess() (*CGroups2, error) { - return newCGroups2FromMountInfo(_procPathMountInfo) + return newCGroups2From(_procPathMountInfo, _procPathCGroup) } -func newCGroups2FromMountInfo(mountInfoPath string) (*CGroups2, error) { +func newCGroups2From(mountInfoPath, procPathCGroup string) (*CGroups2, error) { isV2, err := isCGroupV2(mountInfoPath) if err != nil { return nil, err @@ -79,8 +80,27 @@ func newCGroups2FromMountInfo(mountInfoPath string) (*CGroups2, error) { return nil, ErrNotV2 } + subsystems, err := parseCGroupSubsystems(procPathCGroup) + if err != nil { + return nil, err + } + + // Find v2 subsystem by looking for the `0` id + var v2subsys *CGroupSubsys + for _, subsys := range subsystems { + if subsys.ID == 0 { + v2subsys = subsys + break + } + } + + if v2subsys == nil { + return nil, ErrNotV2 + } + return &CGroups2{ mountPoint: _cgroupv2MountPoint, + groupPath: v2subsys.Name, cpuMaxFile: _cgroupv2CPUMax, }, nil } @@ -106,13 +126,14 @@ func isCGroupV2(procPathMountInfo string) (bool, error) { // It will return `cpu.max / cpu.period`. If cpu.max is set to max, it returns // (-1, false, nil) func (cg *CGroups2) CPUQuota() (float64, bool, error) { - cpuMaxParams, err := os.Open(path.Join(cg.mountPoint, cg.cpuMaxFile)) + cpuMaxParams, err := os.Open(path.Join(cg.mountPoint, cg.groupPath, cg.cpuMaxFile)) if err != nil { if os.IsNotExist(err) { return -1, false, nil } return -1, false, err } + defer cpuMaxParams.Close() scanner := bufio.NewScanner(cpuMaxParams) if scanner.Scan() { diff --git a/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go b/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go index 3a7515649..df6eacf05 100644 --- a/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go +++ b/vendor/go.uber.org/automaxprocs/internal/runtime/runtime.go @@ -28,6 +28,6 @@ CPUQuotaUndefined CPUQuotaStatus = iota // CPUQuotaUsed is returned when a valid CPU quota can be used CPUQuotaUsed - // CPUQuotaMinUsed is return when CPU quota is smaller than the min value + // CPUQuotaMinUsed is returned when CPU quota is smaller than the min value CPUQuotaMinUsed ) diff --git a/vendor/go.uber.org/automaxprocs/maxprocs/version.go b/vendor/go.uber.org/automaxprocs/maxprocs/version.go index 15b156c99..108a95535 100644 --- a/vendor/go.uber.org/automaxprocs/maxprocs/version.go +++ b/vendor/go.uber.org/automaxprocs/maxprocs/version.go @@ -21,4 +21,4 @@ package maxprocs // Version is the current package version. -const Version = "1.5.1" +const Version = "1.5.2" diff --git a/vendor/modules.txt b/vendor/modules.txt index 082d50046..5e29961a5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -730,7 +730,7 @@ github.com/yuin/goldmark/renderer github.com/yuin/goldmark/renderer/html github.com/yuin/goldmark/text github.com/yuin/goldmark/util -# go.uber.org/automaxprocs v1.5.1 +# go.uber.org/automaxprocs v1.5.2 ## explicit; go 1.18 go.uber.org/automaxprocs/internal/cgroups go.uber.org/automaxprocs/internal/runtime