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
7cf9ee19
Commit
7cf9ee19
authored
Aug 19, 2015
by
Lv Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for utsMode change
parent
0b90dfba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
manager.go
pkg/kubelet/dockertools/manager.go
+1
-1
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+40
-0
No files found.
pkg/kubelet/dockertools/manager.go
View file @
7cf9ee19
...
@@ -1309,7 +1309,7 @@ func (dm *DockerManager) runContainerInPod(pod *api.Pod, container *api.Containe
...
@@ -1309,7 +1309,7 @@ func (dm *DockerManager) runContainerInPod(pod *api.Pod, container *api.Containe
// This resolv.conf file is shared by all containers of the same pod, and needs to be modified only once per pod.
// This resolv.conf file is shared by all containers of the same pod, and needs to be modified only once per pod.
// we modify it when the pause container is created since it is the first container created in the pod since it holds
// we modify it when the pause container is created since it is the first container created in the pod since it holds
// the networking namespace.
// the networking namespace.
if
container
.
Name
==
PodInfraContainerName
{
if
container
.
Name
==
PodInfraContainerName
&&
utsMode
!=
"host"
{
err
=
addNDotsOption
(
containerInfo
.
ResolvConfPath
)
err
=
addNDotsOption
(
containerInfo
.
ResolvConfPath
)
}
}
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
7cf9ee19
...
@@ -1991,6 +1991,46 @@ func TestSyncPodWithTerminationLog(t *testing.T) {
...
@@ -1991,6 +1991,46 @@ func TestSyncPodWithTerminationLog(t *testing.T) {
}
}
}
}
func
TestSyncPodWithHostNetwork
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
pod
:=
&
api
.
Pod
{
ObjectMeta
:
api
.
ObjectMeta
{
UID
:
"12345678"
,
Name
:
"foo"
,
Namespace
:
"new"
,
},
Spec
:
api
.
PodSpec
{
Containers
:
[]
api
.
Container
{
{
Name
:
"bar"
},
},
HostNetwork
:
true
,
},
}
runSyncPod
(
t
,
dm
,
fakeDocker
,
pod
)
verifyCalls
(
t
,
fakeDocker
,
[]
string
{
// Create pod infra container.
"create"
,
"start"
,
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"inspect_container"
,
})
fakeDocker
.
Lock
()
if
len
(
fakeDocker
.
Created
)
!=
2
||
!
matchString
(
t
,
"k8s_POD
\\
.[a-f0-9]+_foo_new_"
,
fakeDocker
.
Created
[
0
])
||
!
matchString
(
t
,
"k8s_bar
\\
.[a-f0-9]+_foo_new_"
,
fakeDocker
.
Created
[
1
])
{
t
.
Errorf
(
"Unexpected containers created %v"
,
fakeDocker
.
Created
)
}
utsMode
:=
fakeDocker
.
Container
.
HostConfig
.
UTSMode
if
utsMode
!=
"host"
{
t
.
Errorf
(
"Pod with host network must have
\"
host
\"
utsMode, actual:
\"
%v
\"
"
,
utsMode
)
}
fakeDocker
.
Unlock
()
}
func
TestGetPodStatusSortedContainers
(
t
*
testing
.
T
)
{
func
TestGetPodStatusSortedContainers
(
t
*
testing
.
T
)
{
dm
,
fakeDocker
:=
newTestDockerManager
()
dm
,
fakeDocker
:=
newTestDockerManager
()
dockerInspect
:=
map
[
string
]
*
docker
.
Container
{}
dockerInspect
:=
map
[
string
]
*
docker
.
Container
{}
...
...
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