Do not allow empty topology key for pod affinities.
This commit is contained in:
@@ -4655,8 +4655,8 @@ func TestValidatePod(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
},
|
||||
"invalid pod affinity, empty topologyKey is not allowed for hard pod affinity": {
|
||||
expectedError: "can only be empty for PreferredDuringScheduling pod anti affinity",
|
||||
"invalid hard pod affinity, empty topologyKey is not allowed for hard pod affinity": {
|
||||
expectedError: "can not be empty",
|
||||
spec: api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "123",
|
||||
@@ -4682,8 +4682,8 @@ func TestValidatePod(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
},
|
||||
"invalid pod anti-affinity, empty topologyKey is not allowed for hard pod anti-affinity": {
|
||||
expectedError: "can only be empty for PreferredDuringScheduling pod anti affinity",
|
||||
"invalid hard pod anti-affinity, empty topologyKey is not allowed for hard pod anti-affinity": {
|
||||
expectedError: "can not be empty",
|
||||
spec: api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "123",
|
||||
@@ -4709,8 +4709,8 @@ func TestValidatePod(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
},
|
||||
"invalid pod anti-affinity, empty topologyKey is not allowed for soft pod affinity": {
|
||||
expectedError: "can only be empty for PreferredDuringScheduling pod anti affinity",
|
||||
"invalid soft pod affinity, empty topologyKey is not allowed for soft pod affinity": {
|
||||
expectedError: "can not be empty",
|
||||
spec: api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "123",
|
||||
@@ -4739,6 +4739,36 @@ func TestValidatePod(t *testing.T) {
|
||||
}),
|
||||
},
|
||||
},
|
||||
"invalid soft pod anti-affinity, empty topologyKey is not allowed for soft pod anti-affinity": {
|
||||
expectedError: "can not be empty",
|
||||
spec: api.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "123",
|
||||
Namespace: "ns",
|
||||
},
|
||||
Spec: validPodSpec(&api.Affinity{
|
||||
PodAntiAffinity: &api.PodAntiAffinity{
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: []api.WeightedPodAffinityTerm{
|
||||
{
|
||||
Weight: 10,
|
||||
PodAffinityTerm: api.PodAffinityTerm{
|
||||
LabelSelector: &metav1.LabelSelector{
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{
|
||||
{
|
||||
Key: "key2",
|
||||
Operator: metav1.LabelSelectorOpNotIn,
|
||||
Values: []string{"value1", "value2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
Namespaces: []string{"ns"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
"invalid toleration key": {
|
||||
expectedError: "spec.tolerations[0].key",
|
||||
spec: api.Pod{
|
||||
|
Reference in New Issue
Block a user