Don't get stats for cgroups that don't exist.
Signed-off-by: Victor Marmol <vmarmol@google.com>
This commit is contained in:
parent
be02944484
commit
e3184f97e0
|
@ -105,7 +105,7 @@ func GetStats(systemPaths map[string]string) (*cgroups.Stats, error) {
|
|||
stats := cgroups.NewStats()
|
||||
for name, path := range systemPaths {
|
||||
sys, ok := subsystems[name]
|
||||
if !ok {
|
||||
if !ok || !cgroups.PathExists(path) {
|
||||
continue
|
||||
}
|
||||
if err := sys.GetStats(path, stats); err != nil {
|
||||
|
|
|
@ -174,7 +174,7 @@ func ParseCgroupFile(subsystem string, r io.Reader) (string, error) {
|
|||
return "", NewNotFoundError(subsystem)
|
||||
}
|
||||
|
||||
func pathExists(path string) bool {
|
||||
func PathExists(path string) bool {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return false
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ func pathExists(path string) bool {
|
|||
|
||||
func EnterPid(cgroupPaths map[string]string, pid int) error {
|
||||
for _, path := range cgroupPaths {
|
||||
if pathExists(path) {
|
||||
if PathExists(path) {
|
||||
if err := ioutil.WriteFile(filepath.Join(path, "cgroup.procs"),
|
||||
[]byte(strconv.Itoa(pid)), 0700); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue