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
042b83ba
Commit
042b83ba
authored
Mar 20, 2019
by
Jun Gong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pick pods for preemption based on StartTime of pods when priorities are equal
parent
e7eb742c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
7 deletions
+26
-7
extender_test.go
pkg/scheduler/core/extender_test.go
+1
-1
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+1
-1
generic_scheduler_test.go
pkg/scheduler/core/generic_scheduler_test.go
+13
-0
utils.go
pkg/scheduler/util/utils.go
+11
-5
No files found.
pkg/scheduler/core/extender_test.go
View file @
042b83ba
...
@@ -197,7 +197,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender(
...
@@ -197,7 +197,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender(
// and get cached node info by given node name.
// and get cached node info by given node name.
nodeInfoCopy
:=
f
.
cachedNodeNameToInfo
[
node
.
GetName
()]
.
Clone
()
nodeInfoCopy
:=
f
.
cachedNodeNameToInfo
[
node
.
GetName
()]
.
Clone
()
potentialVictims
:=
util
.
SortableList
{
CompFunc
:
util
.
HigherPriority
Pod
}
potentialVictims
:=
util
.
SortableList
{
CompFunc
:
util
.
MoreImportant
Pod
}
removePod
:=
func
(
rp
*
v1
.
Pod
)
{
removePod
:=
func
(
rp
*
v1
.
Pod
)
{
nodeInfoCopy
.
RemovePod
(
rp
)
nodeInfoCopy
.
RemovePod
(
rp
)
...
...
pkg/scheduler/core/generic_scheduler.go
View file @
042b83ba
...
@@ -1046,7 +1046,7 @@ func selectVictimsOnNode(
...
@@ -1046,7 +1046,7 @@ func selectVictimsOnNode(
if
nodeInfo
==
nil
{
if
nodeInfo
==
nil
{
return
nil
,
0
,
false
return
nil
,
0
,
false
}
}
potentialVictims
:=
util
.
SortableList
{
CompFunc
:
util
.
HigherPriority
Pod
}
potentialVictims
:=
util
.
SortableList
{
CompFunc
:
util
.
MoreImportant
Pod
}
nodeInfoCopy
:=
nodeInfo
.
Clone
()
nodeInfoCopy
:=
nodeInfo
.
Clone
()
removePod
:=
func
(
rp
*
v1
.
Pod
)
{
removePod
:=
func
(
rp
*
v1
.
Pod
)
{
...
...
pkg/scheduler/core/generic_scheduler_test.go
View file @
042b83ba
...
@@ -947,6 +947,19 @@ func TestSelectNodesForPreemption(t *testing.T) {
...
@@ -947,6 +947,19 @@ func TestSelectNodesForPreemption(t *testing.T) {
expected
:
map
[
string
]
map
[
string
]
bool
{
"machine1"
:
{
"b"
:
true
,
"c"
:
true
}},
expected
:
map
[
string
]
map
[
string
]
bool
{
"machine1"
:
{
"b"
:
true
,
"c"
:
true
}},
},
},
{
{
name
:
"mixed priority pods are preempted, pick later StartTime one when priorities are equal"
,
predicates
:
map
[
string
]
algorithmpredicates
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"machine1"
,
UID
:
types
.
UID
(
"machine1"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
largeContainers
,
Priority
:
&
highPriority
}},
pods
:
[]
*
v1
.
Pod
{
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"a"
,
UID
:
types
.
UID
(
"a"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
smallContainers
,
Priority
:
&
lowPriority
,
NodeName
:
"machine1"
},
Status
:
v1
.
PodStatus
{
StartTime
:
&
startTime20190107
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"b"
,
UID
:
types
.
UID
(
"b"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
smallContainers
,
Priority
:
&
lowPriority
,
NodeName
:
"machine1"
},
Status
:
v1
.
PodStatus
{
StartTime
:
&
startTime20190106
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"c"
,
UID
:
types
.
UID
(
"c"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
mediumContainers
,
Priority
:
&
midPriority
,
NodeName
:
"machine1"
},
Status
:
v1
.
PodStatus
{
StartTime
:
&
startTime20190105
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"d"
,
UID
:
types
.
UID
(
"d"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
smallContainers
,
Priority
:
&
highPriority
,
NodeName
:
"machine1"
},
Status
:
v1
.
PodStatus
{
StartTime
:
&
startTime20190104
}},
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"e"
,
UID
:
types
.
UID
(
"e"
)},
Spec
:
v1
.
PodSpec
{
Containers
:
largeContainers
,
Priority
:
&
highPriority
,
NodeName
:
"machine2"
},
Status
:
v1
.
PodStatus
{
StartTime
:
&
startTime20190103
}}},
expected
:
map
[
string
]
map
[
string
]
bool
{
"machine1"
:
{
"a"
:
true
,
"c"
:
true
}},
},
{
name
:
"pod with anti-affinity is preempted"
,
name
:
"pod with anti-affinity is preempted"
,
predicates
:
map
[
string
]
algorithmpredicates
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
predicates
:
map
[
string
]
algorithmpredicates
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
nodes
:
[]
string
{
"machine1"
,
"machine2"
},
...
...
pkg/scheduler/util/utils.go
View file @
042b83ba
...
@@ -134,9 +134,15 @@ func (l *SortableList) Sort() {
...
@@ -134,9 +134,15 @@ func (l *SortableList) Sort() {
sort
.
Sort
(
l
)
sort
.
Sort
(
l
)
}
}
// HigherPriorityPod return true when priority of the first pod is higher than
// MoreImportantPod return true when priority of the first pod is higher than
// the second one. It takes arguments of the type "interface{}" to be used with
// the second one. If two pods' priorities are equal, compare their StartTime.
// SortableList, but expects those arguments to be *v1.Pod.
// It takes arguments of the type "interface{}" to be used with SortableList,
func
HigherPriorityPod
(
pod1
,
pod2
interface
{})
bool
{
// but expects those arguments to be *v1.Pod.
return
GetPodPriority
(
pod1
.
(
*
v1
.
Pod
))
>
GetPodPriority
(
pod2
.
(
*
v1
.
Pod
))
func
MoreImportantPod
(
pod1
,
pod2
interface
{})
bool
{
p1
:=
GetPodPriority
(
pod1
.
(
*
v1
.
Pod
))
p2
:=
GetPodPriority
(
pod2
.
(
*
v1
.
Pod
))
if
p1
!=
p2
{
return
p1
>
p2
}
return
GetPodStartTime
(
pod1
.
(
*
v1
.
Pod
))
.
Before
(
GetPodStartTime
(
pod2
.
(
*
v1
.
Pod
)))
}
}
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