From 6a94d50fb37f57bd5c76191813fe4a88f62a7baa Mon Sep 17 00:00:00 2001 From: Eytan Heidingsfeld <32422402+ehmm@users.noreply.github.com> Date: Mon, 19 Nov 2018 10:14:49 +0000 Subject: [PATCH] Add -s to du commands to not traverse other file systems --- pkg/volume/testing/testing.go | 2 +- pkg/volume/util/fs/fs.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/volume/testing/testing.go b/pkg/volume/testing/testing.go index a61a0c6f8d9..c6d32372264 100644 --- a/pkg/volume/testing/testing.go +++ b/pkg/volume/testing/testing.go @@ -1131,7 +1131,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) } diff --git a/pkg/volume/util/fs/fs.go b/pkg/volume/util/fs/fs.go index 21fb3a21e15..2796e93d19e 100644 --- a/pkg/volume/util/fs/fs.go +++ b/pkg/volume/util/fs/fs.go @@ -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 {