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
20361e33
Commit
20361e33
authored
Sep 21, 2015
by
Paul Weil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use infra container ns for ipc
parent
84313488
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
validation_test.go
pkg/api/validation/validation_test.go
+14
-1
manager.go
pkg/kubelet/dockertools/manager.go
+8
-3
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+2
-2
No files found.
pkg/api/validation/validation_test.go
View file @
20361e33
...
...
@@ -1259,6 +1259,20 @@ func TestValidatePodSpec(t *testing.T) {
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
{
// Populate HostIPC.
HostIPC
:
true
,
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
{
// Populate HostPID.
HostPID
:
true
,
Volumes
:
[]
api
.
Volume
{{
Name
:
"vol"
,
VolumeSource
:
api
.
VolumeSource
{
EmptyDir
:
&
api
.
EmptyDirVolumeSource
{}}}},
Containers
:
[]
api
.
Container
{{
Name
:
"ctr"
,
Image
:
"image"
,
ImagePullPolicy
:
"IfNotPresent"
}},
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
}
for
i
:=
range
successCases
{
if
errs
:=
ValidatePodSpec
(
&
successCases
[
i
]);
len
(
errs
)
!=
0
{
...
...
@@ -1306,7 +1320,6 @@ func TestValidatePodSpec(t *testing.T) {
},
},
HostNetwork
:
true
,
HostIPC
:
true
,
RestartPolicy
:
api
.
RestartPolicyAlways
,
DNSPolicy
:
api
.
DNSClusterFirst
,
},
...
...
pkg/kubelet/dockertools/manager.go
View file @
20361e33
...
...
@@ -1548,7 +1548,7 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
return
""
,
err
}
id
,
err
:=
dm
.
runContainerInPod
(
pod
,
container
,
netNamespace
,
getIPCMode
(
pod
,
""
),
getPidMode
(
pod
))
id
,
err
:=
dm
.
runContainerInPod
(
pod
,
container
,
netNamespace
,
getIPCMode
(
pod
),
getPidMode
(
pod
))
if
err
!=
nil
{
return
""
,
err
}
...
...
@@ -1803,8 +1803,12 @@ func (dm *DockerManager) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, pod
}
// TODO(dawnchen): Check RestartPolicy.DelaySeconds before restart a container
// Note: when configuring the pod's containers anything that can be configured by pointing
// to the namespace of the infra container should use namespaceMode. This includes things like the net namespace
// and IPC namespace. PID mode cannot point to another container right now.
// See createPodInfraContainer for infra container setup.
namespaceMode
:=
fmt
.
Sprintf
(
"container:%v"
,
podInfraContainerID
)
_
,
err
=
dm
.
runContainerInPod
(
pod
,
container
,
namespaceMode
,
getIPCMode
(
pod
,
namespaceMode
)
,
getPidMode
(
pod
))
_
,
err
=
dm
.
runContainerInPod
(
pod
,
container
,
namespaceMode
,
namespaceMode
,
getPidMode
(
pod
))
dm
.
updateReasonCache
(
pod
,
container
,
"RunContainerError"
,
err
)
if
err
!=
nil
{
// TODO(bburns) : Perhaps blacklist a container after N failures?
...
...
@@ -1929,7 +1933,8 @@ func getPidMode(pod *api.Pod) string {
}
// getIPCMode returns the ipc mode to use on the docker container based on pod.Spec.HostIPC.
func
getIPCMode
(
pod
*
api
.
Pod
,
ipcMode
string
)
string
{
func
getIPCMode
(
pod
*
api
.
Pod
)
string
{
ipcMode
:=
""
if
pod
.
Spec
.
HostIPC
{
ipcMode
=
"host"
}
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
20361e33
...
...
@@ -2071,7 +2071,7 @@ func TestGetPidMode(t *testing.T) {
func
TestGetIPCMode
(
t
*
testing
.
T
)
{
// test false
pod
:=
&
api
.
Pod
{}
ipcMode
:=
getIPCMode
(
pod
,
""
)
ipcMode
:=
getIPCMode
(
pod
)
if
ipcMode
!=
""
{
t
.
Errorf
(
"expected empty ipc mode for pod but got %v"
,
ipcMode
)
...
...
@@ -2079,7 +2079,7 @@ func TestGetIPCMode(t *testing.T) {
// test true
pod
.
Spec
.
HostIPC
=
true
ipcMode
=
getIPCMode
(
pod
,
""
)
ipcMode
=
getIPCMode
(
pod
)
if
ipcMode
!=
"host"
{
t
.
Errorf
(
"expected host ipc mode for pod but got %v"
,
ipcMode
)
}
...
...
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