mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-05 03:01:11 +00:00
This caused a dependency chain reaction (sigh):
* All the k8s packages had to be fetched again. This in turn required:
* Pining github.com/docker/docker/pkg/parsers to
0f5c9d301b9b1cca66b3ea0f9dec3b5317d3686d to cirvumvent
https://github.com/kubernetes/kubernetes/issues/18774
* Update github.com/juju/ratelimit
* Make probe/kubernetes/client.go comply with API changes.
58 lines
1.1 KiB
Go
58 lines
1.1 KiB
Go
// +build linux
|
|
|
|
package fs
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
|
"github.com/opencontainers/runc/libcontainer/configs"
|
|
)
|
|
|
|
type PidsGroup struct {
|
|
}
|
|
|
|
func (s *PidsGroup) Name() string {
|
|
return "pids"
|
|
}
|
|
|
|
func (s *PidsGroup) Apply(d *cgroupData) error {
|
|
_, err := d.join("pids")
|
|
if err != nil && !cgroups.IsNotFound(err) {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *PidsGroup) Set(path string, cgroup *configs.Cgroup) error {
|
|
if cgroup.Resources.PidsLimit != 0 {
|
|
// "max" is the fallback value.
|
|
limit := "max"
|
|
|
|
if cgroup.Resources.PidsLimit > 0 {
|
|
limit = strconv.FormatInt(cgroup.Resources.PidsLimit, 10)
|
|
}
|
|
|
|
if err := writeFile(path, "pids.max", limit); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *PidsGroup) Remove(d *cgroupData) error {
|
|
return removePath(d.path("pids"))
|
|
}
|
|
|
|
func (s *PidsGroup) GetStats(path string, stats *cgroups.Stats) error {
|
|
value, err := getCgroupParamUint(path, "pids.current")
|
|
if err != nil {
|
|
return fmt.Errorf("failed to parse pids.current - %s", err)
|
|
}
|
|
|
|
stats.PidsStats.Current = value
|
|
return nil
|
|
}
|