mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
typo fixed
Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
parent
ef56451ae5
commit
55dcde737d
@ -69,16 +69,16 @@ func (p *criticalPaths) sort() {
|
|||||||
func TestPreFilterState(t *testing.T) {
|
func TestPreFilterState(t *testing.T) {
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
objs []runtime.Object
|
objs []runtime.Object
|
||||||
defaultConstraints []v1.TopologySpreadConstraint
|
defaultConstraints []v1.TopologySpreadConstraint
|
||||||
want *preFilterState
|
want *preFilterState
|
||||||
enableMinDomains bool
|
enableMinDomains bool
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
enableMatchLabelKeys bool
|
enableMatchLabelKeys bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "clean cluster with one spreadConstraint",
|
name: "clean cluster with one spreadConstraint",
|
||||||
@ -672,7 +672,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-b"}: 2,
|
{key: "node", value: "node-b"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy honored with labelSelectors",
|
name: "NodeAffinityPolicy honored with labelSelectors",
|
||||||
@ -710,7 +710,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-b"}: 2,
|
{key: "node", value: "node-b"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with labelSelectors",
|
name: "NodeAffinityPolicy ignored with labelSelectors",
|
||||||
@ -749,7 +749,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-c"}: 0,
|
{key: "node", value: "node-c"}: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy honored with nodeAffinity",
|
name: "NodeAffinityPolicy honored with nodeAffinity",
|
||||||
@ -787,7 +787,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-b"}: 2,
|
{key: "node", value: "node-b"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
||||||
@ -826,7 +826,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-c"}: 0,
|
{key: "node", value: "node-c"}: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "feature gate disabled with NodeTaintsPolicy",
|
name: "feature gate disabled with NodeTaintsPolicy",
|
||||||
@ -864,7 +864,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-c"}: 0,
|
{key: "node", value: "node-c"}: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy ignored",
|
name: "NodeTaintsPolicy ignored",
|
||||||
@ -902,7 +902,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-c"}: 0,
|
{key: "node", value: "node-c"}: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy honored",
|
name: "NodeTaintsPolicy honored",
|
||||||
@ -939,7 +939,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-b"}: 2,
|
{key: "node", value: "node-b"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy honored with tolerated taints",
|
name: "NodeTaintsPolicy honored with tolerated taints",
|
||||||
@ -978,7 +978,7 @@ func TestPreFilterState(t *testing.T) {
|
|||||||
{key: "node", value: "node-c"}: 0,
|
{key: "node", value: "node-c"}: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two node inclusion Constraints, zone: honor/ignore, node: ignore/ignore",
|
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,
|
{key: "node", value: "node-x"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two node inclusion Constraints, zone: honor/honor, node: honor/ignore",
|
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,
|
{key: "node", value: "node-x"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two node inclusion Constraints, zone: honor/ignore, node: honor/ignore",
|
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,
|
{key: "node", value: "node-x"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two node inclusion Constraints, zone: ignore/ignore, node: honor/honor",
|
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,
|
{key: "node", value: "node-y"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "matchLabelKeys ignored when feature gate disabled",
|
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 := plugintesting.SetupPluginWithInformers(ctx, t, topologySpreadFunc, args, cache.NewSnapshot(tt.existingPods, tt.nodes), tt.objs)
|
||||||
p.(*PodTopologySpread).enableMinDomainsInPodTopologySpread = tt.enableMinDomains
|
p.(*PodTopologySpread).enableMinDomainsInPodTopologySpread = tt.enableMinDomains
|
||||||
p.(*PodTopologySpread).enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.(*PodTopologySpread).enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
p.(*PodTopologySpread).enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
|
p.(*PodTopologySpread).enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
|
||||||
|
|
||||||
cs := framework.NewCycleState()
|
cs := framework.NewCycleState()
|
||||||
@ -1380,14 +1380,14 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|||||||
zoneConstraint := nodeConstraint
|
zoneConstraint := nodeConstraint
|
||||||
zoneConstraint.TopologyKey = "zone"
|
zoneConstraint.TopologyKey = "zone"
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
preemptor *v1.Pod
|
preemptor *v1.Pod
|
||||||
addedPod *v1.Pod
|
addedPod *v1.Pod
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
nodeIdx int // denotes which node 'addedPod' belongs to
|
nodeIdx int // denotes which node 'addedPod' belongs to
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
want *preFilterState
|
want *preFilterState
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "node a and b both impact current min match",
|
name: "node a and b both impact current min match",
|
||||||
@ -1686,7 +1686,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|||||||
{key: "zone", value: "zone2"}: 1,
|
{key: "zone", value: "zone2"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a pod when scheduling node affinity unmatched pod with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone2"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a pod when scheduling node affinity matched pod with NodeInclusionPolicy disabled",
|
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,
|
{key: "zone", value: "zone2"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a pod when scheduling node affinity matched pod with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone2"}: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a label selector not matched pod when with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone2"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a pod when scheduling taint untolerated pod with NodeInclusionPolicy disabled",
|
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,
|
{key: "zone", value: "zone1"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "add a pod when scheduling taint tolerated pod with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone1"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -1856,7 +1856,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|||||||
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
||||||
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
||||||
p := pl.(*PodTopologySpread)
|
p := pl.(*PodTopologySpread)
|
||||||
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
|
|
||||||
cs := framework.NewCycleState()
|
cs := framework.NewCycleState()
|
||||||
if _, s := p.PreFilter(ctx, cs, tt.preemptor); !s.IsSuccess() {
|
if _, s := p.PreFilter(ctx, cs, tt.preemptor); !s.IsSuccess() {
|
||||||
@ -1892,15 +1892,15 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|||||||
zoneConstraint := nodeConstraint
|
zoneConstraint := nodeConstraint
|
||||||
zoneConstraint.TopologyKey = "zone"
|
zoneConstraint.TopologyKey = "zone"
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
preemptor *v1.Pod // preemptor pod
|
preemptor *v1.Pod // preemptor pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
deletedPodIdx int // need to reuse *Pod of existingPods[i]
|
deletedPodIdx int // need to reuse *Pod of existingPods[i]
|
||||||
deletedPod *v1.Pod // this field is used only when deletedPodIdx is -1
|
deletedPod *v1.Pod // this field is used only when deletedPodIdx is -1
|
||||||
nodeIdx int // denotes which node "deletedPod" belongs to
|
nodeIdx int // denotes which node "deletedPod" belongs to
|
||||||
want *preFilterState
|
want *preFilterState
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
// A high priority pod may not be scheduled due to node taints or resource shortage.
|
// 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,
|
{key: "zone", value: "zone2"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove a pod when scheduling node affinity unmatched pod with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone2"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove a pod when scheduling node affinity matched pod with NodeInclusionPolicy disabled",
|
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,
|
{key: "zone", value: "zone1"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "remove a pod when scheduling node affinity matched pod with NodeInclusionPolicy enabled",
|
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,
|
{key: "zone", value: "zone1"}: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -2172,7 +2172,7 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|||||||
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
||||||
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
||||||
p := pl.(*PodTopologySpread)
|
p := pl.(*PodTopologySpread)
|
||||||
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
|
|
||||||
cs := framework.NewCycleState()
|
cs := framework.NewCycleState()
|
||||||
if _, s := p.PreFilter(ctx, cs, tt.preemptor); !s.IsSuccess() {
|
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) {
|
func TestSingleConstraint(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
wantStatusCode map[string]framework.Code
|
wantStatusCode map[string]framework.Code
|
||||||
enableMinDomains bool
|
enableMinDomains bool
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no existing pods",
|
name: "no existing pods",
|
||||||
@ -2718,7 +2718,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Success, // in real case, when we disable NodeAffinity Plugin, node-y will be 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~
|
// pods spread across node as 1/1/0/~1~
|
||||||
@ -2744,7 +2744,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// pods spread across node as 1/1/0/~0~
|
// pods spread across node as 1/1/0/~0~
|
||||||
@ -2770,7 +2770,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Success, // in real case, when we disable NodeAffinity Plugin, node-y will be 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~
|
// pods spread across node as 1/1/0/~1~
|
||||||
@ -2796,7 +2796,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// pods spread across node as 1/1/0/~0~
|
// pods spread across node as 1/1/0/~0~
|
||||||
@ -2821,7 +2821,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Success, // in real case, when we disable TaintToleration Plugin, node-y will be 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~
|
// pods spread across node as 1/1/0/~1~
|
||||||
@ -2846,7 +2846,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
"node-x": framework.Success,
|
"node-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -2855,7 +2855,7 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
||||||
p := pl.(*PodTopologySpread)
|
p := pl.(*PodTopologySpread)
|
||||||
p.enableMinDomainsInPodTopologySpread = tt.enableMinDomains
|
p.enableMinDomainsInPodTopologySpread = tt.enableMinDomains
|
||||||
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
state := framework.NewCycleState()
|
state := framework.NewCycleState()
|
||||||
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
|
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
|
||||||
t.Errorf("preFilter failed with status: %v", s)
|
t.Errorf("preFilter failed with status: %v", s)
|
||||||
@ -2874,12 +2874,12 @@ func TestSingleConstraint(t *testing.T) {
|
|||||||
|
|
||||||
func TestMultipleConstraints(t *testing.T) {
|
func TestMultipleConstraints(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
wantStatusCode map[string]framework.Code
|
wantStatusCode map[string]framework.Code
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, incoming pod can be placed on any zone (hence any node)
|
// 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-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 2/0
|
// 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-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 1/~1~
|
// 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-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 1/0
|
// 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-x": framework.Success,
|
||||||
"node-y": framework.Unschedulable,
|
"node-y": framework.Unschedulable,
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -3198,7 +3198,7 @@ func TestMultipleConstraints(t *testing.T) {
|
|||||||
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
||||||
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
pl := plugintesting.SetupPlugin(t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
||||||
p := pl.(*PodTopologySpread)
|
p := pl.(*PodTopologySpread)
|
||||||
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
state := framework.NewCycleState()
|
state := framework.NewCycleState()
|
||||||
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
|
if _, s := p.PreFilter(context.Background(), state, tt.pod); !s.IsSuccess() {
|
||||||
t.Errorf("preFilter failed with status: %v", s)
|
t.Errorf("preFilter failed with status: %v", s)
|
||||||
|
@ -43,13 +43,13 @@ var podTopologySpreadFunc = frameworkruntime.FactoryAdapter(feature.Features{},
|
|||||||
|
|
||||||
func TestPreScoreStateEmptyNodes(t *testing.T) {
|
func TestPreScoreStateEmptyNodes(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
objs []runtime.Object
|
objs []runtime.Object
|
||||||
config config.PodTopologySpreadArgs
|
config config.PodTopologySpreadArgs
|
||||||
want *preScoreState
|
want *preScoreState
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "normal case",
|
name: "normal case",
|
||||||
@ -321,7 +321,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with labelSelectors",
|
name: "NodeAffinityPolicy ignored with labelSelectors",
|
||||||
@ -355,7 +355,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy honored with nodeAffinity",
|
name: "NodeAffinityPolicy honored with nodeAffinity",
|
||||||
@ -389,7 +389,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
||||||
@ -423,7 +423,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy honored",
|
name: "NodeTaintsPolicy honored",
|
||||||
@ -456,7 +456,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy ignored",
|
name: "NodeTaintsPolicy ignored",
|
||||||
@ -489,7 +489,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
TopologyNormalizingWeight: []float64{topologyNormalizingWeight(2)},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -503,7 +503,7 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating framework runtime: %v", err)
|
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 {
|
if err != nil {
|
||||||
t.Fatalf("Failed creating plugin: %v", err)
|
t.Fatalf("Failed creating plugin: %v", err)
|
||||||
}
|
}
|
||||||
@ -528,15 +528,15 @@ func TestPreScoreStateEmptyNodes(t *testing.T) {
|
|||||||
|
|
||||||
func TestPodTopologySpreadScore(t *testing.T) {
|
func TestPodTopologySpreadScore(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
failedNodes []*v1.Node // nodes + failedNodes = all nodes
|
failedNodes []*v1.Node // nodes + failedNodes = all nodes
|
||||||
objs []runtime.Object
|
objs []runtime.Object
|
||||||
want framework.NodeScoreList
|
want framework.NodeScoreList
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
enableMatchLabelKeys bool
|
enableMatchLabelKeys bool
|
||||||
}{
|
}{
|
||||||
// Explanation on the Legend:
|
// Explanation on the Legend:
|
||||||
// a) X/Y means there are X matching pods on node1 and Y on node2, both nodes are candidates
|
// 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-b", Score: 33},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with labelSelectors",
|
name: "NodeAffinityPolicy ignored with labelSelectors",
|
||||||
@ -1053,7 +1053,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
{Name: "node-b", Score: 100},
|
{Name: "node-b", Score: 100},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy honoed with nodeAffinity",
|
name: "NodeAffinityPolicy honoed with nodeAffinity",
|
||||||
@ -1077,7 +1077,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
{Name: "node-b", Score: 33},
|
{Name: "node-b", Score: 33},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
name: "NodeAffinityPolicy ignored with nodeAffinity",
|
||||||
@ -1101,7 +1101,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
{Name: "node-b", Score: 100},
|
{Name: "node-b", Score: 100},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy honored",
|
name: "NodeTaintsPolicy honored",
|
||||||
@ -1124,7 +1124,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
{Name: "node-b", Score: 33},
|
{Name: "node-b", Score: 33},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy ignored",
|
name: "NodeTaintsPolicy ignored",
|
||||||
@ -1147,7 +1147,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
{Name: "node-b", Score: 100},
|
{Name: "node-b", Score: 100},
|
||||||
{Name: "node-c", Score: 100},
|
{Name: "node-c", Score: 100},
|
||||||
},
|
},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "matchLabelKeys ignored when feature gate disabled",
|
name: "matchLabelKeys ignored when feature gate disabled",
|
||||||
@ -1238,7 +1238,7 @@ func TestPodTopologySpreadScore(t *testing.T) {
|
|||||||
state := framework.NewCycleState()
|
state := framework.NewCycleState()
|
||||||
pl := plugintesting.SetupPluginWithInformers(ctx, t, podTopologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.SystemDefaulting}, cache.NewSnapshot(tt.existingPods, allNodes), tt.objs)
|
pl := plugintesting.SetupPluginWithInformers(ctx, t, podTopologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.SystemDefaulting}, cache.NewSnapshot(tt.existingPods, allNodes), tt.objs)
|
||||||
p := pl.(*PodTopologySpread)
|
p := pl.(*PodTopologySpread)
|
||||||
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclustionPolicy
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
||||||
p.enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
|
p.enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
|
||||||
|
|
||||||
status := p.PreScore(context.Background(), state, tt.pod, tt.nodes)
|
status := p.PreScore(context.Background(), state, tt.pod, tt.nodes)
|
||||||
|
@ -1068,15 +1068,15 @@ func TestPodTopologySpreadFilter(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
incomingPod *v1.Pod
|
incomingPod *v1.Pod
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
fits bool
|
fits bool
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
candidateNodes []string // nodes expected to schedule onto
|
candidateNodes []string // nodes expected to schedule onto
|
||||||
enableMinDomains bool
|
enableMinDomains bool
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
enableMatchLabelKeys bool
|
enableMatchLabelKeys bool
|
||||||
}{
|
}{
|
||||||
// note: naming starts at index 0
|
// 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-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(),
|
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
|
candidateNodes: []string{"node-4"}, // node-3 is filtered out by NodeAffinity plugin
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeAffinityPolicy ignored with nodeAffinity, pods spread across zone as 1/~2~",
|
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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
|
||||||
},
|
},
|
||||||
candidateNodes: []string{"node-1", "node-2"},
|
candidateNodes: []string{"node-1", "node-2"},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy honored, pods spread across zone as 2/1",
|
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-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(),
|
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
|
candidateNodes: []string{"node-4"}, // node-3 is filtered out by TaintToleration plugin
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "NodeTaintsPolicy ignored, pods spread across zone as 2/2",
|
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-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(),
|
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
|
candidateNodes: []string{"node-1", "node-2", "node-4"}, // node-3 is filtered out by TaintToleration plugin
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 2/1
|
// 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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
|
||||||
},
|
},
|
||||||
candidateNodes: []string{"node-4"},
|
candidateNodes: []string{"node-4"},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 2/1
|
// 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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
|
||||||
},
|
},
|
||||||
candidateNodes: []string{"node-4"},
|
candidateNodes: []string{"node-4"},
|
||||||
enableNodeInclustionPolicy: false,
|
enableNodeInclusionPolicy: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as 2/2
|
// 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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Label("foo", "").Obj(),
|
||||||
},
|
},
|
||||||
candidateNodes: []string{"node-1", "node-4"},
|
candidateNodes: []string{"node-1", "node-4"},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "matchLabelKeys ignored when feature gate disabled, pods spread across zone as 2/1",
|
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 {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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.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)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MatchLabelKeysInPodTopologySpread, tt.enableMatchLabelKeys)()
|
||||||
|
|
||||||
testCtx := initTest(t, "pts-predicate")
|
testCtx := initTest(t, "pts-predicate")
|
||||||
|
@ -442,14 +442,14 @@ func TestPodTopologySpreadScoring(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
incomingPod *v1.Pod
|
incomingPod *v1.Pod
|
||||||
existingPods []*v1.Pod
|
existingPods []*v1.Pod
|
||||||
fits bool
|
fits bool
|
||||||
nodes []*v1.Node
|
nodes []*v1.Node
|
||||||
want []string // nodes expected to schedule onto
|
want []string // nodes expected to schedule onto
|
||||||
enableNodeInclustionPolicy bool
|
enableNodeInclusionPolicy bool
|
||||||
enableMatchLabelKeys bool
|
enableMatchLabelKeys bool
|
||||||
}{
|
}{
|
||||||
// note: naming starts at index 0
|
// note: naming starts at index 0
|
||||||
// the symbol ~X~ means that node is infeasible
|
// 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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Obj(),
|
||||||
},
|
},
|
||||||
want: []string{"node-3"},
|
want: []string{"node-3"},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// 1. to fulfil "zone" constraint, pods spread across zones as ~3~/~1~
|
// 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-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(),
|
st.MakeNode().Name("node-4").Label("node", "node-4").Label("zone", "zone-2").Obj(),
|
||||||
},
|
},
|
||||||
want: []string{"node-3"},
|
want: []string{"node-3"},
|
||||||
enableNodeInclustionPolicy: true,
|
enableNodeInclusionPolicy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "matchLabelKeys ignored when feature gate disabled, node-1 is the preferred fit",
|
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 {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
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)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.MatchLabelKeysInPodTopologySpread, tt.enableMatchLabelKeys)()
|
||||||
|
|
||||||
testCtx := initTestSchedulerForPriorityTest(t, podtopologyspread.Name)
|
testCtx := initTestSchedulerForPriorityTest(t, podtopologyspread.Name)
|
||||||
|
Loading…
Reference in New Issue
Block a user