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


##########
pkg/cache/context.go:
##########
@@ -692,6 +699,40 @@ func (ctx *Context) EventsToRegister(queueingHintFn 
fwk.QueueingHintFn) []fwk.Cl
        return ctx.predManager.EventsToRegister(queueingHintFn)
 }
 
+// PreFilter evaluates given prefilter based predicates based on current 
context
+func (ctx *Context) PreFilter(name string, allocate bool) 
*si.PreFilterPredicatesResponse {
+       ctx.lock.RLock()
+       defer ctx.lock.RUnlock()
+       pod := ctx.schedulerCache.GetPod(name)
+       if pod == nil {
+               log.Log(log.ShimContext).Error("failed running PreFilter 
plugin",
+                       zap.String("pod", name),
+                       zap.Error(ErrorPodNotFound))
+               return &si.PreFilterPredicatesResponse{
+                       FeasibleNodes: make(map[string]*si.Empty),
+                       Success:       false,
+               }
+       }
+       // if pod exists in cache, try to run predicates
+       // need to lock cache here as predicates need a stable view into the 
cache
+       ctx.schedulerCache.LockForReads()
+       feasibleNodes, cycleState, err := ctx.predManager.PreFilter(pod, 
allocate)
+       ctx.schedulerCache.UnlockForReads()
+       if err == nil {
+               ctx.schedulerCache.LockForWrites()
+               ctx.schedulerCache.StoreCycleState(pod, cycleState)
+               ctx.schedulerCache.UnlockForWrites()

Review Comment:
   should follow the same setup as for the delete. Lock inside the call which 
means we can remove the UnlockForWrites and LockForWrites calls.



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