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
296152ec
Commit
296152ec
authored
May 14, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8281 from dchen1107/cleanup
OOM protected docker processes (-900)
parents
7cc42209
ebbb130a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
container_manager_linux.go
pkg/kubelet/container_manager_linux.go
+8
-1
manager.go
pkg/kubelet/dockertools/manager.go
+2
-1
util.go
pkg/util/util.go
+7
-2
No files found.
pkg/kubelet/container_manager_linux.go
View file @
296152ec
...
...
@@ -39,7 +39,8 @@ type containerManagerImpl struct {
dockerContainerName
string
// The manager of the resource-only container Docker should be in.
manager
fs
.
Manager
manager
fs
.
Manager
dockerOomScoreAdj
int
}
var
_
containerManager
=
&
containerManagerImpl
{}
...
...
@@ -55,6 +56,7 @@ func newContainerManager(dockerDaemonContainer string) (containerManager, error)
AllowAllDevices
:
true
,
},
},
dockerOomScoreAdj
:
-
900
,
},
nil
}
...
...
@@ -103,6 +105,11 @@ func (cm *containerManagerImpl) ensureDockerInContainer() error {
errs
=
append
(
errs
,
fmt
.
Errorf
(
"failed to move PID %q (in %q) to %q"
,
pid
,
cont
,
cm
.
dockerContainerName
))
}
}
// Also apply oom_score_adj to processes
if
err
:=
util
.
ApplyOomScoreAdj
(
pid
,
cm
.
dockerOomScoreAdj
);
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"failed to apply oom score %q to PID %q"
,
cm
.
dockerOomScoreAdj
,
pid
))
}
}
return
errors
.
NewAggregate
(
errs
)
...
...
pkg/kubelet/dockertools/manager.go
View file @
296152ec
...
...
@@ -1293,7 +1293,8 @@ func (dm *DockerManager) createPodInfraContainer(pod *api.Pod) (kubeletTypes.Doc
if
containerInfo
.
State
.
Pid
==
0
{
return
""
,
fmt
.
Errorf
(
"failed to get init PID for Docker pod infra container %q"
,
string
(
id
))
}
return
id
,
util
.
ApplyOomScoreAdj
(
containerInfo
.
State
.
Pid
,
podOomScoreAdj
)
util
.
ApplyOomScoreAdj
(
containerInfo
.
State
.
Pid
,
podOomScoreAdj
)
return
id
,
nil
}
// TODO(vmarmol): This will soon be made non-public when its only use is internal.
...
...
pkg/util/util.go
View file @
296152ec
...
...
@@ -214,8 +214,13 @@ func ApplyOomScoreAdj(pid int, value int) error {
pidStr
=
strconv
.
Itoa
(
pid
)
}
if
err
:=
ioutil
.
WriteFile
(
path
.
Join
(
"/proc"
,
pidStr
,
"oom_score_adj"
),
[]
byte
(
strconv
.
Itoa
(
value
)),
0700
);
err
!=
nil
{
fmt
.
Errorf
(
"failed to set oom_score_adj to %d: %v"
,
value
,
err
)
oom_value
,
err
:=
ioutil
.
ReadFile
(
path
.
Join
(
"/proc"
,
pidStr
,
"oom_score_adj"
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to read oom_score_adj: %v"
,
err
)
}
else
if
string
(
oom_value
)
!=
strconv
.
Itoa
(
value
)
{
if
err
:=
ioutil
.
WriteFile
(
path
.
Join
(
"/proc"
,
pidStr
,
"oom_score_adj"
),
[]
byte
(
strconv
.
Itoa
(
value
)),
0700
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to set oom_score_adj to %d: %v"
,
value
,
err
)
}
}
return
nil
...
...
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