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
1b8435d5
Unverified
Commit
1b8435d5
authored
Feb 02, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73652 from bsalamat/fast_volume_checker
Short circuit volume checker if the pod is not requesting any volumes
parents
8de38858
a20a2433
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
4 deletions
+23
-4
predicates.go
pkg/scheduler/algorithm/predicates/predicates.go
+14
-0
scheduler_test.go
pkg/scheduler/scheduler_test.go
+9
-4
No files found.
pkg/scheduler/algorithm/predicates/predicates.go
View file @
1b8435d5
...
...
@@ -1642,7 +1642,21 @@ func NewVolumeBindingPredicate(binder *volumebinder.VolumeBinder) FitPredicate {
return
c
.
predicate
}
func
podHasPVCs
(
pod
*
v1
.
Pod
)
bool
{
for
_
,
vol
:=
range
pod
.
Spec
.
Volumes
{
if
vol
.
PersistentVolumeClaim
!=
nil
{
return
true
}
}
return
false
}
func
(
c
*
VolumeBindingChecker
)
predicate
(
pod
*
v1
.
Pod
,
meta
PredicateMetadata
,
nodeInfo
*
schedulernodeinfo
.
NodeInfo
)
(
bool
,
[]
PredicateFailureReason
,
error
)
{
// If pod does not request any PVC, we don't need to do anything.
if
!
podHasPVCs
(
pod
)
{
return
true
,
nil
,
nil
}
node
:=
nodeInfo
.
Node
()
if
node
==
nil
{
return
false
,
nil
,
fmt
.
Errorf
(
"node not found"
)
...
...
pkg/scheduler/scheduler_test.go
View file @
1b8435d5
...
...
@@ -736,10 +736,15 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
func
setupTestSchedulerWithVolumeBinding
(
fakeVolumeBinder
*
volumebinder
.
VolumeBinder
,
stop
<-
chan
struct
{},
broadcaster
record
.
EventBroadcaster
)
(
*
Scheduler
,
chan
*
v1
.
Binding
,
chan
error
)
{
testNode
:=
v1
.
Node
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"machine1"
,
UID
:
types
.
UID
(
"machine1"
)}}
queuedPodStore
:=
clientcache
.
NewFIFO
(
clientcache
.
MetaNamespaceKeyFunc
)
queuedPodStore
.
Add
(
podWithID
(
"foo"
,
""
))
pod
:=
podWithID
(
"foo"
,
""
)
pod
.
Namespace
=
"foo-ns"
pod
.
Spec
.
Volumes
=
append
(
pod
.
Spec
.
Volumes
,
v1
.
Volume
{
Name
:
"testVol"
,
VolumeSource
:
v1
.
VolumeSource
{
PersistentVolumeClaim
:
&
v1
.
PersistentVolumeClaimVolumeSource
{
ClaimName
:
"testPVC"
}}})
queuedPodStore
.
Add
(
pod
)
scache
:=
schedulerinternalcache
.
New
(
10
*
time
.
Minute
,
stop
)
scache
.
AddNode
(
&
testNode
)
client
:=
clientsetfake
.
NewSimpleClientset
(
&
testNode
)
testPVC
:=
v1
.
PersistentVolumeClaim
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"testPVC"
,
Namespace
:
pod
.
Namespace
,
UID
:
types
.
UID
(
"testPVC"
)}}
client
:=
clientsetfake
.
NewSimpleClientset
(
&
testNode
,
&
testPVC
)
informerFactory
:=
informers
.
NewSharedInformerFactory
(
client
,
0
)
predicateMap
:=
map
[
string
]
predicates
.
FitPredicate
{
...
...
@@ -790,7 +795,7 @@ func TestSchedulerWithVolumeBinding(t *testing.T) {
FindBoundSatsified
:
true
,
},
expectAssumeCalled
:
true
,
expectPodBind
:
&
v1
.
Binding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
UID
:
types
.
UID
(
"foo"
)},
Target
:
v1
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
"machine1"
}},
expectPodBind
:
&
v1
.
Binding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
"foo-ns"
,
UID
:
types
.
UID
(
"foo"
)},
Target
:
v1
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
"machine1"
}},
eventReason
:
"Scheduled"
,
},
{
...
...
@@ -829,7 +834,7 @@ func TestSchedulerWithVolumeBinding(t *testing.T) {
},
expectAssumeCalled
:
true
,
expectBindCalled
:
true
,
expectPodBind
:
&
v1
.
Binding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
UID
:
types
.
UID
(
"foo"
)},
Target
:
v1
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
"machine1"
}},
expectPodBind
:
&
v1
.
Binding
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"foo"
,
Namespace
:
"foo-ns"
,
UID
:
types
.
UID
(
"foo"
)},
Target
:
v1
.
ObjectReference
{
Kind
:
"Node"
,
Name
:
"machine1"
}},
eventReason
:
"Scheduled"
,
},
{
...
...
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