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
80c48aed
Commit
80c48aed
authored
Jun 15, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9824 from dchen1107/clean
explicitly applying oom_score_adj(0) to processes of user containers
parents
19a7e87c
14f78b74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
26 deletions
+37
-26
manager.go
pkg/kubelet/dockertools/manager.go
+27
-16
manager_test.go
pkg/kubelet/dockertools/manager_test.go
+9
-9
kubelet_test.go
pkg/kubelet/kubelet_test.go
+1
-1
No files found.
pkg/kubelet/dockertools/manager.go
View file @
80c48aed
...
...
@@ -48,9 +48,11 @@ import (
)
const
(
// The oom_score_adj of the POD infrastructure container. The default is 0, so
// any value below that makes it *less* likely to get OOM killed.
podOomScoreAdj
=
-
100
// The oom_score_adj of the POD infrastructure container. The default is 0 for
// any other docker containers, so any value below that makes it *less* likely
// to get OOM killed.
podOomScoreAdj
=
-
100
userContainerOomScoreAdj
=
0
maxReasonCacheEntries
=
200
...
...
@@ -1195,6 +1197,28 @@ func (dm *DockerManager) runContainerInPod(pod *api.Pod, container *api.Containe
if
err
=
dm
.
os
.
Symlink
(
containerLogFile
,
symlinkFile
);
err
!=
nil
{
glog
.
Errorf
(
"Failed to create symbolic link to the log file of pod %q container %q: %v"
,
podFullName
,
container
.
Name
,
err
)
}
// Set OOM score of POD container to lower than those of the other containers
// which have OOM score 0 by default in the pod. This ensures that it is
// killed only as a last resort.
containerInfo
,
err
:=
dm
.
client
.
InspectContainer
(
string
(
id
))
if
err
!=
nil
{
return
""
,
err
}
// Ensure the PID actually exists, else we'll move ourselves.
if
containerInfo
.
State
.
Pid
==
0
{
return
""
,
fmt
.
Errorf
(
"failed to get init PID for Docker container %q"
,
string
(
id
))
}
if
container
.
Name
==
PodInfraContainerName
{
util
.
ApplyOomScoreAdj
(
containerInfo
.
State
.
Pid
,
podOomScoreAdj
)
}
else
{
// Children processes of docker daemon will inheritant the OOM score from docker
// daemon process. We explicitly apply OOM score 0 by default to the user
// containers to avoid daemons or POD containers are killed by oom killer.
util
.
ApplyOomScoreAdj
(
containerInfo
.
State
.
Pid
,
userContainerOomScoreAdj
)
}
return
kubeletTypes
.
DockerID
(
id
),
err
}
...
...
@@ -1249,19 +1273,6 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
return
""
,
err
}
// Set OOM score of POD container to lower than those of the other
// containers in the pod. This ensures that it is killed only as a last
// resort.
containerInfo
,
err
:=
dm
.
client
.
InspectContainer
(
string
(
id
))
if
err
!=
nil
{
return
""
,
err
}
// Ensure the PID actually exists, else we'll move ourselves.
if
containerInfo
.
State
.
Pid
==
0
{
return
""
,
fmt
.
Errorf
(
"failed to get init PID for Docker pod infra container %q"
,
string
(
id
))
}
util
.
ApplyOomScoreAdj
(
containerInfo
.
State
.
Pid
,
podOomScoreAdj
)
return
id
,
nil
}
...
...
pkg/kubelet/dockertools/manager_test.go
View file @
80c48aed
...
...
@@ -898,7 +898,7 @@ func TestSyncPodCreateNetAndContainer(t *testing.T) {
// Create pod infra container.
"create"
,
"start"
,
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
fakeDocker
.
Lock
()
...
...
@@ -947,7 +947,7 @@ func TestSyncPodCreatesNetAndContainerPullsImage(t *testing.T) {
// Create pod infra container.
"create"
,
"start"
,
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
fakeDocker
.
Lock
()
...
...
@@ -999,7 +999,7 @@ func TestSyncPodWithPodInfraCreatesContainer(t *testing.T) {
// Inspect pod infra container (but does not create)"
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
fakeDocker
.
Lock
()
...
...
@@ -1040,7 +1040,7 @@ func TestSyncPodDeletesWithNoPodInfraContainer(t *testing.T) {
// Create pod infra container.
"create"
,
"start"
,
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
// A map iteration is used to delete containers, so must not depend on
...
...
@@ -1165,7 +1165,7 @@ func TestSyncPodBadHash(t *testing.T) {
// Check the pod infra container.
"inspect_container"
,
// Kill and restart the bad hash container.
"inspect_container"
,
"stop"
,
"create"
,
"start"
,
"inspect_container"
,
"stop"
,
"create"
,
"start"
,
"inspect_container"
,
})
if
err
:=
fakeDocker
.
AssertStopped
([]
string
{
"1234"
});
err
!=
nil
{
...
...
@@ -1225,7 +1225,7 @@ func TestSyncPodsUnhealthy(t *testing.T) {
// Kill the unhealthy container.
"inspect_container"
,
"stop"
,
// Restart the unhealthy container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
if
err
:=
fakeDocker
.
AssertStopped
([]
string
{
"1234"
});
err
!=
nil
{
...
...
@@ -1410,7 +1410,7 @@ func TestSyncPodWithRestartPolicy(t *testing.T) {
// Check the pod infra container.
"inspect_container"
,
// Restart both containers.
"create"
,
"start"
,
"
create"
,
"start
"
,
"create"
,
"start"
,
"
inspect_container"
,
"create"
,
"start"
,
"inspect_container
"
,
},
[]
string
{
"succeeded"
,
"failed"
},
[]
string
{},
...
...
@@ -1421,7 +1421,7 @@ func TestSyncPodWithRestartPolicy(t *testing.T) {
// Check the pod infra container.
"inspect_container"
,
// Restart the failed container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
},
[]
string
{
"failed"
},
[]
string
{},
...
...
@@ -1834,7 +1834,7 @@ func TestSyncPodWithPodInfraCreatesContainerCallsHandler(t *testing.T) {
// Check the pod infra container.
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
})
fakeDocker
.
Lock
()
...
...
pkg/kubelet/kubelet_test.go
View file @
80c48aed
...
...
@@ -484,7 +484,7 @@ func TestSyncPodsWithTerminationLog(t *testing.T) {
// Create pod infra container.
"create"
,
"start"
,
"inspect_container"
,
// Create container.
"create"
,
"start"
,
"create"
,
"start"
,
"inspect_container"
,
// Get pod status.
"list"
,
"inspect_container"
,
"inspect_container"
,
// Get pods for deleting orphaned volumes.
...
...
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