wilfred-s commented on code in PR #610:
URL: https://github.com/apache/yunikorn-k8shim/pull/610#discussion_r1244512110


##########
pkg/cache/external/scheduler_cache.go:
##########
@@ -589,6 +596,55 @@ func (cache *SchedulerCache) nodePodCount() int {
        return result
 }
 
+// IsPVCUsedByPods determines if a given volume claim is in use by any current 
pods. This is explicitly for the use
+// of the predicate shared lister and requires that the scheduler cache lock 
be held while accessing.
+func (cache *SchedulerCache) IsPVCUsedByPods(key string) bool {
+       _, ok := cache.pvcRefCounts[key]
+       return ok
+}
+
+func (cache *SchedulerCache) maxNodeGeneration() int64 {
+       var maxGeneration int64
+       for _, node := range cache.nodesMap {
+               if maxGeneration < node.Generation {
+                       maxGeneration = node.Generation
+               }
+       }
+       return maxGeneration
+}
+
+func (cache *SchedulerCache) updatePVCRefCounts() {
+       maxGeneration := cache.maxNodeGeneration()
+       updateAll := false
+       if cache.pvcGeneration == 0 {
+               // clear cache
+               updateAll = true
+               cache.pvcRefCounts = make(map[string]map[string]int)
+       } else if cache.pvcGeneration >= maxGeneration {

Review Comment:
   This is expensive when we have a long list of nodes. Generation for the 
nodes is a monotonically increasing number and never can go down. We should 
handle this when the node in the cache is manipulated (new, add or remove pod) 
they all trigger a generation increment. Use a follow up jira to make this 
smarter, we have a handle on the node already that has changed and can target 
this as far as I can tell.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to