Update equivalence cache to use predicate as key

Remove Invalid field from host predicate
This commit is contained in:
Harry Zhang
2017-02-15 16:55:02 +08:00
parent c888069a3b
commit 819554f514
3 changed files with 275 additions and 64 deletions

View File

@@ -247,22 +247,21 @@ func copyAndReplace(set sets.String, replaceWhat, replaceWith string) sets.Strin
// GetEquivalencePod returns a EquivalencePod which contains a group of pod attributes which can be reused.
func GetEquivalencePod(pod *v1.Pod) interface{} {
equivalencePod := EquivalencePod{}
// For now we only consider pods:
// 1. OwnerReferences is Controller
// 2. OwnerReferences kind is in valid controller kinds
// 3. with same OwnerReferences
// 2. with same OwnerReferences
// to be equivalent
if len(pod.OwnerReferences) != 0 {
for _, ref := range pod.OwnerReferences {
if *ref.Controller {
equivalencePod.ControllerRef = ref
// a pod can only belongs to one controller
break
return &EquivalencePod{
ControllerRef: ref,
}
}
}
}
return &equivalencePod
return nil
}
// EquivalencePod is a group of pod attributes which can be reused as equivalence to schedule other pods.