Update go dependencies
This commit is contained in:
parent
293223eea0
commit
b7a799bf82
432 changed files with 37346 additions and 25783 deletions
50
vendor/k8s.io/kubernetes/pkg/util/mount/nsenter_mount.go
generated
vendored
50
vendor/k8s.io/kubernetes/pkg/util/mount/nsenter_mount.go
generated
vendored
|
|
@ -22,9 +22,12 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
utilio "k8s.io/kubernetes/pkg/util/io"
|
||||
"k8s.io/kubernetes/pkg/util/nsenter"
|
||||
)
|
||||
|
||||
|
|
@ -33,6 +36,13 @@ const (
|
|||
hostProcMountsPath = "/rootfs/proc/1/mounts"
|
||||
// hostProcMountinfoPath is the default mount info path for rootfs
|
||||
hostProcMountinfoPath = "/rootfs/proc/1/mountinfo"
|
||||
// hostProcSelfStatusPath is the default path to /proc/self/status on the host
|
||||
hostProcSelfStatusPath = "/rootfs/proc/self/status"
|
||||
)
|
||||
|
||||
var (
|
||||
// pidRegExp matches "Pid: <pid>" in /proc/self/status
|
||||
pidRegExp = regexp.MustCompile(`\nPid:\t([0-9]*)\n`)
|
||||
)
|
||||
|
||||
// Currently, all docker containers receive their own mount namespaces.
|
||||
|
|
@ -165,7 +175,7 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
|
|||
glog.V(5).Infof("nsenter findmnt args: %v", args)
|
||||
out, err := n.ne.Exec("findmnt", args).CombinedOutput()
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Failed findmnt command for path %s: %v", file, err)
|
||||
glog.V(2).Infof("Failed findmnt command for path %s: %s %v", file, out, err)
|
||||
// Different operating systems behave differently for paths which are not mount points.
|
||||
// On older versions (e.g. 2.20.1) we'd get error, on newer ones (e.g. 2.26.2) we'd get "/".
|
||||
// It's safer to assume that it's not a mount point.
|
||||
|
|
@ -270,3 +280,41 @@ func (mounter *NsenterMounter) ExistsPath(pathname string) bool {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (mounter *NsenterMounter) CleanSubPaths(podDir string, volumeName string) error {
|
||||
return doCleanSubPaths(mounter, podDir, volumeName)
|
||||
}
|
||||
|
||||
// getPidOnHost returns kubelet's pid in the host pid namespace
|
||||
func (mounter *NsenterMounter) getPidOnHost(procStatusPath string) (int, error) {
|
||||
// Get the PID from /rootfs/proc/self/status
|
||||
statusBytes, err := utilio.ConsistentRead(procStatusPath, maxListTries)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("error reading %s: %s", procStatusPath, err)
|
||||
}
|
||||
matches := pidRegExp.FindSubmatch(statusBytes)
|
||||
if len(matches) < 2 {
|
||||
return 0, fmt.Errorf("cannot parse %s: no Pid:", procStatusPath)
|
||||
}
|
||||
return strconv.Atoi(string(matches[1]))
|
||||
}
|
||||
|
||||
func (mounter *NsenterMounter) PrepareSafeSubpath(subPath Subpath) (newHostPath string, cleanupAction func(), err error) {
|
||||
hostPid, err := mounter.getPidOnHost(hostProcSelfStatusPath)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
glog.V(4).Infof("Kubelet's PID on the host is %d", hostPid)
|
||||
|
||||
// Bind-mount the subpath to avoid using symlinks in subpaths.
|
||||
newHostPath, err = doBindSubPath(mounter, subPath, hostPid)
|
||||
|
||||
// There is no action when the container starts. Bind-mount will be cleaned
|
||||
// when container stops by CleanSubPaths.
|
||||
cleanupAction = nil
|
||||
return newHostPath, cleanupAction, err
|
||||
}
|
||||
|
||||
func (mounter *NsenterMounter) SafeMakeDir(pathname string, base string, perm os.FileMode) error {
|
||||
return doSafeMakeDir(pathname, base, perm)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue