|
|
|
|
@@ -68,7 +68,6 @@ func (p *criticalPaths) sort() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPreFilterState(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
pod *v1.Pod
|
|
|
|
|
@@ -78,7 +77,6 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
defaultConstraints []v1.TopologySpreadConstraint
|
|
|
|
|
want *preFilterState
|
|
|
|
|
wantPrefilterStatus *framework.Status
|
|
|
|
|
enableMinDomains bool
|
|
|
|
|
enableNodeInclusionPolicy bool
|
|
|
|
|
enableMatchLabelKeys bool
|
|
|
|
|
}{
|
|
|
|
|
@@ -104,6 +102,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 0}, {"zone2", 0}},
|
|
|
|
|
},
|
|
|
|
|
@@ -142,6 +141,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 2}, {"zone1", 3}},
|
|
|
|
|
},
|
|
|
|
|
@@ -180,6 +180,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 0}},
|
|
|
|
|
},
|
|
|
|
|
@@ -220,6 +221,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone3", 0}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -259,6 +261,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {"zone1", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -308,6 +311,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 4},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 3}, {"zone2", 4}},
|
|
|
|
|
"node": {{"node-x", 0}, {"node-b", 1}},
|
|
|
|
|
@@ -363,6 +367,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 3}, {"zone2", 4}},
|
|
|
|
|
"node": {{"node-b", 1}, {"node-a", 2}},
|
|
|
|
|
@@ -410,6 +415,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 1}},
|
|
|
|
|
"node": {{"node-a", 0}, {"node-y", 0}},
|
|
|
|
|
@@ -462,6 +468,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 3}, {"zone2", 4}},
|
|
|
|
|
"node": {{"node-b", 0}, {"node-a", 1}},
|
|
|
|
|
@@ -516,6 +523,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 3}, {"zone2", 4}},
|
|
|
|
|
"node": {{"node-b", 1}, {"node-a", 2}},
|
|
|
|
|
@@ -559,6 +567,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": newCriticalPaths(),
|
|
|
|
|
"rack": newCriticalPaths(),
|
|
|
|
|
@@ -600,6 +609,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": newCriticalPaths(),
|
|
|
|
|
},
|
|
|
|
|
@@ -638,7 +648,6 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
st.MakePod().Name("p-y3").Node("node-y").Label("foo", "").Obj(),
|
|
|
|
|
st.MakePod().Name("p-y4").Node("node-y").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
enableMinDomains: true,
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{
|
|
|
|
|
{
|
|
|
|
|
@@ -704,6 +713,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -742,6 +752,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -780,6 +791,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-c", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -819,6 +831,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -857,6 +870,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-c", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -895,6 +909,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-c", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -933,6 +948,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-c", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -971,6 +987,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyHonor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1009,6 +1026,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyHonor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-c", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1056,6 +1074,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 0}, {"zone2", 1}},
|
|
|
|
|
"node": {{"node-a", 0}, {"node-x", 1}},
|
|
|
|
|
@@ -1105,6 +1124,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 0}, {"zone2", 1}},
|
|
|
|
|
"node": {{"node-a", 0}, {"node-x", 1}},
|
|
|
|
|
@@ -1157,6 +1177,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 0}, {"zone2", 1}},
|
|
|
|
|
"node": {{"node-b", 0}, {"node-x", 1}},
|
|
|
|
|
@@ -1209,6 +1230,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyHonor,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 2}, {"zone2", 3}},
|
|
|
|
|
"node": {{"node-y", 1}, {"node-x", 2}},
|
|
|
|
|
@@ -1251,6 +1273,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 2}, {"zone1", 3}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1290,6 +1313,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {"zone1", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1329,6 +1353,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 2}, {"zone1", 3}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1368,6 +1393,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 0}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1407,6 +1433,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 0}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1445,6 +1472,7 @@ func TestPreFilterState(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 2}, {"zone1", 3}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1475,7 +1503,6 @@ 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.enableNodeInclusionPolicy
|
|
|
|
|
p.(*PodTopologySpread).enableMatchLabelKeysInPodTopologySpread = tt.enableMatchLabelKeys
|
|
|
|
|
|
|
|
|
|
@@ -1534,7 +1561,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone1").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-b", 0}, {"node-a", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1559,7 +1587,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone1").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1584,7 +1613,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone1").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 0}, {"node-b", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1609,7 +1639,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone1").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"node": {{"node-a", 0}, {"node-b", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1633,7 +1664,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-x").Label("zone", "zone2").Label("node", "node-x").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 1}},
|
|
|
|
|
"node": {{"node-x", 0}, {"node-a", 1}},
|
|
|
|
|
@@ -1662,7 +1694,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-x").Label("zone", "zone2").Label("node", "node-x").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 1}},
|
|
|
|
|
"node": {{"node-a", 1}, {"node-x", 1}},
|
|
|
|
|
@@ -1694,7 +1727,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-x").Label("zone", "zone2").Label("node", "node-x").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {"zone1", 3}},
|
|
|
|
|
"node": {{"node-a", 1}, {"node-x", 1}},
|
|
|
|
|
@@ -1738,6 +1772,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {"zone1", 2}},
|
|
|
|
|
"node": {{"node-a", 0}, {"node-b", 1}},
|
|
|
|
|
@@ -1781,6 +1816,7 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
NodeTaintsPolicy: v1.NodeInclusionPolicyIgnore,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 1}},
|
|
|
|
|
"node": {{"node-a", 1}, {"node-b", 1}},
|
|
|
|
|
@@ -1810,7 +1846,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 1},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {MatchNum: math.MaxInt32}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1836,7 +1873,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 1},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {MatchNum: math.MaxInt32}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1862,7 +1900,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1889,7 +1928,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1916,7 +1956,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1943,7 +1984,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -1970,7 +2012,8 @@ func TestPreFilterStateAddPod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2054,7 +2097,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
deletedPodIdx: 0, // remove pod "p-a1"
|
|
|
|
|
nodeIdx: 0, // node-a
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2084,7 +2128,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
deletedPodIdx: 0, // remove pod "p-a1"
|
|
|
|
|
nodeIdx: 0, // node-a
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 1}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2115,7 +2160,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
deletedPodIdx: 0, // remove pod "p-a0"
|
|
|
|
|
nodeIdx: 0, // node-a
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 2}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2146,7 +2192,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
deletedPod: st.MakePod().Name("p-a0").Node("node-a").Label("bar", "").Obj(),
|
|
|
|
|
nodeIdx: 0, // node-a
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone1", 2}, {"zone2", 2}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2177,7 +2224,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
deletedPodIdx: 3, // remove pod "p-x1"
|
|
|
|
|
nodeIdx: 2, // node-x
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint, nodeConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2, "node": 3},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {"zone1", 3}},
|
|
|
|
|
"node": {{"node-b", 1}, {"node-x", 1}},
|
|
|
|
|
@@ -2207,7 +2255,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 1},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {MatchNum: math.MaxInt32}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2233,7 +2282,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 1},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 1}, {MatchNum: math.MaxInt32}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2259,7 +2309,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2286,7 +2337,8 @@ func TestPreFilterStateRemovePod(t *testing.T) {
|
|
|
|
|
st.MakeNode().Name("node-b").Label("zone", "zone2").Label("node", "node-b").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
want: &preFilterState{
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
Constraints: []topologySpreadConstraint{zoneConstraint},
|
|
|
|
|
TpKeyToDomainsNum: map[string]int{"zone": 2},
|
|
|
|
|
TpKeyToCriticalPaths: map[string]*criticalPaths{
|
|
|
|
|
"zone": {{"zone2", 0}, {"zone1", 1}},
|
|
|
|
|
},
|
|
|
|
|
@@ -2416,7 +2468,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
nodes []*v1.Node
|
|
|
|
|
existingPods []*v1.Pod
|
|
|
|
|
wantStatusCode map[string]framework.Code
|
|
|
|
|
enableMinDomains bool
|
|
|
|
|
enableNodeInclusionPolicy bool
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
@@ -2748,7 +2799,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
st.MakePod().Name("p-b2").Node("node-b").Label("foo", "").Obj(),
|
|
|
|
|
st.MakePod().Name("p-c1").Node("node-c").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
enableMinDomains: true,
|
|
|
|
|
wantStatusCode: map[string]framework.Code{
|
|
|
|
|
"node-a": framework.Unschedulable,
|
|
|
|
|
"node-b": framework.Unschedulable,
|
|
|
|
|
@@ -2779,7 +2829,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
st.MakePod().Name("p-b2").Node("node-b").Label("foo", "").Obj(),
|
|
|
|
|
st.MakePod().Name("p-c1").Node("node-c").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
enableMinDomains: true,
|
|
|
|
|
wantStatusCode: map[string]framework.Code{
|
|
|
|
|
"node-a": framework.Success,
|
|
|
|
|
"node-b": framework.Success,
|
|
|
|
|
@@ -2809,7 +2858,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
st.MakePod().Name("p-b2").Node("node-b").Label("foo", "").Obj(),
|
|
|
|
|
st.MakePod().Name("p-y1").Node("node-y").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
enableMinDomains: true,
|
|
|
|
|
wantStatusCode: map[string]framework.Code{
|
|
|
|
|
"node-a": framework.Unschedulable,
|
|
|
|
|
"node-b": framework.Unschedulable,
|
|
|
|
|
@@ -2840,7 +2888,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
st.MakePod().Name("p-b2").Node("node-b").Label("foo", "").Obj(),
|
|
|
|
|
st.MakePod().Name("p-y1").Node("node-y").Label("foo", "").Obj(),
|
|
|
|
|
},
|
|
|
|
|
enableMinDomains: true,
|
|
|
|
|
wantStatusCode: map[string]framework.Code{
|
|
|
|
|
"node-a": framework.Success,
|
|
|
|
|
"node-b": framework.Success,
|
|
|
|
|
@@ -3009,7 +3056,6 @@ func TestSingleConstraint(t *testing.T) {
|
|
|
|
|
snapshot := cache.NewSnapshot(tt.existingPods, tt.nodes)
|
|
|
|
|
pl := plugintesting.SetupPlugin(ctx, t, topologySpreadFunc, &config.PodTopologySpreadArgs{DefaultingType: config.ListDefaulting}, snapshot)
|
|
|
|
|
p := pl.(*PodTopologySpread)
|
|
|
|
|
p.enableMinDomainsInPodTopologySpread = tt.enableMinDomains
|
|
|
|
|
p.enableNodeInclusionPolicyInPodTopologySpread = tt.enableNodeInclusionPolicy
|
|
|
|
|
state := framework.NewCycleState()
|
|
|
|
|
if _, s := p.PreFilter(ctx, state, tt.pod); !s.IsSuccess() {
|
|
|
|
|
|