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
01a44d22
Commit
01a44d22
authored
Apr 12, 2018
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add private mount propagation to API.
And make it default
parent
d1b38b21
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
10 deletions
+33
-10
types.go
pkg/apis/core/types.go
+6
-0
validation.go
pkg/apis/core/validation/validation.go
+1
-1
validation_test.go
pkg/apis/core/validation/validation_test.go
+7
-0
kubelet_pods.go
pkg/kubelet/kubelet_pods.go
+4
-2
kubelet_pods_test.go
pkg/kubelet/kubelet_pods_test.go
+9
-7
types.go
staging/src/k8s.io/api/core/v1/types.go
+6
-0
No files found.
pkg/apis/core/types.go
View file @
01a44d22
...
...
@@ -1540,6 +1540,12 @@ type VolumeMount struct {
type
MountPropagationMode
string
const
(
// MountPropagationNone means that the volume in a container will
// not receive new mounts from the host or other containers, and filesystems
// mounted inside the container won't be propagated to the host or other
// containers.
// Note that this mode corresponds to "private" in Linux terminology.
MountPropagationNone
MountPropagationMode
=
"None"
// MountPropagationHostToContainer means that the volume in a container will
// receive new mounts from the host or other containers, but filesystems
// mounted inside the container won't be propagated to the host or other
...
...
pkg/apis/core/validation/validation.go
View file @
01a44d22
...
...
@@ -1140,7 +1140,7 @@ func validateMountPropagation(mountPropagation *core.MountPropagationMode, conta
return
allErrs
}
supportedMountPropagations
:=
sets
.
NewString
(
string
(
core
.
MountPropagationBidirectional
),
string
(
core
.
MountPropagationHostToContainer
))
supportedMountPropagations
:=
sets
.
NewString
(
string
(
core
.
MountPropagationBidirectional
),
string
(
core
.
MountPropagationHostToContainer
)
,
string
(
core
.
MountPropagationNone
)
)
if
!
supportedMountPropagations
.
Has
(
string
(
*
mountPropagation
))
{
allErrs
=
append
(
allErrs
,
field
.
NotSupported
(
fldPath
,
*
mountPropagation
,
supportedMountPropagations
.
List
()))
}
...
...
pkg/apis/core/validation/validation_test.go
View file @
01a44d22
...
...
@@ -4704,6 +4704,7 @@ func TestValidateMountPropagation(t *testing.T) {
propagationBidirectional
:=
core
.
MountPropagationBidirectional
propagationHostToContainer
:=
core
.
MountPropagationHostToContainer
propagationNone
:=
core
.
MountPropagationNone
propagationInvalid
:=
core
.
MountPropagationMode
(
"invalid"
)
tests
:=
[]
struct
{
...
...
@@ -4724,6 +4725,12 @@ func TestValidateMountPropagation(t *testing.T) {
false
,
},
{
// non-privileged container + None
core
.
VolumeMount
{
Name
:
"foo"
,
MountPath
:
"/foo"
,
MountPropagation
:
&
propagationNone
},
defaultContainer
,
false
,
},
{
// error: implicitly non-privileged container + Bidirectional
core
.
VolumeMount
{
Name
:
"foo"
,
MountPath
:
"/foo"
,
MountPropagation
:
&
propagationBidirectional
},
defaultContainer
,
...
...
pkg/kubelet/kubelet_pods.go
View file @
01a44d22
...
...
@@ -269,12 +269,14 @@ func translateMountPropagation(mountMode *v1.MountPropagationMode) (runtimeapi.M
}
switch
{
case
mountMode
==
nil
:
//
HostToContainer
is the default
return
runtimeapi
.
MountPropagation_PROPAGATION_
HOST_TO_CONTAINER
,
nil
//
PRIVATE
is the default
return
runtimeapi
.
MountPropagation_PROPAGATION_
PRIVATE
,
nil
case
*
mountMode
==
v1
.
MountPropagationHostToContainer
:
return
runtimeapi
.
MountPropagation_PROPAGATION_HOST_TO_CONTAINER
,
nil
case
*
mountMode
==
v1
.
MountPropagationBidirectional
:
return
runtimeapi
.
MountPropagation_PROPAGATION_BIDIRECTIONAL
,
nil
case
*
mountMode
==
v1
.
MountPropagationNone
:
return
runtimeapi
.
MountPropagation_PROPAGATION_PRIVATE
,
nil
default
:
return
0
,
fmt
.
Errorf
(
"invalid MountPropagation mode: %q"
,
mountMode
)
}
...
...
pkg/kubelet/kubelet_pods_test.go
View file @
01a44d22
...
...
@@ -55,6 +55,7 @@ func TestMakeMounts(t *testing.T) {
bTrue
:=
true
propagationHostToContainer
:=
v1
.
MountPropagationHostToContainer
propagationBidirectional
:=
v1
.
MountPropagationBidirectional
propagationNone
:=
v1
.
MountPropagationNone
testCases
:=
map
[
string
]
struct
{
container
v1
.
Container
...
...
@@ -79,9 +80,10 @@ func TestMakeMounts(t *testing.T) {
MountPropagation
:
&
propagationHostToContainer
,
},
{
MountPath
:
"/mnt/path3"
,
Name
:
"disk"
,
ReadOnly
:
true
,
MountPath
:
"/mnt/path3"
,
Name
:
"disk"
,
ReadOnly
:
true
,
MountPropagation
:
&
propagationNone
,
},
{
MountPath
:
"/mnt/path4"
,
...
...
@@ -110,7 +112,7 @@ func TestMakeMounts(t *testing.T) {
HostPath
:
"/mnt/disk"
,
ReadOnly
:
true
,
SELinuxRelabel
:
false
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
HOST_TO_CONTAINER
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
PRIVATE
,
},
{
Name
:
"disk4"
,
...
...
@@ -118,7 +120,7 @@ func TestMakeMounts(t *testing.T) {
HostPath
:
"/mnt/host"
,
ReadOnly
:
false
,
SELinuxRelabel
:
false
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
HOST_TO_CONTAINER
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
PRIVATE
,
},
{
Name
:
"disk5"
,
...
...
@@ -126,7 +128,7 @@ func TestMakeMounts(t *testing.T) {
HostPath
:
"/var/lib/kubelet/podID/volumes/empty/disk5"
,
ReadOnly
:
false
,
SELinuxRelabel
:
false
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
HOST_TO_CONTAINER
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
PRIVATE
,
},
},
expectErr
:
false
,
...
...
@@ -185,7 +187,7 @@ func TestMakeMounts(t *testing.T) {
HostPath
:
"/mnt/host"
,
ReadOnly
:
false
,
SELinuxRelabel
:
false
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
HOST_TO_CONTAINER
,
Propagation
:
runtimeapi
.
MountPropagation_PROPAGATION_
PRIVATE
,
},
},
expectErr
:
false
,
...
...
staging/src/k8s.io/api/core/v1/types.go
View file @
01a44d22
...
...
@@ -1624,6 +1624,12 @@ type VolumeMount struct {
type
MountPropagationMode
string
const
(
// MountPropagationNone means that the volume in a container will
// not receive new mounts from the host or other containers, and filesystems
// mounted inside the container won't be propagated to the host or other
// containers.
// Note that this mode corresponds to "private" in Linux terminology.
MountPropagationNone
MountPropagationMode
=
"None"
// MountPropagationHostToContainer means that the volume in a container will
// receive new mounts from the host or other containers, but filesystems
// mounted inside the container won't be propagated to the host or other
...
...
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