@@ -160,26 +160,26 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
160
160
}()
161
161
162
162
var (
163
- matchedClaims []* bindingInfo
163
+ matchedBindings []* bindingInfo
164
164
provisionedClaims []* v1.PersistentVolumeClaim
165
165
)
166
166
defer func () {
167
167
// We recreate bindings for each new schedule loop.
168
- if len (matchedClaims ) == 0 && len (provisionedClaims ) == 0 {
168
+ if len (matchedBindings ) == 0 && len (provisionedClaims ) == 0 {
169
169
// Clear cache if no claims to bind or provision for this node.
170
170
b .podBindingCache .ClearBindings (pod , node .Name )
171
171
return
172
172
}
173
173
// Although we do not distinguish nil from empty in this function, for
174
174
// easier testing, we normalize empty to nil.
175
- if len (matchedClaims ) == 0 {
176
- matchedClaims = nil
175
+ if len (matchedBindings ) == 0 {
176
+ matchedBindings = nil
177
177
}
178
178
if len (provisionedClaims ) == 0 {
179
179
provisionedClaims = nil
180
180
}
181
181
// Mark cache with all matched and provisioned claims for this node
182
- b .podBindingCache .UpdateBindings (pod , node .Name , matchedClaims , provisionedClaims )
182
+ b .podBindingCache .UpdateBindings (pod , node .Name , matchedBindings , provisionedClaims )
183
183
}()
184
184
185
185
// 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
225
225
// Find matching volumes
226
226
if len (claimsToFindMatching ) > 0 {
227
227
var unboundClaims []* v1.PersistentVolumeClaim
228
- unboundVolumesSatisfied , matchedClaims , unboundClaims , err = b .findMatchingVolumes (pod , claimsToFindMatching , node )
228
+ unboundVolumesSatisfied , matchedBindings , unboundClaims , err = b .findMatchingVolumes (pod , claimsToFindMatching , node )
229
229
if err != nil {
230
230
return false , false , err
231
231
}
@@ -598,10 +598,10 @@ func (b *volumeBinder) arePodVolumesBound(pod *v1.Pod) bool {
598
598
599
599
// getPodVolumes returns a pod's PVCs separated into bound, unbound with delayed binding (including provisioning)
600
600
// and unbound with immediate binding (including prebound)
601
- func (b * volumeBinder ) getPodVolumes (pod * v1.Pod ) (boundClaims []* v1.PersistentVolumeClaim , unboundClaims []* v1.PersistentVolumeClaim , unboundClaimsImmediate []* v1.PersistentVolumeClaim , err error ) {
601
+ func (b * volumeBinder ) getPodVolumes (pod * v1.Pod ) (boundClaims []* v1.PersistentVolumeClaim , unboundClaimsDelayBinding []* v1.PersistentVolumeClaim , unboundClaimsImmediate []* v1.PersistentVolumeClaim , err error ) {
602
602
boundClaims = []* v1.PersistentVolumeClaim {}
603
603
unboundClaimsImmediate = []* v1.PersistentVolumeClaim {}
604
- unboundClaims = []* v1.PersistentVolumeClaim {}
604
+ unboundClaimsDelayBinding = []* v1.PersistentVolumeClaim {}
605
605
606
606
for _ , vol := range pod .Spec .Volumes {
607
607
volumeBound , pvc , err := b .isVolumeBound (pod .Namespace , & vol )
@@ -621,15 +621,15 @@ func (b *volumeBinder) getPodVolumes(pod *v1.Pod) (boundClaims []*v1.PersistentV
621
621
// Prebound PVCs are treated as unbound immediate binding
622
622
if delayBindingMode && pvc .Spec .VolumeName == "" {
623
623
// Scheduler path
624
- unboundClaims = append (unboundClaims , pvc )
624
+ unboundClaimsDelayBinding = append (unboundClaimsDelayBinding , pvc )
625
625
} else {
626
626
// !delayBindingMode || pvc.Spec.VolumeName != ""
627
627
// Immediate binding should have already been bound
628
628
unboundClaimsImmediate = append (unboundClaimsImmediate , pvc )
629
629
}
630
630
}
631
631
}
632
- return boundClaims , unboundClaims , unboundClaimsImmediate , nil
632
+ return boundClaims , unboundClaimsDelayBinding , unboundClaimsImmediate , nil
633
633
}
634
634
635
635
func (b * volumeBinder ) checkBoundClaims (claims []* v1.PersistentVolumeClaim , node * v1.Node , podName string ) (bool , error ) {
@@ -654,15 +654,14 @@ func (b *volumeBinder) checkBoundClaims(claims []*v1.PersistentVolumeClaim, node
654
654
655
655
// findMatchingVolumes tries to find matching volumes for given claims,
656
656
// and return unbound claims for further provision.
657
- func (b * volumeBinder ) findMatchingVolumes (pod * v1.Pod , claimsToBind []* v1.PersistentVolumeClaim , node * v1.Node ) (foundMatches bool , matchedClaims []* bindingInfo , unboundClaims []* v1.PersistentVolumeClaim , err error ) {
657
+ func (b * volumeBinder ) findMatchingVolumes (pod * v1.Pod , claimsToBind []* v1.PersistentVolumeClaim , node * v1.Node ) (foundMatches bool , bindings []* bindingInfo , unboundClaims []* v1.PersistentVolumeClaim , err error ) {
658
658
podName := getPodName (pod )
659
659
// Sort all the claims by increasing size request to get the smallest fits
660
660
sort .Sort (byPVCSize (claimsToBind ))
661
661
662
662
chosenPVs := map [string ]* v1.PersistentVolume {}
663
663
664
664
foundMatches = true
665
- matchedClaims = []* bindingInfo {}
666
665
667
666
for _ , pvc := range claimsToBind {
668
667
// Get storage class name from each PVC
@@ -688,7 +687,7 @@ func (b *volumeBinder) findMatchingVolumes(pod *v1.Pod, claimsToBind []*v1.Persi
688
687
689
688
// matching PV needs to be excluded so we don't select it again
690
689
chosenPVs [pv .Name ] = pv
691
- matchedClaims = append (matchedClaims , & bindingInfo {pv : pv , pvc : pvc })
690
+ bindings = append (bindings , & bindingInfo {pv : pv , pvc : pvc })
692
691
klog .V (5 ).Infof ("Found matching PV %q for PVC %q on node %q for pod %q" , pv .Name , pvcName , node .Name , podName )
693
692
}
694
693
0 commit comments