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
f33c2c11
Commit
f33c2c11
authored
Sep 26, 2018
by
hongjian.sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix scheduler crash when Prioritize Map function failed
parent
426ef9d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
BUILD
pkg/scheduler/core/BUILD
+1
-0
generic_scheduler.go
pkg/scheduler/core/generic_scheduler.go
+2
-1
generic_scheduler_test.go
pkg/scheduler/core/generic_scheduler_test.go
+31
-1
No files found.
pkg/scheduler/core/BUILD
View file @
f33c2c11
...
...
@@ -29,6 +29,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
],
...
...
pkg/scheduler/core/generic_scheduler.go
View file @
f33c2c11
...
...
@@ -650,6 +650,7 @@ func PrioritizeNodes(
results
[
i
]
=
make
(
schedulerapi
.
HostPriorityList
,
len
(
nodes
))
}
}
processNode
:=
func
(
index
int
)
{
nodeInfo
:=
nodeNameToInfo
[
nodes
[
index
]
.
Name
]
var
err
error
...
...
@@ -660,7 +661,7 @@ func PrioritizeNodes(
results
[
i
][
index
],
err
=
priorityConfigs
[
i
]
.
Map
(
pod
,
meta
,
nodeInfo
)
if
err
!=
nil
{
appendError
(
err
)
re
turn
re
sults
[
i
][
index
]
.
Host
=
nodes
[
index
]
.
Name
}
}
}
...
...
pkg/scheduler/core/generic_scheduler_test.go
View file @
f33c2c11
...
...
@@ -31,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/kubernetes/pkg/scheduler/algorithm"
...
...
@@ -44,7 +45,8 @@ import (
)
var
(
order
=
[]
string
{
"false"
,
"true"
,
"matches"
,
"nopods"
,
algorithmpredicates
.
MatchInterPodAffinityPred
}
errPrioritize
=
fmt
.
Errorf
(
"priority map encounters an error"
)
order
=
[]
string
{
"false"
,
"true"
,
"matches"
,
"nopods"
,
algorithmpredicates
.
MatchInterPodAffinityPred
}
)
func
falsePredicate
(
pod
*
v1
.
Pod
,
meta
algorithm
.
PredicateMetadata
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
[]
algorithm
.
PredicateFailureReason
,
error
)
{
...
...
@@ -111,6 +113,26 @@ func reverseNumericPriority(pod *v1.Pod, nodeNameToInfo map[string]*schedulercac
return
reverseResult
,
nil
}
func
trueMapPriority
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
schedulerapi
.
HostPriority
,
error
)
{
return
schedulerapi
.
HostPriority
{
Host
:
nodeInfo
.
Node
()
.
Name
,
Score
:
1
,
},
nil
}
func
falseMapPriority
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeInfo
*
schedulercache
.
NodeInfo
)
(
schedulerapi
.
HostPriority
,
error
)
{
return
schedulerapi
.
HostPriority
{},
errPrioritize
}
func
getNodeReducePriority
(
pod
*
v1
.
Pod
,
meta
interface
{},
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
result
schedulerapi
.
HostPriorityList
)
error
{
for
_
,
host
:=
range
result
{
if
host
.
Host
==
""
{
return
fmt
.
Errorf
(
"unexpected empty host name"
)
}
}
return
nil
}
func
makeNodeList
(
nodeNames
[]
string
)
[]
*
v1
.
Node
{
result
:=
make
([]
*
v1
.
Node
,
0
,
len
(
nodeNames
))
for
_
,
nodeName
:=
range
nodeNames
{
...
...
@@ -399,6 +421,14 @@ func TestGenericScheduler(t *testing.T) {
},
},
},
{
predicates
:
map
[
string
]
algorithm
.
FitPredicate
{
"true"
:
truePredicate
},
prioritizers
:
[]
algorithm
.
PriorityConfig
{{
Map
:
falseMapPriority
,
Weight
:
1
},
{
Map
:
trueMapPriority
,
Reduce
:
getNodeReducePriority
,
Weight
:
2
}},
nodes
:
[]
string
{
"2"
,
"1"
},
pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
name
:
"test error with priority map"
,
wErr
:
errors
.
NewAggregate
([]
error
{
errPrioritize
,
errPrioritize
}),
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
...
...
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