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
9cdc4ae0
Commit
9cdc4ae0
authored
Jan 05, 2017
by
jayunit100
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update FitError as a message component into the PodConditionUpdater.
parent
de59ede6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+4
-7
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+18
-0
scheduler.go
plugin/pkg/scheduler/scheduler.go
+4
-3
No files found.
plugin/pkg/scheduler/generic_scheduler.go
View file @
9cdc4ae0
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
scheduler
import
(
"bytes"
"fmt"
"sort"
"strings"
...
...
@@ -45,10 +44,10 @@ type FitError struct {
var
ErrNoNodesAvailable
=
fmt
.
Errorf
(
"no nodes available to schedule pods"
)
const
NoNodeAvailableMsg
=
"No nodes are available that match all of the following predicates:"
// Error returns detailed information of why the pod failed to fit on each node
func
(
f
*
FitError
)
Error
()
string
{
var
buf
bytes
.
Buffer
buf
.
WriteString
(
fmt
.
Sprintf
(
"pod (%s) failed to fit in any node
\n
"
,
f
.
Pod
.
Name
))
reasons
:=
make
(
map
[
string
]
int
)
for
_
,
predicates
:=
range
f
.
FailedPredicates
{
for
_
,
pred
:=
range
predicates
{
...
...
@@ -64,10 +63,8 @@ func (f *FitError) Error() string {
sort
.
Strings
(
reasonStrings
)
return
reasonStrings
}
reasonMsg
:=
fmt
.
Sprintf
(
"fit failure summary on nodes : %v"
,
strings
.
Join
(
sortReasonsHistogram
(),
", "
))
buf
.
WriteString
(
reasonMsg
)
return
buf
.
String
()
reasonMsg
:=
fmt
.
Sprintf
(
NoNodeAvailableMsg
+
": %v."
,
strings
.
Join
(
sortReasonsHistogram
(),
", "
))
return
reasonMsg
}
type
genericScheduler
struct
{
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
9cdc4ae0
...
...
@@ -21,6 +21,7 @@ import (
"math"
"reflect"
"strconv"
"strings"
"testing"
"time"
...
...
@@ -397,6 +398,23 @@ func makeNode(node string, milliCPU, memory int64) *v1.Node {
}
}
func
TestHumanReadableFitError
(
t
*
testing
.
T
)
{
error
:=
&
FitError
{
Pod
:
&
v1
.
Pod
{
ObjectMeta
:
v1
.
ObjectMeta
{
Name
:
"2"
}},
FailedPredicates
:
FailedPredicateMap
{
"1"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderMemoryPressure
},
"2"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
"3"
:
[]
algorithm
.
PredicateFailureReason
{
algorithmpredicates
.
ErrNodeUnderDiskPressure
},
},
}
if
strings
.
Contains
(
error
.
Error
(),
"No nodes are available that match all of the following predicates"
)
{
if
strings
.
Contains
(
error
.
Error
(),
"NodeUnderDiskPressure (2)"
)
&&
strings
.
Contains
(
error
.
Error
(),
"NodeUnderMemoryPressure (1)"
)
{
return
}
}
t
.
Errorf
(
"Error message doesn't have all the information content: ["
+
error
.
Error
()
+
"]"
)
}
// The point of this test is to show that you:
// - get the same priority for a zero-request pod as for a pod with the defaults requests,
// both when the zero-request pod is already on the machine and when the zero-request pod
...
...
plugin/pkg/scheduler/scheduler.go
View file @
9cdc4ae0
...
...
@@ -98,9 +98,10 @@ func (s *Scheduler) scheduleOne() {
s
.
config
.
Error
(
pod
,
err
)
s
.
config
.
Recorder
.
Eventf
(
pod
,
v1
.
EventTypeWarning
,
"FailedScheduling"
,
"%v"
,
err
)
s
.
config
.
PodConditionUpdater
.
Update
(
pod
,
&
v1
.
PodCondition
{
Type
:
v1
.
PodScheduled
,
Status
:
v1
.
ConditionFalse
,
Reason
:
v1
.
PodReasonUnschedulable
,
Type
:
v1
.
PodScheduled
,
Status
:
v1
.
ConditionFalse
,
Reason
:
v1
.
PodReasonUnschedulable
,
Message
:
err
.
Error
(),
})
return
}
...
...
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