mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-10 18:15:36 +00:00
For one thing, this release decouples device management from libcontainer/cgroups. You can see the result of this in a dropped cilium/ebpf dependency (which is only needed for device management). NOTE that due to an issue with go mod / go list, github.com/opencontainers/runc had to be added to hack/unwanted-dependencies.json under x/exp. This is bogus because opencontainers/runc does not use x/exp directly, only via cilium/ebpf dependency (which is not vendored here). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
53 lines
936 B
Go
53 lines
936 B
Go
package fs2
|
|
|
|
import (
|
|
"bufio"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
|
)
|
|
|
|
func statMisc(dirPath string, stats *cgroups.Stats) error {
|
|
for _, file := range []string{"current", "events"} {
|
|
fd, err := cgroups.OpenFile(dirPath, "misc."+file, os.O_RDONLY)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
s := bufio.NewScanner(fd)
|
|
for s.Scan() {
|
|
key, value, err := fscommon.ParseKeyValue(s.Text())
|
|
if err != nil {
|
|
fd.Close()
|
|
return err
|
|
}
|
|
|
|
key = strings.TrimSuffix(key, ".max")
|
|
|
|
if _, ok := stats.MiscStats[key]; !ok {
|
|
stats.MiscStats[key] = cgroups.MiscStats{}
|
|
}
|
|
|
|
tmp := stats.MiscStats[key]
|
|
|
|
switch file {
|
|
case "current":
|
|
tmp.Usage = value
|
|
case "events":
|
|
tmp.Events = value
|
|
}
|
|
|
|
stats.MiscStats[key] = tmp
|
|
}
|
|
fd.Close()
|
|
|
|
if err := s.Err(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|