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
c2d25e08
Commit
c2d25e08
authored
Jan 16, 2019
by
Yecheng Fu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skip if pod does not have claims.
parent
7fe97886
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
scheduler_binder.go
pkg/controller/volume/persistentvolume/scheduler_binder.go
+30
-16
No files found.
pkg/controller/volume/persistentvolume/scheduler_binder.go
View file @
c2d25e08
...
...
@@ -142,10 +142,40 @@ func (b *volumeBinder) GetBindingsCache() PodBindingCache {
return
b
.
podBindingCache
}
func
podHasClaims
(
pod
*
v1
.
Pod
)
bool
{
for
_
,
vol
:=
range
pod
.
Spec
.
Volumes
{
if
vol
.
PersistentVolumeClaim
!=
nil
{
return
true
}
}
return
false
}
// FindPodVolumes caches the matching PVs and PVCs to provision per node in podBindingCache.
// This method intentionally takes in a *v1.Node object instead of using volumebinder.nodeInformer.
// That's necessary because some operations will need to pass in to the predicate fake node objects.
func
(
b
*
volumeBinder
)
FindPodVolumes
(
pod
*
v1
.
Pod
,
node
*
v1
.
Node
)
(
unboundVolumesSatisfied
,
boundVolumesSatisfied
bool
,
err
error
)
{
podName
:=
getPodName
(
pod
)
// Warning: Below log needs high verbosity as it can be printed several times (#60933).
klog
.
V
(
5
)
.
Infof
(
"FindPodVolumes for pod %q, node %q"
,
podName
,
node
.
Name
)
// Initialize to true for pods that don't have volumes
unboundVolumesSatisfied
=
true
boundVolumesSatisfied
=
true
start
:=
time
.
Now
()
defer
func
()
{
VolumeSchedulingStageLatency
.
WithLabelValues
(
"predicate"
)
.
Observe
(
time
.
Since
(
start
)
.
Seconds
())
if
err
!=
nil
{
VolumeSchedulingStageFailed
.
WithLabelValues
(
"predicate"
)
.
Inc
()
}
}()
if
!
podHasClaims
(
pod
)
{
// Fast path
return
unboundVolumesSatisfied
,
boundVolumesSatisfied
,
nil
}
var
(
matchedClaims
[]
*
bindingInfo
provisionedClaims
[]
*
v1
.
PersistentVolumeClaim
...
...
@@ -164,22 +194,6 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
b
.
podBindingCache
.
UpdateBindings
(
pod
,
node
.
Name
,
matchedClaims
,
provisionedClaims
)
}()
podName
:=
getPodName
(
pod
)
// Warning: Below log needs high verbosity as it can be printed several times (#60933).
klog
.
V
(
5
)
.
Infof
(
"FindPodVolumes for pod %q, node %q"
,
podName
,
node
.
Name
)
// Initialize to true for pods that don't have volumes
unboundVolumesSatisfied
=
true
boundVolumesSatisfied
=
true
start
:=
time
.
Now
()
defer
func
()
{
VolumeSchedulingStageLatency
.
WithLabelValues
(
"predicate"
)
.
Observe
(
time
.
Since
(
start
)
.
Seconds
())
if
err
!=
nil
{
VolumeSchedulingStageFailed
.
WithLabelValues
(
"predicate"
)
.
Inc
()
}
}()
// The pod's volumes need to be processed in one call to avoid the race condition where
// volumes can get bound/provisioned in between calls.
boundClaims
,
claimsToBind
,
unboundClaimsImmediate
,
err
:=
b
.
getPodVolumes
(
pod
)
...
...
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