diff --git a/cypress/e2e/tests/pages/data/agent-configuration-rke2-payload.ts b/cypress/e2e/tests/pages/data/agent-configuration-rke2-payload.ts index 66e8b02f52..f85a68612d 100644 --- a/cypress/e2e/tests/pages/data/agent-configuration-rke2-payload.ts +++ b/cypress/e2e/tests/pages/data/agent-configuration-rke2-payload.ts @@ -10,7 +10,6 @@ export const payloadComparisonData = { { key: 'key1', operator: 'In', - matching: 'matchExpressions', values: [ 'val1' ] @@ -18,7 +17,6 @@ export const payloadComparisonData = { { key: 'key2', operator: 'NotIn', - matching: 'matchExpressions', values: [ 'val2' ] @@ -26,17 +24,14 @@ export const payloadComparisonData = { { key: 'key3', operator: 'Exists', - matching: 'matchExpressions' }, { key: 'key4', operator: 'DoesNotExist', - matching: 'matchExpressions' }, { key: 'key5', operator: 'Lt', - matching: 'matchExpressions', values: [ 'val5' ] @@ -44,13 +39,11 @@ export const payloadComparisonData = { { key: 'key6', operator: 'Gt', - matching: 'matchExpressions', values: [ 'val6' ] } ], - weight: 10 } } ], @@ -61,7 +54,6 @@ export const payloadComparisonData = { { key: 'key1', operator: 'In', - matching: 'matchFields', values: [ 'val1' ] @@ -69,7 +61,6 @@ export const payloadComparisonData = { { key: 'key2', operator: 'NotIn', - matching: 'matchFields', values: [ 'val2' ] @@ -77,17 +68,14 @@ export const payloadComparisonData = { { key: 'key3', operator: 'Exists', - matching: 'matchFields' }, { key: 'key4', operator: 'DoesNotExist', - matching: 'matchFields' }, { key: 'key5', operator: 'Lt', - matching: 'matchFields', values: [ 'val5' ] @@ -95,7 +83,6 @@ export const payloadComparisonData = { { key: 'key6', operator: 'Gt', - matching: 'matchFields', values: [ 'val6' ] @@ -149,7 +136,6 @@ export const payloadComparisonData = { { podAffinityTerm: { namespaces: null, - weight: 10, labelSelector: { matchExpressions: [ { @@ -312,7 +298,6 @@ export const payloadComparisonData = { { key: 'key1', operator: 'In', - matching: 'matchExpressions', values: [ 'val1' ] @@ -320,7 +305,6 @@ export const payloadComparisonData = { { key: 'key2', operator: 'NotIn', - matching: 'matchExpressions', values: [ 'val2' ] @@ -328,17 +312,14 @@ export const payloadComparisonData = { { key: 'key3', operator: 'Exists', - matching: 'matchExpressions' }, { key: 'key4', operator: 'DoesNotExist', - matching: 'matchExpressions' }, { key: 'key5', operator: 'Lt', - matching: 'matchExpressions', values: [ 'val5' ] @@ -346,13 +327,11 @@ export const payloadComparisonData = { { key: 'key6', operator: 'Gt', - matching: 'matchExpressions', values: [ 'val6' ] } ], - weight: 10 } } ], @@ -363,7 +342,6 @@ export const payloadComparisonData = { { key: 'key1', operator: 'In', - matching: 'matchFields', values: [ 'val1' ] @@ -371,7 +349,6 @@ export const payloadComparisonData = { { key: 'key2', operator: 'NotIn', - matching: 'matchFields', values: [ 'val2' ] @@ -379,17 +356,14 @@ export const payloadComparisonData = { { key: 'key3', operator: 'Exists', - matching: 'matchFields' }, { key: 'key4', operator: 'DoesNotExist', - matching: 'matchFields' }, { key: 'key5', operator: 'Lt', - matching: 'matchFields', values: [ 'val5' ] @@ -397,7 +371,6 @@ export const payloadComparisonData = { { key: 'key6', operator: 'Gt', - matching: 'matchFields', values: [ 'val6' ] @@ -528,7 +501,6 @@ export const payloadComparisonData = { { podAffinityTerm: { namespaces: null, - weight: 10, labelSelector: { matchExpressions: [ { diff --git a/shell/components/form/NodeAffinity.vue b/shell/components/form/NodeAffinity.vue index d9b3474d16..27ce7a2fe4 100644 --- a/shell/components/form/NodeAffinity.vue +++ b/shell/components/form/NodeAffinity.vue @@ -95,10 +95,36 @@ export default { const requiredDuringSchedulingIgnoredDuringExecution = { nodeSelectorTerms: [] }; 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) { const neu = { weight: term.weight, preference: term }; + delete neu.preference.weight; + preferredDuringSchedulingIgnoredDuringExecution.push(neu); } else { requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms.push(term); @@ -144,12 +170,8 @@ export default { expressionsMatching[expression.matching || 'matchExpressions'].push(expression); }); - if (expressionsMatching.matchFields.length) { - this.$set(row, 'matchFields', expressionsMatching.matchFields); - } - if (expressionsMatching.matchExpressions.length) { - this.$set(row, 'matchExpressions', expressionsMatching.matchExpressions); - } + this.$set(row, 'matchFields', expressionsMatching.matchFields); + this.$set(row, 'matchExpressions', expressionsMatching.matchExpressions); this.update(); } diff --git a/shell/components/form/PodAffinity.vue b/shell/components/form/PodAffinity.vue index 6d7fbef909..c2425c4d21 100644 --- a/shell/components/form/PodAffinity.vue +++ b/shell/components/form/PodAffinity.vue @@ -230,8 +230,9 @@ export default { this.allSelectorTerms.forEach((term) => { if (term._anti) { 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); } else { podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution.push(term);