mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
Update to kube v1.17
Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
committed by
mergify[bot]
parent
327fcd1b1b
commit
3af1e26d7c
10
vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go
generated
vendored
10
vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs.go
generated
vendored
@ -27,7 +27,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/volume/util/quota"
|
||||
"k8s.io/kubernetes/pkg/volume/util/fsquota"
|
||||
)
|
||||
|
||||
// FSInfo linux returns (available bytes, byte capacity, byte usage, total inodes, inodes free, inode usage, error)
|
||||
@ -60,7 +60,7 @@ func DiskUsage(path string) (*resource.Quantity, error) {
|
||||
// First check whether the quota system knows about this directory
|
||||
// A nil quantity with no error means that the path does not support quotas
|
||||
// and we should use other mechanisms.
|
||||
data, err := quota.GetConsumption(path)
|
||||
data, err := fsquota.GetConsumption(path)
|
||||
if data != nil {
|
||||
return data, nil
|
||||
} else if err != nil {
|
||||
@ -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 {
|
||||
@ -89,7 +89,7 @@ func Find(path string) (int64, error) {
|
||||
// First check whether the quota system knows about this directory
|
||||
// A nil quantity with no error means that the path does not support quotas
|
||||
// and we should use other mechanisms.
|
||||
inodes, err := quota.GetInodes(path)
|
||||
inodes, err := fsquota.GetInodes(path)
|
||||
if inodes != nil {
|
||||
return inodes.Value(), nil
|
||||
} else if err != nil {
|
||||
|
46
vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_windows.go
generated
vendored
46
vendor/k8s.io/kubernetes/pkg/volume/util/fs/fs_windows.go
generated
vendored
@ -20,6 +20,7 @@ package fs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
@ -58,7 +59,12 @@ func FsInfo(path string) (int64, int64, int64, int64, int64, int64, error) {
|
||||
|
||||
// DiskUsage gets disk usage of specified path.
|
||||
func DiskUsage(path string) (*resource.Quantity, error) {
|
||||
_, _, usage, _, _, _, err := FsInfo(path)
|
||||
info, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
usage, err := diskUsage(path, info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -75,3 +81,41 @@ func DiskUsage(path string) (*resource.Quantity, error) {
|
||||
func Find(path string) (int64, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func diskUsage(currPath string, info os.FileInfo) (int64, error) {
|
||||
var size int64
|
||||
|
||||
if info.Mode()&os.ModeSymlink != 0 {
|
||||
return size, nil
|
||||
}
|
||||
|
||||
size += info.Size()
|
||||
|
||||
if !info.IsDir() {
|
||||
return size, nil
|
||||
}
|
||||
|
||||
dir, err := os.Open(currPath)
|
||||
if err != nil {
|
||||
return size, err
|
||||
}
|
||||
defer dir.Close()
|
||||
|
||||
files, err := dir.Readdir(-1)
|
||||
if err != nil {
|
||||
return size, err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
s, err := diskUsage(fmt.Sprintf("%s/%s", currPath, file.Name()), file)
|
||||
if err != nil {
|
||||
return size, err
|
||||
}
|
||||
size += s
|
||||
} else {
|
||||
size += file.Size()
|
||||
}
|
||||
}
|
||||
return size, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user