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;
|
||||
|
||||
const unmatchedRequiredNodeAffinities: Affinity[] =
|
||||
basicNodeAffinity?.nodeSelectorTerms.map(
|
||||
basicNodeAffinity?.nodeSelectorTerms
|
||||
.map(
|
||||
(selectorTerm) =>
|
||||
selectorTerm.matchExpressions?.flatMap((matchExpression) => {
|
||||
const exists = !!node.metadata?.labels?.[matchExpression.key];
|
||||
|
@ -200,12 +201,16 @@ function getUnmatchedRequiredNodeAffinities(node: Node, pod: Pod): Affinity[] {
|
|||
(matchExpression.operator === 'NotIn' && !isIn) ||
|
||||
(matchExpression.operator === 'Gt' &&
|
||||
exists &&
|
||||
parseInt(node.metadata?.labels?.[matchExpression.key] || '', 10) >
|
||||
parseInt(matchExpression.values?.[0] || '', 10)) ||
|
||||
parseInt(
|
||||
node.metadata?.labels?.[matchExpression.key] || '',
|
||||
10
|
||||
) > parseInt(matchExpression.values?.[0] || '', 10)) ||
|
||||
(matchExpression.operator === 'Lt' &&
|
||||
exists &&
|
||||
parseInt(node.metadata?.labels?.[matchExpression.key] || '', 10) <
|
||||
parseInt(matchExpression.values?.[0] || '', 10))
|
||||
parseInt(
|
||||
node.metadata?.labels?.[matchExpression.key] || '',
|
||||
10
|
||||
) < parseInt(matchExpression.values?.[0] || '', 10))
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
@ -220,7 +225,8 @@ function getUnmatchedRequiredNodeAffinities(node: Node, pod: Pod): Affinity[] {
|
|||
},
|
||||
];
|
||||
}) || []
|
||||
) || [];
|
||||
)
|
||||
.filter((unmatchedAffinity) => unmatchedAffinity.length > 0) || [];
|
||||
return unmatchedRequiredNodeAffinities;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue