Merge pull request #112784 from kerthcet/cleanup/word-typo

typo fixed with NodeInclusionPolicy
This commit is contained in:
Kubernetes Prow Robot 2022-09-29 10:14:50 -07:00 committed by GitHub
commit 77bf2d1ade
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 146 additions and 146 deletions

View File

@ -69,16 +69,16 @@ func (p *criticalPaths) sort() {
func TestPreFilterState(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
objs []runtime.Object
defaultConstraints []v1.TopologySpreadConstraint
want *preFilterState
enableMinDomains bool
enableNodeInclustionPolicy bool
enableMatchLabelKeys bool
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
objs []runtime.Object
defaultConstraints []v1.TopologySpreadConstraint
want *preFilterState
enableMinDomains bool
enableNodeInclusionPolicy bool
enableMatchLabelKeys bool
}{
{
name: "clean cluster with one spreadConstraint",
@ -672,7 +672,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-b"}: 2,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "NodeAffinityPolicy honored with labelSelectors",
@ -710,7 +710,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-b"}: 2,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with labelSelectors",
@ -749,7 +749,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-c"}: 0,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy honored with nodeAffinity",
@ -787,7 +787,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-b"}: 2,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with nodeAffinity",
@ -826,7 +826,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-c"}: 0,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "feature gate disabled with NodeTaintsPolicy",
@ -864,7 +864,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-c"}: 0,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "NodeTaintsPolicy ignored",
@ -902,7 +902,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-c"}: 0,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy honored",
@ -939,7 +939,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-b"}: 2,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy honored with tolerated taints",
@ -978,7 +978,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-c"}: 0,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "two node inclusion Constraints, zone: honor/ignore, node: ignore/ignore",
@ -1028,7 +1028,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-x"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "two node inclusion Constraints, zone: honor/honor, node: honor/ignore",
@ -1077,7 +1077,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-x"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "two node inclusion Constraints, zone: honor/ignore, node: honor/ignore",
@ -1128,7 +1128,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-x"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "two node inclusion Constraints, zone: ignore/ignore, node: honor/honor",
@ -1180,7 +1180,7 @@ func TestPreFilterState(t *testing.T) {
{key: "node", value: "node-y"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "matchLabelKeys ignored when feature gate disabled",
@ -1350,7 +1350,7 @@ func TestPreFilterState(t *testing.T) {
p := plugintesting.SetupPluginWithInformers(ctx, t, topologySpreadFunc, args, cache.NewSnapshot(tt.existingPods, tt.nodes), tt.objs)
p.(*PodTopologySpread).enableMinDomainsInPodTopologySpread = tt.enableMinDomains
p.(*PodTopologySpread).enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.(*PodTopologySpread).enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
p.(*PodTopologySpread).enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
cs := framework.NewCycleState()
@ -1380,14 +1380,14 @@ func TestPreFilterStateAddPod(t *testing.T) {
zoneConstraint := nodeConstraint
zoneConstraint.TopologyKey = "zone"
tests := []struct {
name string
preemptor *v1.Pod
addedPod *v1.Pod
existingPods []*v1.Pod
nodeIdx int // denotes which node 'addedPod' belongs to
nodes []*v1.Node
want *preFilterState
enableNodeInclustionPolicy bool
name string
preemptor *v1.Pod
addedPod *v1.Pod
existingPods []*v1.Pod
nodeIdx int // denotes which node 'addedPod' belongs to
nodes []*v1.Node
want *preFilterState
enableNodeInclusionPolicy bool
}{
{
name: "node a and b both impact current min match",
@ -1686,7 +1686,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone2"}: 1,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "add a pod when scheduling node affinity unmatched pod with NodeInclusionPolicy enabled",
@ -1712,7 +1712,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone2"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "add a pod when scheduling node affinity matched pod with NodeInclusionPolicy disabled",
@ -1739,7 +1739,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone2"}: 2,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "add a pod when scheduling node affinity matched pod with NodeInclusionPolicy enabled",
@ -1766,7 +1766,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone2"}: 2,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "add a label selector not matched pod when with NodeInclusionPolicy enabled",
@ -1793,7 +1793,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone2"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "add a pod when scheduling taint untolerated pod with NodeInclusionPolicy disabled",
@ -1820,7 +1820,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone1"}: 1,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "add a pod when scheduling taint tolerated pod with NodeInclusionPolicy enabled",
@ -1847,7 +1847,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
{key: "zone", value: "zone1"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
}
for _, tt := range tests {
@ -1856,7 +1856,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
p := pl.(*PodTopologySpread)
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
cs := framework.NewCycleState()
if _, s := p.PreFilter(ctx, cs, tt.preemptor); !s.IsSuccess() {
@ -1892,15 +1892,15 @@ func TestPreFilterStateRemovePod(t *testing.T) {
zoneConstraint := nodeConstraint
zoneConstraint.TopologyKey = "zone"
tests := []struct {
name string
preemptor *v1.Pod // preemptor pod
nodes []*v1.Node
existingPods []*v1.Pod
deletedPodIdx int // need to reuse *Pod of existingPods[i]
deletedPod *v1.Pod // this field is used only when deletedPodIdx is -1
nodeIdx int // denotes which node "deletedPod" belongs to
want *preFilterState
enableNodeInclustionPolicy bool
name string
preemptor *v1.Pod // preemptor pod
nodes []*v1.Node
existingPods []*v1.Pod
deletedPodIdx int // need to reuse *Pod of existingPods[i]
deletedPod *v1.Pod // this field is used only when deletedPodIdx is -1
nodeIdx int // denotes which node "deletedPod" belongs to
want *preFilterState
enableNodeInclusionPolicy bool
}{
{
// A high priority pod may not be scheduled due to node taints or resource shortage.
@ -2083,7 +2083,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
{key: "zone", value: "zone2"}: 1,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "remove a pod when scheduling node affinity unmatched pod with NodeInclusionPolicy enabled",
@ -2109,7 +2109,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
{key: "zone", value: "zone2"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "remove a pod when scheduling node affinity matched pod with NodeInclusionPolicy disabled",
@ -2136,7 +2136,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
{key: "zone", value: "zone1"}: 1,
},
},
enableNodeInclustionPolicy: false,
enableNodeInclusionPolicy: false,
},
{
name: "remove a pod when scheduling node affinity matched pod with NodeInclusionPolicy enabled",
@ -2163,7 +2163,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
{key: "zone", value: "zone1"}: 1,
},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
}
for _, tt := range tests {
@ -2172,7 +2172,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
p := pl.(*PodTopologySpread)
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
cs := framework.NewCycleState()
if _, s := p.PreFilter(ctx, cs, tt.preemptor); !s.IsSuccess() {
@ -2279,13 +2279,13 @@ func mustConvertLabelSelectorAsSelector(t *testing.T, ls *metav1.LabelSelector)
func TestSingleConstraint(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
wantStatusCode map[string]framework.Code
enableMinDomains bool
enableNodeInclustionPolicy bool
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
wantStatusCode map[string]framework.Code
enableMinDomains bool
enableNodeInclusionPolicy bool
}{
{
name: "no existing pods",
@ -2718,7 +2718,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Success, // in real case, when we disable NodeAffinity Plugin, node-y will be success.
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// pods spread across node as 1/1/0/~1~
@ -2744,7 +2744,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// pods spread across node as 1/1/0/~0~
@ -2770,7 +2770,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Success, // in real case, when we disable NodeAffinity Plugin, node-y will be success.
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// pods spread across node as 1/1/0/~1~
@ -2796,7 +2796,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// pods spread across node as 1/1/0/~0~
@ -2821,7 +2821,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Success, // in real case, when we disable TaintToleration Plugin, node-y will be success.
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// pods spread across node as 1/1/0/~1~
@ -2846,7 +2846,7 @@ func TestSingleConstraint(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
}
for _, tt := range tests {
@ -2855,7 +2855,7 @@ func TestSingleConstraint(t *testing.T) {
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
p := pl.(*PodTopologySpread)
p.enableMinDomainsInPodTopologySpread = tt.enableMinDomains
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
state := framework.NewCycleState()
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
t.Errorf("preFilter failed with status: %v", s)
@ -2874,12 +2874,12 @@ func TestSingleConstraint(t *testing.T) {
func TestMultipleConstraints(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
wantStatusCode map[string]framework.Code
enableNodeInclustionPolicy bool
name string
pod *v1.Pod
nodes []*v1.Node
existingPods []*v1.Pod
wantStatusCode map[string]framework.Code
enableNodeInclusionPolicy bool
}{
{
// 1. to fulfil "zone" constraint, incoming pod can be placed on any zone (hence any node)
@ -3104,7 +3104,7 @@ func TestMultipleConstraints(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 2/0
@ -3132,7 +3132,7 @@ func TestMultipleConstraints(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 1/~1~
@ -3161,7 +3161,7 @@ func TestMultipleConstraints(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 1/0
@ -3190,7 +3190,7 @@ func TestMultipleConstraints(t *testing.T) {
"node-x": framework.Success,
"node-y": framework.Unschedulable,
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
}
for _, tt := range tests {
@ -3198,7 +3198,7 @@ func TestMultipleConstraints(t *testing.T) {
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
p := pl.(*PodTopologySpread)
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
state := framework.NewCycleState()
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
t.Errorf("preFilter failed with status: %v", s)

View File

@ -43,13 +43,13 @@ var podTopologySpreadFunc = frameworkruntime.FactoryAdapter(feature.Features{},
func TestPreScoreStateEmptyNodes(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
nodes []*v1.Node
objs []runtime.Object
config config.PodTopologySpreadArgs
want *preScoreState
enableNodeInclustionPolicy bool
name string
pod *v1.Pod
nodes []*v1.Node
objs []runtime.Object
config config.PodTopologySpreadArgs
want *preScoreState
enableNodeInclusionPolicy bool
}{
{
name: "normal case",
@ -321,7 +321,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with labelSelectors",
@ -355,7 +355,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy honored with nodeAffinity",
@ -389,7 +389,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with nodeAffinity",
@ -423,7 +423,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy honored",
@ -456,7 +456,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy ignored",
@ -489,7 +489,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
},
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
}
for _, tt := range tests {
@ -503,7 +503,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
if err != nil {
t.Fatalf("Failed creating framework runtime: %v", err)
}
pl, err := New(&tt.config, f, feature.Features{EnableNodeInclusionPolicyInPodTopologySpread: tt.enableNodeInclustionPolicy})
pl, err := New(&tt.config, f, feature.Features{EnableNodeInclusionPolicyInPodTopologySpread: tt.enableNodeInclusionPolicy})
if err != nil {
t.Fatalf("Failed creating plugin: %v", err)
}
@ -528,15 +528,15 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
func TestPodTopologySpreadScore(t *testing.T) {
tests := []struct {
name string
pod *v1.Pod
existingPods []*v1.Pod
nodes []*v1.Node
failedNodes []*v1.Node // nodes + failedNodes = all nodes
objs []runtime.Object
want framework.NodeScoreList
enableNodeInclustionPolicy bool
enableMatchLabelKeys bool
name string
pod *v1.Pod
existingPods []*v1.Pod
nodes []*v1.Node
failedNodes []*v1.Node // nodes + failedNodes = all nodes
objs []runtime.Object
want framework.NodeScoreList
enableNodeInclusionPolicy bool
enableMatchLabelKeys bool
}{
// Explanation on the Legend:
// a) X/Y means there are X matching pods on node1 and Y on node2, both nodes are candidates
@ -1029,7 +1029,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 33},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with labelSelectors",
@ -1053,7 +1053,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 100},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy honoed with nodeAffinity",
@ -1077,7 +1077,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 33},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with nodeAffinity",
@ -1101,7 +1101,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 100},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy honored",
@ -1124,7 +1124,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 33},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy ignored",
@ -1147,7 +1147,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
{Name: "node-b", Score: 100},
{Name: "node-c", Score: 100},
},
enableNodeInclustionPolicy: true,
enableNodeInclusionPolicy: true,
},
{
name: "matchLabelKeys ignored when feature gate disabled",
@ -1238,7 +1238,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
state := framework.NewCycleState()
pl := plugintesting.SetupPluginWithInformers(ctx, t, podTopologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.SystemDefaulting}, cache.NewSnapshot(tt.existingPods, allNodes), tt.objs)
p := pl.(*PodTopologySpread)
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
p.enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
status := p.PreScore(context.Background(), state, tt.pod, tt.nodes)

View File

@ -1068,15 +1068,15 @@ func TestPodTopologySpreadFilter(t *testing.T) {
}
tests := []struct {
name string
incomingPod *v1.Pod
existingPods []*v1.Pod
fits bool
nodes []*v1.Node
candidateNodes []string // nodes expected to schedule onto
enableMinDomains bool
enableNodeInclustionPolicy bool
enableMatchLabelKeys bool
name string
incomingPod *v1.Pod
existingPods []*v1.Pod
fits bool
nodes []*v1.Node
candidateNodes []string // nodes expected to schedule onto
enableMinDomains bool
enableNodeInclusionPolicy bool
enableMatchLabelKeys bool
}{
// note: naming starts at index 0
{
@ -1291,8 +1291,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-4"}, // node-3 is filtered out by NodeAffinity plugin
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-4"}, // node-3 is filtered out by NodeAffinity plugin
enableNodeInclusionPolicy: true,
},
{
name: "NodeAffinityPolicy ignored with nodeAffinity, pods spread across zone as 1/~2~",
@ -1312,8 +1312,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-1", "node-2"},
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-1", "node-2"},
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy honored, pods spread across zone as 2/1",
@ -1333,8 +1333,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Taints(taints).Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-4"}, // node-3 is filtered out by TaintToleration plugin
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-4"}, // node-3 is filtered out by TaintToleration plugin
enableNodeInclusionPolicy: true,
},
{
name: "NodeTaintsPolicy ignored, pods spread across zone as 2/2",
@ -1354,8 +1354,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Taints(taints).Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-1", "node-2", "node-4"}, // node-3 is filtered out by TaintToleration plugin
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-1", "node-2", "node-4"}, // node-3 is filtered out by TaintToleration plugin
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 2/1
@ -1380,8 +1380,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-4"},
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-4"},
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 2/1
@ -1406,8 +1406,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-4"},
enableNodeInclustionPolicy: false,
candidateNodes: []string{"node-4"},
enableNodeInclusionPolicy: false,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as 2/2
@ -1432,8 +1432,8 @@ func TestPodTopologySpreadFilter(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
},
candidateNodes: []string{"node-1", "node-4"},
enableNodeInclustionPolicy: true,
candidateNodes: []string{"node-1", "node-4"},
enableNodeInclusionPolicy: true,
},
{
name: "matchLabelKeys ignored when feature gate disabled, pods spread across zone as 2/1",
@ -1484,7 +1484,7 @@ func TestPodTopologySpreadFilter(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MinDomainsInPodTopologySpread, tt.enableMinDomains)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeInclusionPolicyInPodTopologySpread, tt.enableNodeInclustionPolicy)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeInclusionPolicyInPodTopologySpread, tt.enableNodeInclusionPolicy)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MatchLabelKeysInPodTopologySpread, tt.enableMatchLabelKeys)()
testCtx := initTest(t, "pts-predicate")

View File

@ -442,14 +442,14 @@ func TestPodTopologySpreadScoring(t *testing.T) {
}
tests := []struct {
name string
incomingPod *v1.Pod
existingPods []*v1.Pod
fits bool
nodes []*v1.Node
want []string // nodes expected to schedule onto
enableNodeInclustionPolicy bool
enableMatchLabelKeys bool
name string
incomingPod *v1.Pod
existingPods []*v1.Pod
fits bool
nodes []*v1.Node
want []string // nodes expected to schedule onto
enableNodeInclusionPolicy bool
enableMatchLabelKeys bool
}{
// note: naming starts at index 0
// the symbol ~X~ means that node is infeasible
@ -512,8 +512,8 @@ func TestPodTopologySpreadScoring(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Label("foo", "").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Obj(),
},
want: []string{"node-3"},
enableNodeInclustionPolicy: true,
want: []string{"node-3"},
enableNodeInclusionPolicy: true,
},
{
// 1. to fulfil "zone" constraint, pods spread across zones as ~3~/~1~
@ -538,8 +538,8 @@ func TestPodTopologySpreadScoring(t *testing.T) {
st.MakeNode().Name("node-3").Label("node", "node-3").Label("zone", "zone-2").Label("foo", "").Obj(),
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Obj(),
},
want: []string{"node-3"},
enableNodeInclustionPolicy: true,
want: []string{"node-3"},
enableNodeInclusionPolicy: true,
},
{
name: "matchLabelKeys ignored when feature gate disabled, node-1 is the preferred fit",
@ -598,7 +598,7 @@ func TestPodTopologySpreadScoring(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeInclusionPolicyInPodTopologySpread, tt.enableNodeInclustionPolicy)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeInclusionPolicyInPodTopologySpread, tt.enableNodeInclusionPolicy)()
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MatchLabelKeysInPodTopologySpread, tt.enableMatchLabelKeys)()
testCtx := initTestSchedulerForPriorityTest(t, podtopologyspread.Name)