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
58c95c13
Commit
58c95c13
authored
Jul 07, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick returns in predicates
parent
acda24ae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
predicates.go
plugin/pkg/scheduler/algorithm/predicates/predicates.go
+12
-0
generic_scheduler.go
plugin/pkg/scheduler/generic_scheduler.go
+2
-1
No files found.
plugin/pkg/scheduler/algorithm/predicates/predicates.go
View file @
58c95c13
...
@@ -204,6 +204,12 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
...
@@ -204,6 +204,12 @@ func (c *MaxPDVolumeCountChecker) filterVolumes(volumes []api.Volume, namespace
}
}
func
(
c
*
MaxPDVolumeCountChecker
)
predicate
(
pod
*
api
.
Pod
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
func
(
c
*
MaxPDVolumeCountChecker
)
predicate
(
pod
*
api
.
Pod
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
// If a pod doesn't have any volume attached to it, the predicate will always be true.
// Thus we make a fast path for it, to avoid unnecessary computations in this case.
if
len
(
pod
.
Spec
.
Volumes
)
==
0
{
return
true
,
nil
}
newVolumes
:=
make
(
map
[
string
]
bool
)
newVolumes
:=
make
(
map
[
string
]
bool
)
if
err
:=
c
.
filterVolumes
(
pod
.
Spec
.
Volumes
,
pod
.
Namespace
,
newVolumes
);
err
!=
nil
{
if
err
:=
c
.
filterVolumes
(
pod
.
Spec
.
Volumes
,
pod
.
Namespace
,
newVolumes
);
err
!=
nil
{
return
false
,
err
return
false
,
err
...
@@ -302,6 +308,12 @@ func NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolum
...
@@ -302,6 +308,12 @@ func NewVolumeZonePredicate(pvInfo PersistentVolumeInfo, pvcInfo PersistentVolum
}
}
func
(
c
*
VolumeZoneChecker
)
predicate
(
pod
*
api
.
Pod
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
func
(
c
*
VolumeZoneChecker
)
predicate
(
pod
*
api
.
Pod
,
nodeInfo
*
schedulercache
.
NodeInfo
)
(
bool
,
error
)
{
// If a pod doesn't have any volume attached to it, the predicate will always be true.
// Thus we make a fast path for it, to avoid unnecessary computations in this case.
if
len
(
pod
.
Spec
.
Volumes
)
==
0
{
return
true
,
nil
}
node
:=
nodeInfo
.
Node
()
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
if
node
==
nil
{
return
false
,
fmt
.
Errorf
(
"node not found"
)
return
false
,
fmt
.
Errorf
(
"node not found"
)
...
...
plugin/pkg/scheduler/generic_scheduler.go
View file @
58c95c13
...
@@ -135,7 +135,8 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
...
@@ -135,7 +135,8 @@ func (g *genericScheduler) selectHost(priorityList schedulerapi.HostPriorityList
// Filters the nodes to find the ones that fit based on the given predicate functions
// Filters the nodes to find the ones that fit based on the given predicate functions
// Each node is passed through the predicate functions to determine if it is a fit
// Each node is passed through the predicate functions to determine if it is a fit
func
findNodesThatFit
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
predicateFuncs
map
[
string
]
algorithm
.
FitPredicate
,
nodes
api
.
NodeList
,
extenders
[]
algorithm
.
SchedulerExtender
)
(
api
.
NodeList
,
FailedPredicateMap
,
error
)
{
func
findNodesThatFit
(
pod
*
api
.
Pod
,
nodeNameToInfo
map
[
string
]
*
schedulercache
.
NodeInfo
,
predicateFuncs
map
[
string
]
algorithm
.
FitPredicate
,
nodes
api
.
NodeList
,
extenders
[]
algorithm
.
SchedulerExtender
)
(
api
.
NodeList
,
FailedPredicateMap
,
error
)
{
filtered
:=
[]
api
.
Node
{}
// Create filtered list with enough space to avoid growing it.
filtered
:=
make
([]
api
.
Node
,
0
,
len
(
nodes
.
Items
))
failedPredicateMap
:=
FailedPredicateMap
{}
failedPredicateMap
:=
FailedPredicateMap
{}
if
len
(
predicateFuncs
)
==
0
{
if
len
(
predicateFuncs
)
==
0
{
...
...
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