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
545bf184
Commit
545bf184
authored
Apr 14, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify FailedPredicateMap
parent
b02f1bf6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
16 deletions
+11
-16
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+5
-10
generic_scheduler_test.go
plugin/pkg/scheduler/generic_scheduler_test.go
+6
-6
No files found.
plugin/pkg/scheduler/generic_scheduler.go
View file @
545bf184
...
...
@@ -21,20 +21,18 @@ import (
"fmt"
"math/rand"
"sort"
"strings"
"sync"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm"
"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm/predicates"
schedulerapi
"k8s.io/kubernetes/plugin/pkg/scheduler/api"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
)
type
FailedPredicateMap
map
[
string
]
s
ets
.
S
tring
type
FailedPredicateMap
map
[
string
]
string
type
FitError
struct
{
Pod
*
api
.
Pod
...
...
@@ -47,8 +45,8 @@ var ErrNoNodesAvailable = fmt.Errorf("no nodes available to schedule pods")
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
))
for
node
,
predicate
List
:=
range
f
.
FailedPredicates
{
reason
:=
fmt
.
Sprintf
(
"fit failure on node (%s): %s
\n
"
,
node
,
strings
.
Join
(
predicateList
.
List
(),
","
)
)
for
node
,
predicate
:=
range
f
.
FailedPredicates
{
reason
:=
fmt
.
Sprintf
(
"fit failure on node (%s): %s
\n
"
,
node
,
predicate
)
buf
.
WriteString
(
reason
)
}
return
buf
.
String
()
...
...
@@ -151,15 +149,12 @@ func findNodesThatFit(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.No
}
if
!
fit
{
fits
=
false
if
_
,
found
:=
failedPredicateMap
[
node
.
Name
];
!
found
{
failedPredicateMap
[
node
.
Name
]
=
sets
.
String
{}
}
if
re
,
ok
:=
err
.
(
*
predicates
.
InsufficientResourceError
);
ok
{
failedPredicateMap
[
node
.
Name
]
.
Insert
(
fmt
.
Sprintf
(
"Insufficient %s"
,
re
.
ResourceName
)
)
failedPredicateMap
[
node
.
Name
]
=
fmt
.
Sprintf
(
"Insufficient %s"
,
re
.
ResourceName
)
break
}
if
re
,
ok
:=
err
.
(
*
predicates
.
PredicateFailureError
);
ok
{
failedPredicateMap
[
node
.
Name
]
.
Insert
(
re
.
PredicateName
)
failedPredicateMap
[
node
.
Name
]
=
re
.
PredicateName
break
}
else
{
err
:=
fmt
.
Errorf
(
"SchedulerPredicates failed due to %v, which is unexpected."
,
err
)
...
...
plugin/pkg/scheduler/generic_scheduler_test.go
View file @
545bf184
...
...
@@ -309,12 +309,12 @@ func TestFindFitAllError(t *testing.T) {
}
for
_
,
node
:=
range
nodes
{
failure
s
,
found
:=
predicateMap
[
node
]
failure
,
found
:=
predicateMap
[
node
]
if
!
found
{
t
.
Errorf
(
"failed to find node: %s in %v"
,
node
,
predicateMap
)
}
if
len
(
failures
)
!=
1
||
!
failures
.
Has
(
"false"
)
{
t
.
Errorf
(
"unexpected failures: %v"
,
failure
s
)
if
failure
!=
"false"
{
t
.
Errorf
(
"unexpected failures: %v"
,
failure
)
}
}
}
...
...
@@ -342,12 +342,12 @@ func TestFindFitSomeError(t *testing.T) {
if
node
==
pod
.
Name
{
continue
}
failure
s
,
found
:=
predicateMap
[
node
]
failure
,
found
:=
predicateMap
[
node
]
if
!
found
{
t
.
Errorf
(
"failed to find node: %s in %v"
,
node
,
predicateMap
)
}
if
len
(
failures
)
!=
1
||
!
failures
.
Has
(
"false"
)
{
t
.
Errorf
(
"unexpected failures: %v"
,
failure
s
)
if
failure
!=
"false"
{
t
.
Errorf
(
"unexpected failures: %v"
,
failure
)
}
}
}
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