Drop ConfigurePredicateCheckerForLoop
This commit is contained in:
parent
2679713436
commit
b01f2fca8f
|
|
@ -319,8 +319,6 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
|
|||
// scheduledPods will be mutated over this method. We keep original list of pods on originalScheduledPods.
|
||||
scheduledPods := append([]*apiv1.Pod{}, originalScheduledPods...)
|
||||
|
||||
core_utils.ConfigurePredicateCheckerForLoop(unschedulablePods, scheduledPods, a.PredicateChecker)
|
||||
|
||||
unschedulablePods = tpu.ClearTPURequests(unschedulablePods)
|
||||
|
||||
// todo: move split and append below to separate PodListProcessor
|
||||
|
|
|
|||
|
|
@ -313,28 +313,6 @@ func hasHardInterPodAffinity(affinity *apiv1.Affinity) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func anyPodHasHardInterPodAffinity(pods []*apiv1.Pod) bool {
|
||||
for _, pod := range pods {
|
||||
if hasHardInterPodAffinity(pod.Spec.Affinity) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ConfigurePredicateCheckerForLoop can be run to update predicateChecker configuration
|
||||
// based on current state of the cluster.
|
||||
func ConfigurePredicateCheckerForLoop(unschedulablePods []*apiv1.Pod, schedulablePods []*apiv1.Pod, predicateChecker *simulator.PredicateChecker) {
|
||||
podsWithAffinityFound := anyPodHasHardInterPodAffinity(unschedulablePods)
|
||||
if !podsWithAffinityFound {
|
||||
podsWithAffinityFound = anyPodHasHardInterPodAffinity(schedulablePods)
|
||||
}
|
||||
predicateChecker.SetAffinityPredicateEnabled(podsWithAffinityFound)
|
||||
if !podsWithAffinityFound {
|
||||
klog.V(1).Info("No pod using affinity / antiaffinity found in cluster, disabling affinity predicate for this loop")
|
||||
}
|
||||
}
|
||||
|
||||
// GetNodeCoresAndMemory extracts cpu and memory resources out of Node object
|
||||
func GetNodeCoresAndMemory(node *apiv1.Node) (int64, int64) {
|
||||
cores := getNodeResource(node, apiv1.ResourceCPU)
|
||||
|
|
|
|||
|
|
@ -289,59 +289,6 @@ func TestSanitizeTaints(t *testing.T) {
|
|||
assert.Equal(t, node.Spec.Taints[0].Key, "test-taint")
|
||||
}
|
||||
|
||||
func TestConfigurePredicateCheckerForLoop(t *testing.T) {
|
||||
testCases := []struct {
|
||||
affinity *apiv1.Affinity
|
||||
predicateEnabled bool
|
||||
}{
|
||||
{
|
||||
&apiv1.Affinity{
|
||||
PodAffinity: &apiv1.PodAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: []apiv1.PodAffinityTerm{
|
||||
{},
|
||||
},
|
||||
},
|
||||
}, true},
|
||||
{
|
||||
&apiv1.Affinity{
|
||||
PodAffinity: &apiv1.PodAffinity{
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: []apiv1.WeightedPodAffinityTerm{
|
||||
{},
|
||||
},
|
||||
},
|
||||
}, false},
|
||||
{
|
||||
&apiv1.Affinity{
|
||||
PodAntiAffinity: &apiv1.PodAntiAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: []apiv1.PodAffinityTerm{
|
||||
{},
|
||||
},
|
||||
},
|
||||
}, true},
|
||||
{
|
||||
&apiv1.Affinity{
|
||||
PodAntiAffinity: &apiv1.PodAntiAffinity{
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: []apiv1.WeightedPodAffinityTerm{
|
||||
{},
|
||||
},
|
||||
},
|
||||
}, false},
|
||||
{
|
||||
&apiv1.Affinity{
|
||||
NodeAffinity: &apiv1.NodeAffinity{},
|
||||
}, false},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
p := BuildTestPod("p", 500, 1000)
|
||||
p.Spec.Affinity = tc.affinity
|
||||
predicateChecker := simulator.NewTestPredicateChecker()
|
||||
predicateChecker.SetAffinityPredicateEnabled(false)
|
||||
ConfigurePredicateCheckerForLoop([]*apiv1.Pod{p}, []*apiv1.Pod{}, predicateChecker)
|
||||
assert.Equal(t, tc.predicateEnabled, predicateChecker.IsAffinityPredicateEnabled())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetNodeResource(t *testing.T) {
|
||||
node := BuildTestNode("n1", 1000, 2*MiB)
|
||||
|
||||
|
|
|
|||
|
|
@ -122,20 +122,6 @@ func (p *PredicateChecker) SnapshotClusterState() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// SetAffinityPredicateEnabled can be used to enable or disable checking MatchInterPodAffinity
|
||||
// predicate. This will cause incorrect CA behavior if there is at least a single pod in
|
||||
// cluster using affinity/antiaffinity. However, checking affinity predicate is extremely
|
||||
// costly even if no pod is using it, so it may be worth disabling it in such situation.
|
||||
func (p *PredicateChecker) SetAffinityPredicateEnabled(enable bool) {
|
||||
// TODO(scheduler_framework)
|
||||
}
|
||||
|
||||
// IsAffinityPredicateEnabled checks if affinity predicate is enabled.
|
||||
func (p *PredicateChecker) IsAffinityPredicateEnabled() bool {
|
||||
// TODO(scheduler_framework)
|
||||
return false
|
||||
}
|
||||
|
||||
// FitsAny checks if the given pod can be place on any of the given nodes.
|
||||
func (p *PredicateChecker) FitsAny(pod *apiv1.Pod, nodeInfos map[string]*scheduler_nodeinfo.NodeInfo) (string, error) {
|
||||
// TODO(scheduler_framework) run prefilter only once
|
||||
|
|
|
|||
Loading…
Reference in New Issue