Merge pull request #82474 from cwdsuzhou/du_one_file_system

Add -x to du commands to not traverse other file systems
This commit is contained in:
Kubernetes Prow Robot
2019-09-11 18:29:45 -07:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -1130,7 +1130,7 @@ func FindEmptyDirectoryUsageOnTmpfs() (*resource.Quantity, error) {
return nil, err
}
defer os.RemoveAll(tmpDir)
out, err := exec.Command("nice", "-n", "19", "du", "-s", "-B", "1", tmpDir).CombinedOutput()
out, err := exec.Command("nice", "-n", "19", "du", "-x", "-s", "-B", "1", tmpDir).CombinedOutput()
if err != nil {
return nil, fmt.Errorf("failed command 'du' on %s with error %v", tmpDir, err)
}

View File

@@ -68,9 +68,9 @@ func DiskUsage(path string) (*resource.Quantity, error) {
}
// Uses the same niceness level as cadvisor.fs does when running du
// Uses -B 1 to always scale to a blocksize of 1 byte
out, err := exec.Command("nice", "-n", "19", "du", "-s", "-B", "1", path).CombinedOutput()
out, err := exec.Command("nice", "-n", "19", "du", "-x", "-s", "-B", "1", path).CombinedOutput()
if err != nil {
return nil, fmt.Errorf("failed command 'du' ($ nice -n 19 du -s -B 1) on path %s with error %v", path, err)
return nil, fmt.Errorf("failed command 'du' ($ nice -n 19 du -x -s -B 1) on path %s with error %v", path, err)
}
used, err := resource.ParseQuantity(strings.Fields(string(out))[0])
if err != nil {