mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Clear cache instead of saving nils if no claims to bind or provision
This commit is contained in:
parent
c2d25e08d7
commit
dbd80460de
@ -182,6 +182,11 @@ func (b *volumeBinder) FindPodVolumes(pod *v1.Pod, node *v1.Node) (unboundVolume
|
|||||||
)
|
)
|
||||||
defer func() {
|
defer func() {
|
||||||
// We recreate bindings for each new schedule loop.
|
// We recreate bindings for each new schedule loop.
|
||||||
|
if len(matchedClaims) == 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
|
// Although we do not distinguish nil from empty in this function, for
|
||||||
// easier testing, we normalize empty to nil.
|
// easier testing, we normalize empty to nil.
|
||||||
if len(matchedClaims) == 0 {
|
if len(matchedClaims) == 0 {
|
||||||
|
@ -30,6 +30,9 @@ type PodBindingCache interface {
|
|||||||
// pod and node.
|
// pod and node.
|
||||||
UpdateBindings(pod *v1.Pod, node string, bindings []*bindingInfo, provisionings []*v1.PersistentVolumeClaim)
|
UpdateBindings(pod *v1.Pod, node string, bindings []*bindingInfo, provisionings []*v1.PersistentVolumeClaim)
|
||||||
|
|
||||||
|
// ClearBindings will clear the cached bindings for the given pod and node.
|
||||||
|
ClearBindings(pod *v1.Pod, node string)
|
||||||
|
|
||||||
// GetBindings will return the cached bindings for the given pod and node.
|
// GetBindings will return the cached bindings for the given pod and node.
|
||||||
// A nil return value means that the entry was not found. An empty slice
|
// A nil return value means that the entry was not found. An empty slice
|
||||||
// means that no binding operations are needed.
|
// means that no binding operations are needed.
|
||||||
@ -148,3 +151,15 @@ func (c *podBindingCache) GetProvisionedPVCs(pod *v1.Pod, node string) []*v1.Per
|
|||||||
}
|
}
|
||||||
return decision.provisionings
|
return decision.provisionings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *podBindingCache) ClearBindings(pod *v1.Pod, node string) {
|
||||||
|
c.rwMutex.Lock()
|
||||||
|
defer c.rwMutex.Unlock()
|
||||||
|
|
||||||
|
podName := getPodName(pod)
|
||||||
|
decisions, ok := c.bindingDecisions[podName]
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete(decisions, node)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user