Skip to content

Commit aef336d

Browse files
authored
Merge pull request kubernetes#86999 from draveness/feature/remove-ErrTopologySpreadConstraintsNotMatch
fix: remove ErrTopologySpreadConstraintsNotMatch
2 parents 95c9878 + 0278d79 commit aef336d

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

pkg/scheduler/algorithm/predicates/error.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ var (
5151
ErrNodeUnschedulable = NewPredicateFailureError("NodeUnschedulable", "node(s) were unschedulable")
5252
// ErrNodeUnknownCondition is used for NodeUnknownCondition predicate error.
5353
ErrNodeUnknownCondition = NewPredicateFailureError("NodeUnknownCondition", "node(s) had unknown conditions")
54-
// ErrTopologySpreadConstraintsNotMatch is used for EvenPodsSpread predicate error.
55-
ErrTopologySpreadConstraintsNotMatch = NewPredicateFailureError("EvenPodsSpreadNotMatch", "node(s) didn't match pod topology spread constraints")
5654
// ErrFakePredicate is used for test only. The fake predicates returning false also returns error
5755
// as ErrFakePredicate.
5856
ErrFakePredicate = NewPredicateFailureError("FakePredicateError", "Nodes failed the fake predicate")

pkg/scheduler/core/generic_scheduler_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,9 @@ func TestNodesWherePreemptionMightHelp(t *testing.T) {
19541954
{
19551955
name: "ErrTopologySpreadConstraintsNotMatch should be tried as it indicates that the pod is unschedulable due to topology spread constraints",
19561956
nodesStatuses: framework.NodeToStatusMap{
1957-
"machine1": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrTopologySpreadConstraintsNotMatch.GetReason()),
1957+
"machine1": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
19581958
"machine2": framework.NewStatus(framework.UnschedulableAndUnresolvable, algorithmpredicates.ErrPodNotMatchHostName.GetReason()),
1959-
"machine3": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrTopologySpreadConstraintsNotMatch.GetReason()),
1959+
"machine3": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
19601960
},
19611961
expected: map[string]bool{"machine1": true, "machine3": true, "machine4": true},
19621962
},
@@ -2123,9 +2123,9 @@ func TestPreempt(t *testing.T) {
21232123
},
21242124
},
21252125
failedNodeToStatusMap: framework.NodeToStatusMap{
2126-
"node-a": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrTopologySpreadConstraintsNotMatch.GetReason()),
2127-
"node-b": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrTopologySpreadConstraintsNotMatch.GetReason()),
2128-
"node-x": framework.NewStatus(framework.Unschedulable, algorithmpredicates.ErrTopologySpreadConstraintsNotMatch.GetReason()),
2126+
"node-a": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
2127+
"node-b": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
2128+
"node-x": framework.NewStatus(framework.Unschedulable, podtopologyspread.ErrReasonConstraintsNotMatch),
21292129
},
21302130
nodeNames: []string{"node-a/zone1", "node-b/zone1", "node-x/zone2"},
21312131
registerPlugin: st.RegisterPluginAsExtensions(

pkg/scheduler/framework/plugins/podtopologyspread/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ go_library(
1111
importpath = "k8s.io/kubernetes/pkg/scheduler/framework/plugins/podtopologyspread",
1212
visibility = ["//visibility:public"],
1313
deps = [
14-
"//pkg/scheduler/algorithm/predicates:go_default_library",
1514
"//pkg/scheduler/framework/plugins/helper:go_default_library",
16-
"//pkg/scheduler/framework/plugins/migration:go_default_library",
1715
"//pkg/scheduler/framework/v1alpha1:go_default_library",
1816
"//pkg/scheduler/listers:go_default_library",
1917
"//pkg/scheduler/nodeinfo:go_default_library",

pkg/scheduler/framework/plugins/podtopologyspread/filtering.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ import (
2626
"k8s.io/apimachinery/pkg/labels"
2727
"k8s.io/client-go/util/workqueue"
2828
"k8s.io/klog"
29-
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
3029
pluginhelper "k8s.io/kubernetes/pkg/scheduler/framework/plugins/helper"
31-
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration"
3230
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
3331
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
3432
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
@@ -310,7 +308,7 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
310308
tpVal, ok := node.Labels[c.topologyKey]
311309
if !ok {
312310
klog.V(5).Infof("node '%s' doesn't have required label '%s'", node.Name, tpKey)
313-
return migration.PredicateResultToFrameworkStatus([]predicates.PredicateFailureReason{predicates.ErrTopologySpreadConstraintsNotMatch}, nil)
311+
return framework.NewStatus(framework.Unschedulable, ErrReasonConstraintsNotMatch)
314312
}
315313

316314
selfMatchNum := int32(0)
@@ -332,7 +330,7 @@ func (pl *PodTopologySpread) Filter(ctx context.Context, cycleState *framework.C
332330
skew := matchNum + selfMatchNum - minMatchNum
333331
if skew > c.maxSkew {
334332
klog.V(5).Infof("node '%s' failed spreadConstraint[%s]: matchNum(%d) + selfMatchNum(%d) - minMatchNum(%d) > maxSkew(%d)", node.Name, tpKey, matchNum, selfMatchNum, minMatchNum, c.maxSkew)
335-
return migration.PredicateResultToFrameworkStatus([]predicates.PredicateFailureReason{predicates.ErrTopologySpreadConstraintsNotMatch}, nil)
333+
return framework.NewStatus(framework.Unschedulable, ErrReasonConstraintsNotMatch)
336334
}
337335
}
338336

pkg/scheduler/framework/plugins/podtopologyspread/plugin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
2525
)
2626

27+
const (
28+
// ErrReasonConstraintsNotMatch is used for PodTopologySpread filter error.
29+
ErrReasonConstraintsNotMatch = "node(s) didn't match pod topology spread constraints"
30+
)
31+
2732
// PodTopologySpread is a plugin that ensures pod's topologySpreadConstraints is satisfied.
2833
type PodTopologySpread struct {
2934
sharedLister schedulerlisters.SharedLister

0 commit comments

Comments
 (0)