diff --git a/pkg/scheduler/core/generic_scheduler.go b/pkg/scheduler/core/generic_scheduler.go index 2edb785ba1f..960054b0d14 100644 --- a/pkg/scheduler/core/generic_scheduler.go +++ b/pkg/scheduler/core/generic_scheduler.go @@ -508,39 +508,11 @@ func podFitsOnNode( ) //TODO (yastij) : compute average predicate restrictiveness to export it as Prometheus metric if predicate, exist := predicateFuncs[predicateKey]; exist { - // Use an in-line function to guarantee invocation of ecache.Unlock() - // when the in-line function returns. - func() { - var invalid bool - if eCacheAvailable { - // Lock ecache here to avoid a race condition against cache invalidation invoked - // in event handlers. This race has existed despite locks in equivClassCacheimplementation. - ecache.Lock() - defer ecache.Unlock() - // PredicateWithECache will return its cached predicate results. - fit, reasons, invalid = ecache.PredicateWithECache( - pod.GetName(), info.Node().GetName(), - predicateKey, equivCacheInfo.hash, false) - } - - if !eCacheAvailable || invalid { - // we need to execute predicate functions since equivalence cache does not work - fit, reasons, err = predicate(pod, metaToUse, nodeInfoToUse) - if err != nil { - return - } - - if eCacheAvailable { - // Skip update if NodeInfo is stale. - if cache != nil && cache.IsUpToDate(info) { - ecache.UpdateCachedPredicateItem( - pod.GetName(), info.Node().GetName(), - predicateKey, fit, reasons, equivCacheInfo.hash, false) - } - } - } - }() - + if eCacheAvailable { + fit, reasons, err = ecache.RunPredicate(predicate, predicateKey, pod, metaToUse, nodeInfoToUse, equivCacheInfo, cache) + } else { + fit, reasons, err = predicate(pod, metaToUse, nodeInfoToUse) + } if err != nil { return false, []algorithm.PredicateFailureReason{}, err }