mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
update github.com/opencontainers/cgroups to v0.0.6
Includes one small fix for a breaking change in a type. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
4
vendor/github.com/opencontainers/cgroups/config_linux.go
generated
vendored
4
vendor/github.com/opencontainers/cgroups/config_linux.go
generated
vendored
@@ -90,8 +90,8 @@ type Resources struct {
|
||||
// Cgroup's SCHED_IDLE value.
|
||||
CPUIdle *int64 `json:"cpu_idle,omitempty"`
|
||||
|
||||
// Process limit; set <= `0' to disable limit.
|
||||
PidsLimit int64 `json:"pids_limit,omitempty"`
|
||||
// Process limit; set < `0' to disable limit. `nil` means "keep current limit".
|
||||
PidsLimit *int64 `json:"pids_limit,omitempty"`
|
||||
|
||||
// Specifies per cgroup weight, range is from 10 to 1000.
|
||||
BlkioWeight uint16 `json:"blkio_weight,omitempty"`
|
||||
|
||||
12
vendor/github.com/opencontainers/cgroups/fs/cpuacct.go
generated
vendored
12
vendor/github.com/opencontainers/cgroups/fs/cpuacct.go
generated
vendored
@@ -129,12 +129,16 @@ func getPercpuUsageInModes(path string) ([]uint64, []uint64, error) {
|
||||
defer fd.Close()
|
||||
|
||||
scanner := bufio.NewScanner(fd)
|
||||
scanner.Scan() // skipping header line
|
||||
scanner.Scan() // Read header line.
|
||||
const want = "cpu user system"
|
||||
if hdr := scanner.Text(); !strings.HasPrefix(hdr, want) {
|
||||
return nil, nil, malformedLine(path, file, hdr)
|
||||
}
|
||||
|
||||
for scanner.Scan() {
|
||||
// Each line is: cpu user system
|
||||
fields := strings.SplitN(scanner.Text(), " ", 3)
|
||||
if len(fields) != 3 {
|
||||
// Each line is: cpu user system. Keep N at 4 to ignore extra fields.
|
||||
fields := strings.SplitN(scanner.Text(), " ", 4)
|
||||
if len(fields) < 3 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
27
vendor/github.com/opencontainers/cgroups/fs/pids.go
generated
vendored
27
vendor/github.com/opencontainers/cgroups/fs/pids.go
generated
vendored
@@ -19,19 +19,24 @@ func (s *PidsGroup) Apply(path string, _ *cgroups.Resources, pid int) error {
|
||||
}
|
||||
|
||||
func (s *PidsGroup) Set(path string, r *cgroups.Resources) error {
|
||||
if r.PidsLimit != 0 {
|
||||
// "max" is the fallback value.
|
||||
limit := "max"
|
||||
|
||||
if r.PidsLimit > 0 {
|
||||
limit = strconv.FormatInt(r.PidsLimit, 10)
|
||||
}
|
||||
|
||||
if err := cgroups.WriteFile(path, "pids.max", limit); err != nil {
|
||||
return err
|
||||
}
|
||||
if r.PidsLimit == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// "max" is the fallback value.
|
||||
val := "max"
|
||||
if limit := *r.PidsLimit; limit > 0 {
|
||||
val = strconv.FormatInt(limit, 10)
|
||||
} else if limit == 0 {
|
||||
// systemd doesn't support setting pids.max to "0", so when setting
|
||||
// TasksMax we need to remap it to "1". We do the same thing here to
|
||||
// avoid flip-flop behaviour between the fs and systemd drivers. In
|
||||
// practice, the pids cgroup behaviour is basically identical.
|
||||
val = "1"
|
||||
}
|
||||
if err := cgroups.WriteFile(path, "pids.max", val); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
19
vendor/github.com/opencontainers/cgroups/fs2/io.go
generated
vendored
19
vendor/github.com/opencontainers/cgroups/fs2/io.go
generated
vendored
@@ -165,11 +165,22 @@ func statIo(dirPath string, stats *cgroups.Stats) error {
|
||||
case "wios":
|
||||
op = "Write"
|
||||
targetTable = &parsedStats.IoServicedRecursive
|
||||
|
||||
case "cost.usage":
|
||||
op = "Count"
|
||||
targetTable = &parsedStats.IoCostUsage
|
||||
case "cost.wait":
|
||||
op = "Count"
|
||||
targetTable = &parsedStats.IoCostWait
|
||||
case "cost.indebt":
|
||||
op = "Count"
|
||||
targetTable = &parsedStats.IoCostIndebt
|
||||
case "cost.indelay":
|
||||
op = "Count"
|
||||
targetTable = &parsedStats.IoCostIndelay
|
||||
|
||||
default:
|
||||
// Skip over entries we cannot map to cgroupv1 stats for now.
|
||||
// In the future we should expand the stats struct to include
|
||||
// them.
|
||||
logrus.Debugf("cgroupv2 io stats: skipping over unmappable %s entry", item)
|
||||
logrus.Debugf("cgroupv2 io stats: unknown entry %s", item)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
20
vendor/github.com/opencontainers/cgroups/fs2/pids.go
generated
vendored
20
vendor/github.com/opencontainers/cgroups/fs2/pids.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
@@ -13,19 +14,26 @@ import (
|
||||
)
|
||||
|
||||
func isPidsSet(r *cgroups.Resources) bool {
|
||||
return r.PidsLimit != 0
|
||||
return r.PidsLimit != nil
|
||||
}
|
||||
|
||||
func setPids(dirPath string, r *cgroups.Resources) error {
|
||||
if !isPidsSet(r) {
|
||||
return nil
|
||||
}
|
||||
if val := numToStr(r.PidsLimit); val != "" {
|
||||
if err := cgroups.WriteFile(dirPath, "pids.max", val); err != nil {
|
||||
return err
|
||||
}
|
||||
val := "max"
|
||||
if limit := *r.PidsLimit; limit > 0 {
|
||||
val = strconv.FormatInt(limit, 10)
|
||||
} else if limit == 0 {
|
||||
// systemd doesn't support setting pids.max to "0", so when setting
|
||||
// TasksMax we need to remap it to "1". We do the same thing here to
|
||||
// avoid flip-flop behaviour between the fs and systemd drivers. In
|
||||
// practice, the pids cgroup behaviour is basically identical.
|
||||
val = "1"
|
||||
}
|
||||
if err := cgroups.WriteFile(dirPath, "pids.max", val); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
4
vendor/github.com/opencontainers/cgroups/stats.go
generated
vendored
4
vendor/github.com/opencontainers/cgroups/stats.go
generated
vendored
@@ -159,6 +159,10 @@ type BlkioStats struct {
|
||||
IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive,omitempty"`
|
||||
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive,omitempty"`
|
||||
PSI *PSIStats `json:"psi,omitempty"`
|
||||
IoCostUsage []BlkioStatEntry `json:"io_cost_usage,omitempty"`
|
||||
IoCostWait []BlkioStatEntry `json:"io_cost_wait,omitempty"`
|
||||
IoCostIndebt []BlkioStatEntry `json:"io_cost_indebt,omitempty"`
|
||||
IoCostIndelay []BlkioStatEntry `json:"io_cost_indelay,omitempty"`
|
||||
}
|
||||
|
||||
type HugetlbStats struct {
|
||||
|
||||
Reference in New Issue
Block a user