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
9c6223f8
Commit
9c6223f8
authored
May 10, 2017
by
Matthew Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't attempt to make and chmod subPath if it already exists
parent
becd626c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+17
-12
No files found.
pkg/kubelet/kubelet_pods.go
View file @
9c6223f8
...
@@ -58,6 +58,7 @@ import (
...
@@ -58,6 +58,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/status"
"k8s.io/kubernetes/pkg/kubelet/status"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
kubetypes
"k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/kubelet/util/format"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/pkg/volume/util/volumehelper"
"k8s.io/kubernetes/third_party/forked/golang/expansion"
"k8s.io/kubernetes/third_party/forked/golang/expansion"
...
@@ -145,19 +146,23 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
...
@@ -145,19 +146,23 @@ func makeMounts(pod *v1.Pod, podDir string, container *v1.Container, hostName, h
hostPath
=
filepath
.
Join
(
hostPath
,
mount
.
SubPath
)
hostPath
=
filepath
.
Join
(
hostPath
,
mount
.
SubPath
)
// Create the sub path now because if it's auto-created later when referenced, it may have an
if
subPathExists
,
err
:=
util
.
FileExists
(
hostPath
);
err
!=
nil
{
// incorrect ownership and mode. For example, the sub path directory must have at least g+rwx
glog
.
Errorf
(
"Could not determine if subPath %s exists; will not attempt to change its permissions"
,
hostPath
)
// when the pod specifies an fsGroup, and if the directory is not created here, Docker will
}
else
if
!
subPathExists
{
// later auto-create it with the incorrect mode 0750
// Create the sub path now because if it's auto-created later when referenced, it may have an
if
err
:=
os
.
MkdirAll
(
hostPath
,
perm
);
err
!=
nil
{
// incorrect ownership and mode. For example, the sub path directory must have at least g+rwx
glog
.
Errorf
(
"failed to mkdir:%s"
,
hostPath
)
// when the pod specifies an fsGroup, and if the directory is not created here, Docker will
return
nil
,
err
// later auto-create it with the incorrect mode 0750
}
if
err
:=
os
.
MkdirAll
(
hostPath
,
perm
);
err
!=
nil
{
glog
.
Errorf
(
"failed to mkdir:%s"
,
hostPath
)
return
nil
,
err
}
// chmod the sub path because umask may have prevented us from making the sub path with the same
// chmod the sub path because umask may have prevented us from making the sub path with the same
// permissions as the mounter path
// permissions as the mounter path
if
err
:=
os
.
Chmod
(
hostPath
,
perm
);
err
!=
nil
{
if
err
:=
os
.
Chmod
(
hostPath
,
perm
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
}
}
}
...
...
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