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
22c67bb1
Unverified
Commit
22c67bb1
authored
Apr 19, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76333 from cwdsuzhou/clean_up_scheduler_binder
Rename some varibles and clean up codes in scheduler_binder.go
parents
746fea04
1c5efe7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
scheduler_binder.go
pkg/controller/volume/persistentvolume/scheduler_binder.go
+12
-13
No files found.
pkg/controller/volume/persistentvolume/scheduler_binder.go
View file @
22c67bb1
...
...
@@ -160,26 +160,26 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
}()
var
(
matched
Claims
[]
*
bindingInfo
matched
Bindings
[]
*
bindingInfo
provisionedClaims
[]
*
v1
.
PersistentVolumeClaim
)
defer
func
()
{
// We recreate bindings for each new schedule loop.
if
len
(
matched
Claim
s
)
==
0
&&
len
(
provisionedClaims
)
==
0
{
if
len
(
matched
Binding
s
)
==
0
&&
len
(
provisionedClaims
)
==
0
{
// Clear cache if no claims to bind or provision for this node.
b
.
podBindingCache
.
ClearBindings
(
pod
,
node
.
Name
)
return
}
// Although we do not distinguish nil from empty in this function, for
// easier testing, we normalize empty to nil.
if
len
(
matched
Claim
s
)
==
0
{
matched
Claim
s
=
nil
if
len
(
matched
Binding
s
)
==
0
{
matched
Binding
s
=
nil
}
if
len
(
provisionedClaims
)
==
0
{
provisionedClaims
=
nil
}
// Mark cache with all matched and provisioned claims for this node
b
.
podBindingCache
.
UpdateBindings
(
pod
,
node
.
Name
,
matched
Claim
s
,
provisionedClaims
)
b
.
podBindingCache
.
UpdateBindings
(
pod
,
node
.
Name
,
matched
Binding
s
,
provisionedClaims
)
}()
// The pod's volumes need to be processed in one call to avoid the race condition where
...
...
@@ -225,7 +225,7 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
// Find matching volumes
if
len
(
claimsToFindMatching
)
>
0
{
var
unboundClaims
[]
*
v1
.
PersistentVolumeClaim
unboundVolumesSatisfied
,
matched
Claim
s
,
unboundClaims
,
err
=
b
.
findMatchingVolumes
(
pod
,
claimsToFindMatching
,
node
)
unboundVolumesSatisfied
,
matched
Binding
s
,
unboundClaims
,
err
=
b
.
findMatchingVolumes
(
pod
,
claimsToFindMatching
,
node
)
if
err
!=
nil
{
return
false
,
false
,
err
}
...
...
@@ -598,10 +598,10 @@ func (b *volumeBinder) arePodVolumesBound(pod *v1.Pod) bool {
// getPodVolumes returns a pod's PVCs separated into bound, unbound with delayed binding (including provisioning)
// and unbound with immediate binding (including prebound)
func
(
b
*
volumeBinder
)
getPodVolumes
(
pod
*
v1
.
Pod
)
(
boundClaims
[]
*
v1
.
PersistentVolumeClaim
,
unboundClaims
[]
*
v1
.
PersistentVolumeClaim
,
unboundClaimsImmediate
[]
*
v1
.
PersistentVolumeClaim
,
err
error
)
{
func
(
b
*
volumeBinder
)
getPodVolumes
(
pod
*
v1
.
Pod
)
(
boundClaims
[]
*
v1
.
PersistentVolumeClaim
,
unboundClaims
DelayBinding
[]
*
v1
.
PersistentVolumeClaim
,
unboundClaimsImmediate
[]
*
v1
.
PersistentVolumeClaim
,
err
error
)
{
boundClaims
=
[]
*
v1
.
PersistentVolumeClaim
{}
unboundClaimsImmediate
=
[]
*
v1
.
PersistentVolumeClaim
{}
unboundClaims
=
[]
*
v1
.
PersistentVolumeClaim
{}
unboundClaims
DelayBinding
=
[]
*
v1
.
PersistentVolumeClaim
{}
for
_
,
vol
:=
range
pod
.
Spec
.
Volumes
{
volumeBound
,
pvc
,
err
:=
b
.
isVolumeBound
(
pod
.
Namespace
,
&
vol
)
...
...
@@ -621,7 +621,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV
// Prebound PVCs are treated as unbound immediate binding
if
delayBindingMode
&&
pvc
.
Spec
.
VolumeName
==
""
{
// Scheduler path
unboundClaims
=
append
(
unboundClaims
,
pvc
)
unboundClaims
DelayBinding
=
append
(
unboundClaimsDelayBinding
,
pvc
)
}
else
{
// !delayBindingMode || pvc.Spec.VolumeName != ""
// Immediate binding should have already been bound
...
...
@@ -629,7 +629,7 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV
}
}
}
return
boundClaims
,
unboundClaims
,
unboundClaimsImmediate
,
nil
return
boundClaims
,
unboundClaims
DelayBinding
,
unboundClaimsImmediate
,
nil
}
func
(
b
*
volumeBinder
)
checkBoundClaims
(
claims
[]
*
v1
.
PersistentVolumeClaim
,
node
*
v1
.
Node
,
podName
string
)
(
bool
,
error
)
{
...
...
@@ -654,7 +654,7 @@ func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node
// findMatchingVolumes tries to find matching volumes for given claims,
// and return unbound claims for further provision.
func
(
b
*
volumeBinder
)
findMatchingVolumes
(
pod
*
v1
.
Pod
,
claimsToBind
[]
*
v1
.
PersistentVolumeClaim
,
node
*
v1
.
Node
)
(
foundMatches
bool
,
matchedClaim
s
[]
*
bindingInfo
,
unboundClaims
[]
*
v1
.
PersistentVolumeClaim
,
err
error
)
{
func
(
b
*
volumeBinder
)
findMatchingVolumes
(
pod
*
v1
.
Pod
,
claimsToBind
[]
*
v1
.
PersistentVolumeClaim
,
node
*
v1
.
Node
)
(
foundMatches
bool
,
binding
s
[]
*
bindingInfo
,
unboundClaims
[]
*
v1
.
PersistentVolumeClaim
,
err
error
)
{
podName
:=
getPodName
(
pod
)
// Sort all the claims by increasing size request to get the smallest fits
sort
.
Sort
(
byPVCSize
(
claimsToBind
))
...
...
@@ -662,7 +662,6 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
chosenPVs
:=
map
[
string
]
*
v1
.
PersistentVolume
{}
foundMatches
=
true
matchedClaims
=
[]
*
bindingInfo
{}
for
_
,
pvc
:=
range
claimsToBind
{
// Get storage class name from each PVC
...
...
@@ -688,7 +687,7 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
// matching PV needs to be excluded so we don't select it again
chosenPVs
[
pv
.
Name
]
=
pv
matchedClaims
=
append
(
matchedClaim
s
,
&
bindingInfo
{
pv
:
pv
,
pvc
:
pvc
})
bindings
=
append
(
binding
s
,
&
bindingInfo
{
pv
:
pv
,
pvc
:
pvc
})
klog
.
V
(
5
)
.
Infof
(
"Found matching PV %q for PVC %q on node %q for pod %q"
,
pv
.
Name
,
pvcName
,
node
.
Name
,
podName
)
}
...
...
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