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
67966456
Unverified
Commit
67966456
authored
Feb 06, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 06, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73758 from sjenning/priority-based-oom-score-adj
kubelet: set low oom_score_adj for containers in critical pods
parents
b00b5d4a
7dcf1fe5
Show 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 @
67966456
...
@@ -11,6 +11,7 @@ go_test(
...
@@ -11,6 +11,7 @@ go_test(
srcs = ["policy_test.go"],
srcs = ["policy_test.go"],
embed = [":go_default_library"],
embed = [":go_default_library"],
deps = [
deps = [
"//pkg/apis/scheduling:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/api/core/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
],
],
...
@@ -25,6 +26,7 @@ go_library(
...
@@ -25,6 +26,7 @@ go_library(
importpath = "k8s.io/kubernetes/pkg/kubelet/qos",
importpath = "k8s.io/kubernetes/pkg/kubelet/qos",
deps = [
deps = [
"//pkg/apis/core/v1/helper/qos:go_default_library",
"//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",
"//staging/src/k8s.io/api/core/v1:go_default_library",
],
],
)
)
...
...
pkg/kubelet/qos/policy.go
View file @
67966456
...
@@ -17,8 +17,9 @@ limitations under the License.
...
@@ -17,8 +17,9 @@ limitations under the License.
package
qos
package
qos
import
(
import
(
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
v1qos
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
v1qos
"k8s.io/kubernetes/pkg/apis/core/v1/helper/qos"
"k8s.io/kubernetes/pkg/kubelet/types"
)
)
const
(
const
(
...
@@ -41,6 +42,11 @@ const (
...
@@ -41,6 +42,11 @@ const (
// and 1000. Containers with higher OOM scores are killed if the system runs out of memory.
// 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.
// See https://lwn.net/Articles/391222/ for more information.
func
GetContainerOOMScoreAdjust
(
pod
*
v1
.
Pod
,
container
*
v1
.
Container
,
memoryCapacity
int64
)
int
{
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
)
{
switch
v1qos
.
GetPodQOS
(
pod
)
{
case
v1
.
PodQOSGuaranteed
:
case
v1
.
PodQOSGuaranteed
:
// Guaranteed containers should be the last to get killed.
// Guaranteed containers should be the last to get killed.
...
...
pkg/kubelet/qos/policy_test.go
View file @
67966456
...
@@ -20,8 +20,9 @@ import (
...
@@ -20,8 +20,9 @@ import (
"strconv"
"strconv"
"testing"
"testing"
"k8s.io/api/core/v1"
v1
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/apis/scheduling"
)
)
const
(
const
(
...
@@ -135,6 +136,19 @@ var (
...
@@ -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
{
type
oomTest
struct
{
...
@@ -188,6 +202,12 @@ func TestGetContainerOOMScoreAdjust(t *testing.T) {
...
@@ -188,6 +202,12 @@ func TestGetContainerOOMScoreAdjust(t *testing.T) {
lowOOMScoreAdj
:
2
,
lowOOMScoreAdj
:
2
,
highOOMScoreAdj
:
2
,
highOOMScoreAdj
:
2
,
},
},
{
pod
:
&
critical
,
memoryCapacity
:
4000000000
,
lowOOMScoreAdj
:
-
998
,
highOOMScoreAdj
:
-
998
,
},
}
}
for
_
,
test
:=
range
oomTests
{
for
_
,
test
:=
range
oomTests
{
oomScoreAdj
:=
GetContainerOOMScoreAdjust
(
test
.
pod
,
&
test
.
pod
.
Spec
.
Containers
[
0
],
test
.
memoryCapacity
)
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