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',
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: [
{

View File

@ -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();
}

View File

@ -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);