Merge pull request #2400 from dims/update-vendor-dir-for-k8s.io/utils

Update vendor for k8s.io/utils
This commit is contained in:
David Ashpole 2020-02-24 13:45:26 -08:00 committed by GitHub
commit e1d7efe383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 8 deletions

View File

@ -61,8 +61,12 @@ type MountInfo struct {
ID int
// The ID of the parent mount (or of self for the root of this mount namespace's mount tree).
ParentID int
// The value of `st_dev` for files on this filesystem.
MajorMinor string
// Major indicates one half of the device ID which identifies the device class
// (parsed from `st_dev` for files on this filesystem).
Major int
// Minor indicates one half of the device ID which identifies a specific
// instance of device (parsed from `st_dev` for files on this filesystem).
Minor int
// The pathname of the directory in the filesystem which forms the root of this mount.
Root string
// Mount source, filesystem-specific information. e.g. device, tmpfs name.
@ -106,10 +110,24 @@ func ParseMountInfo(filename string) ([]MountInfo, error) {
if err != nil {
return nil, err
}
mm := strings.Split(fields[2], ":")
if len(mm) != 2 {
return nil, fmt.Errorf("parsing '%s' failed: unexpected minor:major pair %s", line, mm)
}
major, err := strconv.Atoi(mm[0])
if err != nil {
return nil, fmt.Errorf("parsing '%s' failed: unable to parse major device id, err:%v", mm[0], err)
}
minor, err := strconv.Atoi(mm[1])
if err != nil {
return nil, fmt.Errorf("parsing '%s' failed: unable to parse minor device id, err:%v", mm[1], err)
}
info := MountInfo{
ID: id,
ParentID: parentID,
MajorMinor: fields[2],
Major: major,
Minor: minor,
Root: fields[3],
MountPoint: fields[4],
MountOptions: strings.Split(fields[5], ","),

View File

@ -499,7 +499,8 @@ func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error) {
mountID := 0
rootPath := ""
majorMinor := ""
major := -1
minor := -1
// Finding the underlying root path and major:minor if possible.
// We need search in backward order because it's possible for later mounts
@ -509,12 +510,13 @@ func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error) {
// If it's a mount point or path under a mount point.
mountID = mis[i].ID
rootPath = filepath.Join(mis[i].Root, strings.TrimPrefix(hostSource, mis[i].MountPoint))
majorMinor = mis[i].MajorMinor
major = mis[i].Major
minor = mis[i].Minor
break
}
}
if rootPath == "" || majorMinor == "" {
if rootPath == "" || major == -1 || minor == -1 {
return nil, fmt.Errorf("failed to get root path and major:minor for %s", hostSource)
}
@ -524,7 +526,7 @@ func SearchMountPoints(hostSource, mountInfoPath string) ([]string, error) {
// Ignore mount entry for mount source itself.
continue
}
if mis[i].Root == rootPath && mis[i].MajorMinor == majorMinor {
if mis[i].Root == rootPath && mis[i].Major == major && mis[i].Minor == minor {
refs = append(refs, mis[i].MountPoint)
}
}

2
vendor/modules.txt vendored
View File

@ -311,7 +311,7 @@ gopkg.in/olivere/elastic.v2/uritemplates
gopkg.in/yaml.v2
# k8s.io/klog v0.3.0
k8s.io/klog
# k8s.io/utils v0.0.0-20200117235808-5f6fbceb4c31
# k8s.io/utils v0.0.0-20200122174043-1e243dd1a584
k8s.io/utils/clock
k8s.io/utils/clock/testing
k8s.io/utils/exec