Fix malformed pod affinity and node affinity terms (#9011)

* remove extra weight field from matchExpressions[].preference

* remove extra weight field from podAffinityTerm

* fix fleetAgentDeploymentCustomization payload data

* remove ui-only matching field from matchexpression and matchfield terms

* rm cypress numTestsKeptInMemory config change
This commit is contained in:
Nancy 2023-05-31 10:51:38 -07:00 committed by GitHub
parent 527abd91bd
commit 786dc75822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 36 deletions

View File

@ -10,7 +10,6 @@ export const payloadComparisonData = {
{ {
key: 'key1', key: 'key1',
operator: 'In', operator: 'In',
matching: 'matchExpressions',
values: [ values: [
'val1' 'val1'
] ]
@ -18,7 +17,6 @@ export const payloadComparisonData = {
{ {
key: 'key2', key: 'key2',
operator: 'NotIn', operator: 'NotIn',
matching: 'matchExpressions',
values: [ values: [
'val2' 'val2'
] ]
@ -26,17 +24,14 @@ export const payloadComparisonData = {
{ {
key: 'key3', key: 'key3',
operator: 'Exists', operator: 'Exists',
matching: 'matchExpressions'
}, },
{ {
key: 'key4', key: 'key4',
operator: 'DoesNotExist', operator: 'DoesNotExist',
matching: 'matchExpressions'
}, },
{ {
key: 'key5', key: 'key5',
operator: 'Lt', operator: 'Lt',
matching: 'matchExpressions',
values: [ values: [
'val5' 'val5'
] ]
@ -44,13 +39,11 @@ export const payloadComparisonData = {
{ {
key: 'key6', key: 'key6',
operator: 'Gt', operator: 'Gt',
matching: 'matchExpressions',
values: [ values: [
'val6' 'val6'
] ]
} }
], ],
weight: 10
} }
} }
], ],
@ -61,7 +54,6 @@ export const payloadComparisonData = {
{ {
key: 'key1', key: 'key1',
operator: 'In', operator: 'In',
matching: 'matchFields',
values: [ values: [
'val1' 'val1'
] ]
@ -69,7 +61,6 @@ export const payloadComparisonData = {
{ {
key: 'key2', key: 'key2',
operator: 'NotIn', operator: 'NotIn',
matching: 'matchFields',
values: [ values: [
'val2' 'val2'
] ]
@ -77,17 +68,14 @@ export const payloadComparisonData = {
{ {
key: 'key3', key: 'key3',
operator: 'Exists', operator: 'Exists',
matching: 'matchFields'
}, },
{ {
key: 'key4', key: 'key4',
operator: 'DoesNotExist', operator: 'DoesNotExist',
matching: 'matchFields'
}, },
{ {
key: 'key5', key: 'key5',
operator: 'Lt', operator: 'Lt',
matching: 'matchFields',
values: [ values: [
'val5' 'val5'
] ]
@ -95,7 +83,6 @@ export const payloadComparisonData = {
{ {
key: 'key6', key: 'key6',
operator: 'Gt', operator: 'Gt',
matching: 'matchFields',
values: [ values: [
'val6' 'val6'
] ]
@ -149,7 +136,6 @@ export const payloadComparisonData = {
{ {
podAffinityTerm: { podAffinityTerm: {
namespaces: null, namespaces: null,
weight: 10,
labelSelector: { labelSelector: {
matchExpressions: [ matchExpressions: [
{ {
@ -312,7 +298,6 @@ export const payloadComparisonData = {
{ {
key: 'key1', key: 'key1',
operator: 'In', operator: 'In',
matching: 'matchExpressions',
values: [ values: [
'val1' 'val1'
] ]
@ -320,7 +305,6 @@ export const payloadComparisonData = {
{ {
key: 'key2', key: 'key2',
operator: 'NotIn', operator: 'NotIn',
matching: 'matchExpressions',
values: [ values: [
'val2' 'val2'
] ]
@ -328,17 +312,14 @@ export const payloadComparisonData = {
{ {
key: 'key3', key: 'key3',
operator: 'Exists', operator: 'Exists',
matching: 'matchExpressions'
}, },
{ {
key: 'key4', key: 'key4',
operator: 'DoesNotExist', operator: 'DoesNotExist',
matching: 'matchExpressions'
}, },
{ {
key: 'key5', key: 'key5',
operator: 'Lt', operator: 'Lt',
matching: 'matchExpressions',
values: [ values: [
'val5' 'val5'
] ]
@ -346,13 +327,11 @@ export const payloadComparisonData = {
{ {
key: 'key6', key: 'key6',
operator: 'Gt', operator: 'Gt',
matching: 'matchExpressions',
values: [ values: [
'val6' 'val6'
] ]
} }
], ],
weight: 10
} }
} }
], ],
@ -363,7 +342,6 @@ export const payloadComparisonData = {
{ {
key: 'key1', key: 'key1',
operator: 'In', operator: 'In',
matching: 'matchFields',
values: [ values: [
'val1' 'val1'
] ]
@ -371,7 +349,6 @@ export const payloadComparisonData = {
{ {
key: 'key2', key: 'key2',
operator: 'NotIn', operator: 'NotIn',
matching: 'matchFields',
values: [ values: [
'val2' 'val2'
] ]
@ -379,17 +356,14 @@ export const payloadComparisonData = {
{ {
key: 'key3', key: 'key3',
operator: 'Exists', operator: 'Exists',
matching: 'matchFields'
}, },
{ {
key: 'key4', key: 'key4',
operator: 'DoesNotExist', operator: 'DoesNotExist',
matching: 'matchFields'
}, },
{ {
key: 'key5', key: 'key5',
operator: 'Lt', operator: 'Lt',
matching: 'matchFields',
values: [ values: [
'val5' 'val5'
] ]
@ -397,7 +371,6 @@ export const payloadComparisonData = {
{ {
key: 'key6', key: 'key6',
operator: 'Gt', operator: 'Gt',
matching: 'matchFields',
values: [ values: [
'val6' 'val6'
] ]
@ -528,7 +501,6 @@ export const payloadComparisonData = {
{ {
podAffinityTerm: { podAffinityTerm: {
namespaces: null, namespaces: null,
weight: 10,
labelSelector: { labelSelector: {
matchExpressions: [ matchExpressions: [
{ {

View File

@ -95,10 +95,36 @@ export default {
const requiredDuringSchedulingIgnoredDuringExecution = { nodeSelectorTerms: [] }; const requiredDuringSchedulingIgnoredDuringExecution = { nodeSelectorTerms: [] };
const preferredDuringSchedulingIgnoredDuringExecution = [] ; const preferredDuringSchedulingIgnoredDuringExecution = [] ;
this.allSelectorTerms.forEach((term) => { this.allSelectorTerms.forEach((t) => {
const term = { ...t };
// the 'matching' field isn't part of the affinity spec: including this in the save request will cause a flood of errors that might cause the request to fail
// same deal with term.preference.weight
if (term.matchExpressions) {
term.matchExpressions = (term.matchExpressions || []).map((expression) => {
const out = { ...expression };
delete out.matching;
return out;
});
}
if (term.matchFields) {
term.matchFields = (term.matchFields || []).map((field) => {
const out = { ...field };
delete out.matching;
return out;
});
}
if (term.weight) { if (term.weight) {
const neu = { weight: term.weight, preference: term }; const neu = { weight: term.weight, preference: term };
delete neu.preference.weight;
preferredDuringSchedulingIgnoredDuringExecution.push(neu); preferredDuringSchedulingIgnoredDuringExecution.push(neu);
} else { } else {
requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.push(term); requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.push(term);
@ -144,12 +170,8 @@ export default {
expressionsMatching[expression.matching || 'matchExpressions'].push(expression); expressionsMatching[expression.matching || 'matchExpressions'].push(expression);
}); });
if (expressionsMatching.matchFields.length) { this.$set(row, 'matchFields', expressionsMatching.matchFields);
this.$set(row, 'matchFields', expressionsMatching.matchFields); this.$set(row, 'matchExpressions', expressionsMatching.matchExpressions);
}
if (expressionsMatching.matchExpressions.length) {
this.$set(row, 'matchExpressions', expressionsMatching.matchExpressions);
}
this.update(); this.update();
} }

View File

@ -230,8 +230,9 @@ export default {
this.allSelectorTerms.forEach((term) => { this.allSelectorTerms.forEach((term) => {
if (term._anti) { if (term._anti) {
if (term.weight) { if (term.weight) {
const neu = { podAffinityTerm: term, weight: term.weight || this.defaultWeight }; const neu = { podAffinityTerm: { ...term }, weight: term.weight || this.defaultWeight };
delete neu.podAffinityTerm.weight;
podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution.push(neu); podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution.push(neu);
} else { } else {
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.push(term); podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.push(term);