1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 15:29:42 +02:00

fix(placements) filter out empty items in the required node affinity array [BE-11022] (#12034)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run

Co-authored-by: testa113 <testa113>
This commit is contained in:
Ali 2024-07-23 09:31:08 +12:00 committed by GitHub
parent 1900fb695d
commit 6eb9e906af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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