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
7f3c4ac1
Commit
7f3c4ac1
authored
Oct 06, 2017
by
Gavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clarify pridicates message when no nodes available
fix space address comment
parent
5cc95fbf
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
generic_scheduler.go
plugin/pkg/scheduler/core/generic_scheduler.go
+5
-3
generic_scheduler_test.go
plugin/pkg/scheduler/core/generic_scheduler_test.go
+8
-4
scheduler_test.go
plugin/pkg/scheduler/scheduler_test.go
+2
-0
No files found.
plugin/pkg/scheduler/core/generic_scheduler.go
View file @
7f3c4ac1
...
@@ -42,13 +42,14 @@ type FailedPredicateMap map[string][]algorithm.PredicateFailureReason
...
@@ -42,13 +42,14 @@ type FailedPredicateMap map[string][]algorithm.PredicateFailureReason
type
FitError
struct
{
type
FitError
struct
{
Pod
*
v1
.
Pod
Pod
*
v1
.
Pod
NumAllNodes
int
FailedPredicates
FailedPredicateMap
FailedPredicates
FailedPredicateMap
}
}
var
ErrNoNodesAvailable
=
fmt
.
Errorf
(
"no nodes available to schedule pods"
)
var
ErrNoNodesAvailable
=
fmt
.
Errorf
(
"no nodes available to schedule pods"
)
const
(
const
(
NoNodeAvailableMsg
=
"
No nodes are available that match all of the predicates
"
NoNodeAvailableMsg
=
"
0/%v nodes are available
"
// NominatedNodeAnnotationKey is used to annotate a pod that has preempted other pods.
// NominatedNodeAnnotationKey is used to annotate a pod that has preempted other pods.
// The scheduler uses the annotation to find that the pod shouldn't preempt more pods
// The scheduler uses the annotation to find that the pod shouldn't preempt more pods
// when it gets to the head of scheduling queue again.
// when it gets to the head of scheduling queue again.
...
@@ -68,12 +69,12 @@ func (f *FitError) Error() string {
...
@@ -68,12 +69,12 @@ func (f *FitError) Error() string {
sortReasonsHistogram
:=
func
()
[]
string
{
sortReasonsHistogram
:=
func
()
[]
string
{
reasonStrings
:=
[]
string
{}
reasonStrings
:=
[]
string
{}
for
k
,
v
:=
range
reasons
{
for
k
,
v
:=
range
reasons
{
reasonStrings
=
append
(
reasonStrings
,
fmt
.
Sprintf
(
"%v
(%v)"
,
k
,
v
))
reasonStrings
=
append
(
reasonStrings
,
fmt
.
Sprintf
(
"%v
%v"
,
v
,
k
))
}
}
sort
.
Strings
(
reasonStrings
)
sort
.
Strings
(
reasonStrings
)
return
reasonStrings
return
reasonStrings
}
}
reasonMsg
:=
fmt
.
Sprintf
(
NoNodeAvailableMsg
+
": %v."
,
strings
.
Join
(
sortReasonsHistogram
(),
", "
))
reasonMsg
:=
fmt
.
Sprintf
(
NoNodeAvailableMsg
+
": %v."
,
f
.
NumAllNodes
,
strings
.
Join
(
sortReasonsHistogram
(),
", "
))
return
reasonMsg
return
reasonMsg
}
}
...
@@ -122,6 +123,7 @@ func (g *genericScheduler) Schedule(pod *v1.Pod, nodeLister algorithm.NodeLister
...
@@ -122,6 +123,7 @@ func (g *genericScheduler) Schedule(pod *v1.Pod, nodeLister algorithm.NodeLister
if
len
(
filteredNodes
)
==
0
{
if
len
(
filteredNodes
)
==
0
{
return
""
,
&
FitError
{
return
""
,
&
FitError
{
Pod
:
pod
,
Pod
:
pod
,
NumAllNodes
:
len
(
nodes
),
FailedPredicates
:
failedPredicateMap
,
FailedPredicates
:
failedPredicateMap
,
}
}
}
}
...
...
plugin/pkg/scheduler/core/generic_scheduler_test.go
View file @
7f3c4ac1
...
@@ -201,6 +201,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -201,6 +201,7 @@ func TestGenericScheduler(t *testing.T) {
name
:
"test 1"
,
name
:
"test 1"
,
wErr
:
&
FitError
{
wErr
:
&
FitError
{
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
NumAllNodes
:
2
,
FailedPredicates
:
FailedPredicateMap
{
FailedPredicates
:
FailedPredicateMap
{
"machine1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"machine1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"machine2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"machine2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
...
@@ -261,6 +262,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -261,6 +262,7 @@ func TestGenericScheduler(t *testing.T) {
name
:
"test 7"
,
name
:
"test 7"
,
wErr
:
&
FitError
{
wErr
:
&
FitError
{
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
NumAllNodes
:
3
,
FailedPredicates
:
FailedPredicateMap
{
FailedPredicates
:
FailedPredicateMap
{
"3"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"3"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
...
@@ -291,6 +293,7 @@ func TestGenericScheduler(t *testing.T) {
...
@@ -291,6 +293,7 @@ func TestGenericScheduler(t *testing.T) {
name
:
"test 8"
,
name
:
"test 8"
,
wErr
:
&
FitError
{
wErr
:
&
FitError
{
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
NumAllNodes
:
2
,
FailedPredicates
:
FailedPredicateMap
{
FailedPredicates
:
FailedPredicateMap
{
"1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrFakePredicate
},
...
@@ -407,14 +410,15 @@ func makeNode(node string, milliCPU, memory int64) *v1.Node {
...
@@ -407,14 +410,15 @@ func makeNode(node string, milliCPU, memory int64) *v1.Node {
func
TestHumanReadableFitError
(
t
*
testing
.
T
)
{
func
TestHumanReadableFitError
(
t
*
testing
.
T
)
{
err
:=
&
FitError
{
err
:=
&
FitError
{
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"2"
}},
NumAllNodes
:
3
,
FailedPredicates
:
FailedPredicateMap
{
FailedPredicates
:
FailedPredicateMap
{
"1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderMemoryPressure
},
"1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderMemoryPressure
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
"3"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
"3"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
},
},
}
}
if
strings
.
Contains
(
err
.
Error
(),
NoNodeAvailableMsg
)
{
if
strings
.
Contains
(
err
.
Error
(),
"0/3 nodes are available"
)
{
if
strings
.
Contains
(
err
.
Error
(),
"
NodeUnderDiskPressure (2)"
)
&&
strings
.
Contains
(
err
.
Error
(),
"NodeUnderMemoryPressure (1)
"
)
{
if
strings
.
Contains
(
err
.
Error
(),
"
2 NodeUnderDiskPressure"
)
&&
strings
.
Contains
(
err
.
Error
(),
"1 NodeUnderMemoryPressure
"
)
{
return
return
}
}
}
}
...
@@ -1180,7 +1184,7 @@ func TestPreempt(t *testing.T) {
...
@@ -1180,7 +1184,7 @@ func TestPreempt(t *testing.T) {
scheduler
:=
NewGenericScheduler
(
scheduler
:=
NewGenericScheduler
(
cache
,
nil
,
map
[
string
]
algorithm
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
algorithm
.
EmptyPredicateMetadataProducer
,
[]
algorithm
.
PriorityConfig
{{
Function
:
numericPriority
,
Weight
:
1
}},
algorithm
.
EmptyMetadataProducer
,
extenders
)
cache
,
nil
,
map
[
string
]
algorithm
.
FitPredicate
{
"matches"
:
algorithmpredicates
.
PodFitsResources
},
algorithm
.
EmptyPredicateMetadataProducer
,
[]
algorithm
.
PriorityConfig
{{
Function
:
numericPriority
,
Weight
:
1
}},
algorithm
.
EmptyMetadataProducer
,
extenders
)
// Call Preempt and check the expected results.
// Call Preempt and check the expected results.
node
,
victims
,
err
:=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
test
.
pod
,
failedPredMap
}))
node
,
victims
,
err
:=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
Pod
:
test
.
pod
,
FailedPredicates
:
failedPredMap
}))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"test [%v]: unexpected error in preemption: %v"
,
test
.
name
,
err
)
t
.
Errorf
(
"test [%v]: unexpected error in preemption: %v"
,
test
.
name
,
err
)
}
}
...
@@ -1208,7 +1212,7 @@ func TestPreempt(t *testing.T) {
...
@@ -1208,7 +1212,7 @@ func TestPreempt(t *testing.T) {
test
.
pod
.
Annotations
[
NominatedNodeAnnotationKey
]
=
node
.
Name
test
.
pod
.
Annotations
[
NominatedNodeAnnotationKey
]
=
node
.
Name
}
}
// Call preempt again and make sure it doesn't preempt any more pods.
// Call preempt again and make sure it doesn't preempt any more pods.
node
,
victims
,
err
=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
test
.
pod
,
failedPredMap
}))
node
,
victims
,
err
=
scheduler
.
Preempt
(
test
.
pod
,
schedulertesting
.
FakeNodeLister
(
makeNodeList
(
nodeNames
)),
error
(
&
FitError
{
Pod
:
test
.
pod
,
FailedPredicates
:
failedPredMap
}))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Errorf
(
"test [%v]: unexpected error in preemption: %v"
,
test
.
name
,
err
)
t
.
Errorf
(
"test [%v]: unexpected error in preemption: %v"
,
test
.
name
,
err
)
}
}
...
...
plugin/pkg/scheduler/scheduler_test.go
View file @
7f3c4ac1
...
@@ -300,6 +300,7 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
...
@@ -300,6 +300,7 @@ func TestSchedulerNoPhantomPodAfterDelete(t *testing.T) {
case
err
:=
<-
errChan
:
case
err
:=
<-
errChan
:
expectErr
:=
&
core
.
FitError
{
expectErr
:=
&
core
.
FitError
{
Pod
:
secondPod
,
Pod
:
secondPod
,
NumAllNodes
:
1
,
FailedPredicates
:
core
.
FailedPredicateMap
{
node
.
Name
:
[]
algorithm
.
PredicateFailureReason
{
predicates
.
ErrPodNotFitsHostPorts
}},
FailedPredicates
:
core
.
FailedPredicateMap
{
node
.
Name
:
[]
algorithm
.
PredicateFailureReason
{
predicates
.
ErrPodNotFitsHostPorts
}},
}
}
if
!
reflect
.
DeepEqual
(
expectErr
,
err
)
{
if
!
reflect
.
DeepEqual
(
expectErr
,
err
)
{
...
@@ -484,6 +485,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
...
@@ -484,6 +485,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {
case
err
:=
<-
errChan
:
case
err
:=
<-
errChan
:
expectErr
:=
&
core
.
FitError
{
expectErr
:=
&
core
.
FitError
{
Pod
:
podWithTooBigResourceRequests
,
Pod
:
podWithTooBigResourceRequests
,
NumAllNodes
:
len
(
nodes
),
FailedPredicates
:
failedPredicatesMap
,
FailedPredicates
:
failedPredicatesMap
,
}
}
if
len
(
fmt
.
Sprint
(
expectErr
))
>
150
{
if
len
(
fmt
.
Sprint
(
expectErr
))
>
150
{
...
...
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