mirror of https://github.com/portainer/portainer
fix(placements) filter out empty items in the required node affinity array [BE-11022] (#12036)
Co-authored-by: testa113 <testa113>pull/12045/head
parent
e2830019d7
commit
cc60836bb8
|
@ -181,7 +181,8 @@ function getUnmatchedRequiredNodeAffinities(node: Node, pod: Pod): Affinity[] {
|
||||||
?.requiredDuringSchedulingIgnoredDuringExecution;
|
?.requiredDuringSchedulingIgnoredDuringExecution;
|
||||||
|
|
||||||
const unmatchedRequiredNodeAffinities: Affinity[] =
|
const unmatchedRequiredNodeAffinities: Affinity[] =
|
||||||
basicNodeAffinity?.nodeSelectorTerms.map(
|
basicNodeAffinity?.nodeSelectorTerms
|
||||||
|
.map(
|
||||||
(selectorTerm) =>
|
(selectorTerm) =>
|
||||||
selectorTerm.matchExpressions?.flatMap((matchExpression) => {
|
selectorTerm.matchExpressions?.flatMap((matchExpression) => {
|
||||||
const exists = !!node.metadata?.labels?.[matchExpression.key];
|
const exists = !!node.metadata?.labels?.[matchExpression.key];
|
||||||
|
@ -200,12 +201,16 @@ function getUnmatchedRequiredNodeAffinities(node: Node, pod: Pod): Affinity[] {
|
||||||
(matchExpression.operator === 'NotIn' && !isIn) ||
|
(matchExpression.operator === 'NotIn' && !isIn) ||
|
||||||
(matchExpression.operator === 'Gt' &&
|
(matchExpression.operator === 'Gt' &&
|
||||||
exists &&
|
exists &&
|
||||||
parseInt(node.metadata?.labels?.[matchExpression.key] || '', 10) >
|
parseInt(
|
||||||
parseInt(matchExpression.values?.[0] || '', 10)) ||
|
node.metadata?.labels?.[matchExpression.key] || '',
|
||||||
|
10
|
||||||
|
) > parseInt(matchExpression.values?.[0] || '', 10)) ||
|
||||||
(matchExpression.operator === 'Lt' &&
|
(matchExpression.operator === 'Lt' &&
|
||||||
exists &&
|
exists &&
|
||||||
parseInt(node.metadata?.labels?.[matchExpression.key] || '', 10) <
|
parseInt(
|
||||||
parseInt(matchExpression.values?.[0] || '', 10))
|
node.metadata?.labels?.[matchExpression.key] || '',
|
||||||
|
10
|
||||||
|
) < parseInt(matchExpression.values?.[0] || '', 10))
|
||||||
) {
|
) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -220,7 +225,8 @@ function getUnmatchedRequiredNodeAffinities(node: Node, pod: Pod): Affinity[] {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}) || []
|
}) || []
|
||||||
) || [];
|
)
|
||||||
|
.filter((unmatchedAffinity) => unmatchedAffinity.length > 0) || [];
|
||||||
return unmatchedRequiredNodeAffinities;
|
return unmatchedRequiredNodeAffinities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue