Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
686b37ff
Unverified
Commit
686b37ff
authored
Oct 09, 2018
by
k8s-ci-robot
Committed by
GitHub
Oct 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69565 from jsafrane/fix-contianerized-subpath
Fixed subpath in containerized kubelet.
parents
4966faab
0b8c4725
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
mount.go
pkg/util/mount/mount.go
+8
-6
nsenter_mount.go
pkg/util/mount/nsenter_mount.go
+13
-6
No files found.
pkg/util/mount/mount.go
View file @
686b37ff
...
@@ -251,14 +251,9 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
...
@@ -251,14 +251,9 @@ func GetDeviceNameFromMount(mounter Interface, mountPath string) (string, int, e
// It is more extensive than IsLikelyNotMountPoint
// It is more extensive than IsLikelyNotMountPoint
// and it detects bind mounts in linux
// and it detects bind mounts in linux
func
IsNotMountPoint
(
mounter
Interface
,
file
string
)
(
bool
,
error
)
{
func
IsNotMountPoint
(
mounter
Interface
,
file
string
)
(
bool
,
error
)
{
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts
resolvedFile
,
err
:=
mounter
.
EvalHostSymlinks
(
file
)
if
err
!=
nil
{
return
true
,
err
}
// IsLikelyNotMountPoint provides a quick check
// IsLikelyNotMountPoint provides a quick check
// to determine whether file IS A mountpoint
// to determine whether file IS A mountpoint
notMnt
,
notMntErr
:=
mounter
.
IsLikelyNotMountPoint
(
resolvedF
ile
)
notMnt
,
notMntErr
:=
mounter
.
IsLikelyNotMountPoint
(
f
ile
)
if
notMntErr
!=
nil
&&
os
.
IsPermission
(
notMntErr
)
{
if
notMntErr
!=
nil
&&
os
.
IsPermission
(
notMntErr
)
{
// We were not allowed to do the simple stat() check, e.g. on NFS with
// We were not allowed to do the simple stat() check, e.g. on NFS with
// root_squash. Fall back to /proc/mounts check below.
// root_squash. Fall back to /proc/mounts check below.
...
@@ -272,6 +267,13 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
...
@@ -272,6 +267,13 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
if
notMnt
==
false
{
if
notMnt
==
false
{
return
notMnt
,
nil
return
notMnt
,
nil
}
}
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts
resolvedFile
,
err
:=
mounter
.
EvalHostSymlinks
(
file
)
if
err
!=
nil
{
return
true
,
err
}
// check all mountpoints since IsLikelyNotMountPoint
// check all mountpoints since IsLikelyNotMountPoint
// is not reliable for some mountpoint types
// is not reliable for some mountpoint types
mountPoints
,
mountPointsErr
:=
mounter
.
List
()
mountPoints
,
mountPointsErr
:=
mounter
.
List
()
...
...
pkg/util/mount/nsenter_mount.go
View file @
686b37ff
...
@@ -166,15 +166,22 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
...
@@ -166,15 +166,22 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
glog
.
V
(
5
)
.
Infof
(
"findmnt: directory %s does not exist"
,
file
)
glog
.
V
(
5
)
.
Infof
(
"findmnt: directory %s does not exist"
,
file
)
return
true
,
err
return
true
,
err
}
}
// Resolve any symlinks in file, kernel would do the same and use the resolved path in /proc/mounts
resolvedFile
,
err
:=
n
.
EvalHostSymlinks
(
file
)
if
err
!=
nil
{
return
true
,
err
}
// Add --first-only option: since we are testing for the absence of a mountpoint, it is sufficient to get only
// Add --first-only option: since we are testing for the absence of a mountpoint, it is sufficient to get only
// the first of multiple possible mountpoints using --first-only.
// the first of multiple possible mountpoints using --first-only.
// Also add fstype output to make sure that the output of target file will give the full path
// Also add fstype output to make sure that the output of target file will give the full path
// TODO: Need more refactoring for this function. Track the solution with issue #26996
// TODO: Need more refactoring for this function. Track the solution with issue #26996
args
:=
[]
string
{
"-o"
,
"target,fstype"
,
"--noheadings"
,
"--first-only"
,
"--target"
,
f
ile
}
args
:=
[]
string
{
"-o"
,
"target,fstype"
,
"--noheadings"
,
"--first-only"
,
"--target"
,
resolvedF
ile
}
glog
.
V
(
5
)
.
Infof
(
"nsenter findmnt args: %v"
,
args
)
glog
.
V
(
5
)
.
Infof
(
"nsenter findmnt args: %v"
,
args
)
out
,
err
:=
n
.
ne
.
Exec
(
"findmnt"
,
args
)
.
CombinedOutput
()
out
,
err
:=
n
.
ne
.
Exec
(
"findmnt"
,
args
)
.
CombinedOutput
()
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
V
(
2
)
.
Infof
(
"Failed findmnt command for path %s: %s %v"
,
f
ile
,
out
,
err
)
glog
.
V
(
2
)
.
Infof
(
"Failed findmnt command for path %s: %s %v"
,
resolvedF
ile
,
out
,
err
)
// Different operating systems behave differently for paths which are not mount points.
// 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 "/".
// 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.
// It's safer to assume that it's not a mount point.
...
@@ -185,13 +192,13 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
...
@@ -185,13 +192,13 @@ func (n *NsenterMounter) IsLikelyNotMountPoint(file string) (bool, error) {
return
false
,
err
return
false
,
err
}
}
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint findmnt output for path %s: %v:"
,
f
ile
,
mountTarget
)
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint findmnt output for path %s: %v:"
,
resolvedF
ile
,
mountTarget
)
if
mountTarget
==
f
ile
{
if
mountTarget
==
resolvedF
ile
{
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint: %s is a mount point"
,
f
ile
)
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint: %s is a mount point"
,
resolvedF
ile
)
return
false
,
nil
return
false
,
nil
}
}
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint: %s is not a mount point"
,
f
ile
)
glog
.
V
(
5
)
.
Infof
(
"IsLikelyNotMountPoint: %s is not a mount point"
,
resolvedF
ile
)
return
true
,
nil
return
true
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment