Merge pull request #640 from cyphar/add-cgroup-pids-stats-limit
libcontainer: cgroups: add pids.max to PidsStats
This commit is contained in:
commit
5a91c338f5
|
@ -47,11 +47,17 @@ func (s *PidsGroup) Remove(d *cgroupData) error {
|
|||
}
|
||||
|
||||
func (s *PidsGroup) GetStats(path string, stats *cgroups.Stats) error {
|
||||
value, err := getCgroupParamUint(path, "pids.current")
|
||||
current, err := getCgroupParamUint(path, "pids.current")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse pids.current - %s", err)
|
||||
}
|
||||
|
||||
stats.PidsStats.Current = value
|
||||
max, err := getCgroupParamUint(path, "pids.max")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse pids.max - %s", err)
|
||||
}
|
||||
|
||||
stats.PidsStats.Current = current
|
||||
stats.PidsStats.Max = max
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -80,4 +80,8 @@ func TestPidsStats(t *testing.T) {
|
|||
if stats.PidsStats.Current != 1337 {
|
||||
t.Fatalf("Expected %d, got %d for pids.current", 1337, stats.PidsStats.Current)
|
||||
}
|
||||
|
||||
if stats.PidsStats.Max != maxLimited {
|
||||
t.Fatalf("Expected %d, got %d for pids.max", maxLimited, stats.PidsStats.Max)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ type MemoryStats struct {
|
|||
type PidsStats struct {
|
||||
// number of pids in the cgroup
|
||||
Current uint64 `json:"current,omitempty"`
|
||||
// active pids hard limit
|
||||
Max uint64 `json:"max,omitempty"`
|
||||
}
|
||||
|
||||
type BlkioStatEntry struct {
|
||||
|
|
Loading…
Reference in New Issue