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
97b5299c
Commit
97b5299c
authored
May 23, 2018
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GetMode to mounter interface.
Kubelet must not call os.Lstat on raw volume paths when it runs in a container. Mounter knows where the file really is.
parent
23d9a48e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
72 additions
and
6 deletions
+72
-6
container_manager_linux_test.go
pkg/kubelet/cm/container_manager_linux_test.go
+4
-0
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+5
-6
exec_mount.go
pkg/util/mount/exec_mount.go
+4
-0
exec_mount_test.go
pkg/util/mount/exec_mount_test.go
+4
-0
exec_mount_unsupported.go
pkg/util/mount/exec_mount_unsupported.go
+4
-0
fake.go
pkg/util/mount/fake.go
+4
-0
mount.go
pkg/util/mount/mount.go
+2
-0
mount_linux.go
pkg/util/mount/mount_linux.go
+13
-0
mount_unsupported.go
pkg/util/mount/mount_unsupported.go
+4
-0
mount_windows.go
pkg/util/mount/mount_windows.go
+8
-0
nsenter_mount.go
pkg/util/mount/nsenter_mount.go
+8
-0
nsenter_mount_unsupported.go
pkg/util/mount/nsenter_mount_unsupported.go
+4
-0
removeall_test.go
pkg/util/removeall/removeall_test.go
+4
-0
host_path_test.go
pkg/volume/host_path/host_path_test.go
+4
-0
No files found.
pkg/kubelet/cm/container_manager_linux_test.go
View file @
97b5299c
...
...
@@ -120,6 +120,10 @@ func (mi *fakeMountInterface) GetSELinuxSupport(pathname string) (bool, error) {
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mi
*
fakeMountInterface
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
fakeContainerMgrMountInt
()
mount
.
Interface
{
return
&
fakeMountInterface
{
[]
mount
.
MountPoint
{
...
...
pkg/kubelet/kubelet_pods.go
View file @
97b5299c
...
...
@@ -175,12 +175,6 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
return
nil
,
cleanupAction
,
fmt
.
Errorf
(
"unable to provision SubPath `%s`: %v"
,
mount
.
SubPath
,
err
)
}
fileinfo
,
err
:=
os
.
Lstat
(
hostPath
)
if
err
!=
nil
{
return
nil
,
cleanupAction
,
err
}
perm
:=
fileinfo
.
Mode
()
volumePath
,
err
:=
filepath
.
EvalSymlinks
(
hostPath
)
if
err
!=
nil
{
return
nil
,
cleanupAction
,
err
...
...
@@ -195,6 +189,11 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
// when the pod specifies an fsGroup, and if the directory is not created here, Docker will
// later auto-create it with the incorrect mode 0750
// Make extra care not to escape the volume!
perm
,
err
:=
mounter
.
GetMode
(
volumePath
)
if
err
!=
nil
{
return
nil
,
cleanupAction
,
err
}
if
err
:=
mounter
.
SafeMakeDir
(
hostPath
,
volumePath
,
perm
);
err
!=
nil
{
glog
.
Errorf
(
"failed to mkdir %q: %v"
,
hostPath
,
err
)
return
nil
,
cleanupAction
,
err
...
...
pkg/util/mount/exec_mount.go
View file @
97b5299c
...
...
@@ -163,3 +163,7 @@ func (m *execMounter) GetFSGroup(pathname string) (int64, error) {
func
(
m
*
execMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
m
.
wrappedMounter
.
GetSELinuxSupport
(
pathname
)
}
func
(
m
*
execMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
m
.
wrappedMounter
.
GetMode
(
pathname
)
}
pkg/util/mount/exec_mount_test.go
View file @
97b5299c
...
...
@@ -176,3 +176,7 @@ func (fm *fakeMounter) GetFSGroup(pathname string) (int64, error) {
func
(
fm
*
fakeMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
fm
*
fakeMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/mount/exec_mount_unsupported.go
View file @
97b5299c
...
...
@@ -110,3 +110,7 @@ func (mounter *execMounter) GetFSGroup(pathname string) (int64, error) {
func
(
mounter
*
execMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
execMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/mount/fake.go
View file @
97b5299c
...
...
@@ -232,3 +232,7 @@ func (f *FakeMounter) GetFSGroup(pathname string) (int64, error) {
func
(
f
*
FakeMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"GetSELinuxSupport not implemented"
)
}
func
(
f
*
FakeMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/mount/mount.go
View file @
97b5299c
...
...
@@ -117,6 +117,8 @@ type Interface interface {
// GetSELinuxSupport returns true if given path is on a mount that supports
// SELinux.
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
// GetMode returns permissions of the path.
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
}
type
Subpath
struct
{
...
...
pkg/util/mount/mount_linux.go
View file @
97b5299c
...
...
@@ -982,6 +982,10 @@ func (mounter *Mounter) GetFSGroup(pathname string) (int64, error) {
return
getFSGroup
(
realpath
)
}
func
(
mounter
*
Mounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
getMode
(
pathname
)
}
// This implementation is shared between Linux and NsEnterMounter
func
getFSGroup
(
pathname
string
)
(
int64
,
error
)
{
info
,
err
:=
os
.
Stat
(
pathname
)
...
...
@@ -992,6 +996,15 @@ func getFSGroup(pathname string) (int64, error) {
}
// This implementation is shared between Linux and NsEnterMounter
func
getMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
info
,
err
:=
os
.
Stat
(
pathname
)
if
err
!=
nil
{
return
0
,
err
}
return
info
.
Mode
(),
nil
}
// This implementation is shared between Linux and NsEnterMounter
func
doSafeMakeDir
(
pathname
string
,
base
string
,
perm
os
.
FileMode
)
error
{
glog
.
V
(
4
)
.
Infof
(
"Creating directory %q within base %q"
,
pathname
,
base
)
...
...
pkg/util/mount/mount_unsupported.go
View file @
97b5299c
...
...
@@ -138,3 +138,7 @@ func (mounter *Mounter) GetFSGroup(pathname string) (int64, error) {
func
(
mounter
*
Mounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
Mounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/mount/mount_windows.go
View file @
97b5299c
...
...
@@ -461,6 +461,14 @@ func (mounter *Mounter) GetSELinuxSupport(pathname string) (bool, error) {
return
false
,
nil
}
func
(
mounter
*
Mounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
info
,
err
:=
os
.
Stat
(
pathname
)
if
err
!=
nil
{
return
0
,
err
}
return
info
.
Mode
(),
nil
}
// SafeMakeDir makes sure that the created directory does not escape given base directory mis-using symlinks.
func
(
mounter
*
Mounter
)
SafeMakeDir
(
pathname
string
,
base
string
,
perm
os
.
FileMode
)
error
{
return
doSafeMakeDir
(
pathname
,
base
,
perm
)
...
...
pkg/util/mount/nsenter_mount.go
View file @
97b5299c
...
...
@@ -347,3 +347,11 @@ func (mounter *NsenterMounter) GetFSGroup(pathname string) (int64, error) {
func
(
mounter
*
NsenterMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
getSELinuxSupport
(
pathname
,
procMountInfoPath
)
}
func
(
mounter
*
NsenterMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
kubeletpath
,
err
:=
mounter
.
ne
.
KubeletPath
(
pathname
)
if
err
!=
nil
{
return
0
,
err
}
return
getMode
(
kubeletpath
)
}
pkg/util/mount/nsenter_mount_unsupported.go
View file @
97b5299c
...
...
@@ -110,3 +110,7 @@ func (*NsenterMounter) GetFSGroup(pathname string) (int64, error) {
func
(
*
NsenterMounter
)
GetSELinuxSupport
(
pathname
string
)
(
bool
,
error
)
{
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
*
NsenterMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
pkg/util/removeall/removeall_test.go
View file @
97b5299c
...
...
@@ -103,6 +103,10 @@ func (mounter *fakeMounter) GetSELinuxSupport(pathname string) (bool, error) {
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
(
mounter
*
fakeMounter
)
IsLikelyNotMountPoint
(
file
string
)
(
bool
,
error
)
{
name
:=
path
.
Base
(
file
)
if
strings
.
HasPrefix
(
name
,
"mount"
)
{
...
...
pkg/volume/host_path/host_path_test.go
View file @
97b5299c
...
...
@@ -401,6 +401,10 @@ func (fftc *fakeFileTypeChecker) GetSELinuxSupport(pathname string) (bool, error
return
false
,
errors
.
New
(
"not implemented"
)
}
func
(
fftc
*
fakeFileTypeChecker
)
GetMode
(
pathname
string
)
(
os
.
FileMode
,
error
)
{
return
0
,
errors
.
New
(
"not implemented"
)
}
func
setUp
()
error
{
err
:=
os
.
MkdirAll
(
"/tmp/ExistingFolder"
,
os
.
FileMode
(
0755
))
if
err
!=
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