Commit 8df3ab75 authored by Harry Zhang's avatar Harry Zhang

Check nodeInfo before ecache

parent b2a8ef47
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package core package core
import ( import (
"fmt"
"hash/fnv" "hash/fnv"
"sync" "sync"
...@@ -86,6 +87,12 @@ func (ec *EquivalenceCache) RunPredicate( ...@@ -86,6 +87,12 @@ func (ec *EquivalenceCache) RunPredicate(
) (bool, []algorithm.PredicateFailureReason, error) { ) (bool, []algorithm.PredicateFailureReason, error) {
ec.mu.Lock() ec.mu.Lock()
defer ec.mu.Unlock() defer ec.mu.Unlock()
if nodeInfo == nil || nodeInfo.Node() == nil {
// This may happen during tests.
return false, []algorithm.PredicateFailureReason{}, fmt.Errorf("nodeInfo is nil or node is invalid")
}
fit, reasons, invalid := ec.lookupResult(pod.GetName(), nodeInfo.Node().GetName(), predicateKey, equivClassInfo.hash) fit, reasons, invalid := ec.lookupResult(pod.GetName(), nodeInfo.Node().GetName(), predicateKey, equivClassInfo.hash)
if !invalid { if !invalid {
return fit, reasons, nil return fit, reasons, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment