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
7dcf1fe5
Commit
7dcf1fe5
authored
Feb 05, 2019
by
Seth Jennings
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet: set low oom_score_adj for containers in critical pods
parent
1c557b9c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
BUILD
pkg/kubelet/qos/BUILD
+2
-0
policy.go
pkg/kubelet/qos/policy.go
+7
-1
policy_test.go
pkg/kubelet/qos/policy_test.go
+21
-1
No files found.
pkg/kubelet/qos/BUILD
View file @
7dcf1fe5
...
...
@@ -11,6 +11,7 @@ go_test(
srcs = ["policy_test.go"],
embed = [":go_default_library"],
deps = [
"//pkg/apis/scheduling:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
],
...
...
@@ -25,6 +26,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/kubelet/qos",
deps = [
"//pkg/apis/core/v1/helper/qos:go_default_library",
"//pkg/kubelet/types:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
],
)
...
...
pkg/kubelet/qos/policy.go
View file @
7dcf1fe5
...
...
@@ -17,8 +17,9 @@ limitations under the License.
package
qos
import
(
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
v1qos
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
"k8s.io/kubernetes/pkg/kubelet/types"
)
const
(
...
...
@@ -41,6 +42,11 @@ const (
// and 1000. Containers with higher OOM scores are killed if the system runs out of memory.
// See https://lwn.net/Articles/391222/ for more information.
func
GetContainerOOMScoreAdjust
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
,
memoryCapacity
int64
)
int
{
if
types
.
IsCriticalPod
(
pod
)
{
// Critical pods should be the last to get killed.
return
guaranteedOOMScoreAdj
}
switch
v1qos
.
GetPodQOS
(
pod
)
{
case
v1
.
PodQOSGuaranteed
:
// Guaranteed containers should be the last to get killed.
...
...
pkg/kubelet/qos/policy_test.go
View file @
7dcf1fe5
...
...
@@ -20,8 +20,9 @@ import (
"strconv"
"testing"
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/apis/scheduling"
)
const
(
...
...
@@ -135,6 +136,19 @@ var (
},
},
}
systemCritical
=
scheduling
.
SystemCriticalPriority
critical
=
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
Priority
:
&
systemCritical
,
Containers
:
[]
v1
.
Container
{
{
Resources
:
v1
.
ResourceRequirements
{},
},
},
},
}
)
type
oomTest
struct
{
...
...
@@ -188,6 +202,12 @@ func TestGetContainerOOMScoreAdjust(t *testing.T) {
lowOOMScoreAdj
:
2
,
highOOMScoreAdj
:
2
,
},
{
pod
:
&
critical
,
memoryCapacity
:
4000000000
,
lowOOMScoreAdj
:
-
998
,
highOOMScoreAdj
:
-
998
,
},
}
for
_
,
test
:=
range
oomTests
{
oomScoreAdj
:=
GetContainerOOMScoreAdjust
(
test
.
pod
,
&
test
.
pod
.
Spec
.
Containers
[
0
],
test
.
memoryCapacity
)
...
...
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