diff --git a/container/common/helpers.go b/container/common/helpers.go index 33d9db37..f5539b5d 100644 --- a/container/common/helpers.go +++ b/container/common/helpers.go @@ -127,15 +127,13 @@ func GetSpec(cgroupPaths map[string]string, machineInfoFactory info.MachineInfoF func readString(dirpath string, file string) string { cgroupFile := path.Join(dirpath, file) - // Ignore non-existent files - if !utils.FileExists(cgroupFile) { - return "" - } - // Read out, err := ioutil.ReadFile(cgroupFile) if err != nil { - glog.Errorf("readString: Failed to read %q: %s", cgroupFile, err) + // Ignore non-existent files + if !os.IsNotExist(err) { + glog.Errorf("readString: Failed to read %q: %s", cgroupFile, err) + } return "" } return strings.TrimSpace(string(out)) @@ -158,13 +156,12 @@ func readUInt64(dirpath string, file string) uint64 { // Lists all directories under "path" and outputs the results as children of "parent". func ListDirectories(dirpath string, parent string, recursive bool, output map[string]struct{}) error { - // Ignore if this hierarchy does not exist. - if !utils.FileExists(dirpath) { - return nil - } - entries, err := ioutil.ReadDir(dirpath) if err != nil { + // Ignore if this hierarchy does not exist. + if os.IsNotExist(err) { + err = nil + } return err } for _, entry := range entries {