mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Skip if pod does not have claims.
This commit is contained in:
parent
7fe97886a8
commit
c2d25e08d7
@ -142,10 +142,40 @@ func (b *volumeBinder) GetBindingsCache() PodBindingCache {
|
|||||||
return b.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.
|
// 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.
|
// 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.
|
// 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) {
|
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 (
|
var (
|
||||||
matchedClaims []*bindingInfo
|
matchedClaims []*bindingInfo
|
||||||
provisionedClaims []*v1.PersistentVolumeClaim
|
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)
|
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
|
// 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.
|
// volumes can get bound/provisioned in between calls.
|
||||||
boundClaims, claimsToBind, unboundClaimsImmediate, err := b.getPodVolumes(pod)
|
boundClaims, claimsToBind, unboundClaimsImmediate, err := b.getPodVolumes(pod)
|
||||||
|
Loading…
Reference in New Issue
Block a user