craigcondit commented on code in PR #610:
URL: https://github.com/apache/yunikorn-k8shim/pull/610#discussion_r1244534030


##########
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 was based on the implementation the default scheduler uses. I kept it 
the same for now to ensure compatibility. We can revisit if this proves to be 
very expensive.



-- 
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