test(computeplane): pin the maxUnavailable bounds and zero through the API

A zero dropped anywhere between the ComputePlane API and the pool chart would let a GPU pool fall back to the chart default of 1, and the render tests never cross the aggregated API. A negative value let through by the ComputePlane schema would only be refused by the pool chart, after the parent release had already been upgraded.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
Mattia Eleuteri committed 2026-11-09 13:24:36 +01:00
1 parent 28b66bbc63
commit f2ee3ec8ad
2 files changed
+23 -5

No files matched your search

@@ -102,7 +102,9 @@ spec:
#
# nameOverride is outside the module's per-pool allowlist. The ComputePlane
# schema accepts it, so it reaches the module and the pool check below can
# see whether the module dropped it.
# see whether the module dropped it. maxUnavailable is set to 0 because a
# zero lost anywhere on the way would let a GPU pool fall back to the
# chart's default of 1; only this path crosses the aggregated API.
- script:
timeout: 3m
content: |
@@ -118,6 +120,7 @@ spec:
diskSize: 20Gi
instanceType: u1.medium
logSerialConsole: true
maxUnavailable: 0
minReplicas: 2
maxReplicas: 2
podCpuLimit: 2
@@ -175,8 +178,9 @@ spec:
enabled: true
exposeMethod: Proxied
# The pool takes the patched shape, and the nameOverride the patch sent
# does not reach it, nor does any other key outside the allowlist.
# The pool takes the patched shape, the explicit maxUnavailable of 0
# included, and the nameOverride the patch sent does not reach it, nor does
# any other key outside the allowlist.
- script:
timeout: 1m
content: |
@@ -186,8 +190,8 @@ spec:
sc=$(cozy_e2e_storage_class)
values=$(timeout -k 5 30 kubectl -n tenant-cplane get helmrelease kubernetes-nodes-computeplane-cluster-md0 -o json | jq -c '.spec.values')
echo "pool values: $values"
echo "$values" | jq -e --arg sc "$sc" '.storageClass == $sc and .minReplicas == 2 and .cluster == "computeplane-cluster" and .clusterReleaseName == "computeplane-cluster"'
extra=$(echo "$values" | jq -r 'keys - ["cluster","clusterReleaseName","minReplicas","maxReplicas","instanceType","diskSize","storageClass","roles","resources","gpus","kubelet","logSerialConsole","maxUnhealthy","nodeStartupTimeout","readyUnknownTimeout","readyFalseTimeout","podCpuLimit","podCpuRequest","maxNodeProvisionTime"] | .[]')
echo "$values" | jq -e --arg sc "$sc" '.storageClass == $sc and .minReplicas == 2 and .maxUnavailable == 0 and .cluster == "computeplane-cluster" and .clusterReleaseName == "computeplane-cluster"'
extra=$(echo "$values" | jq -r 'keys - ["cluster","clusterReleaseName","minReplicas","maxReplicas","instanceType","diskSize","storageClass","roles","resources","gpus","kubelet","logSerialConsole","maxUnhealthy","nodeStartupTimeout","readyUnknownTimeout","readyFalseTimeout","podCpuLimit","podCpuRequest","maxNodeProvisionTime","maxUnavailable"] | .[]')
if [ -n "$extra" ]; then
echo "pool HelmRelease carries keys outside the module allowlist: $extra" >&2
exit 1
@@ -353,6 +353,20 @@ tests:
- failedTemplate:
errorPattern: "maxUnavailable"
- it: refuses a negative maxUnavailable
set:
nodeGroups:
md0:
minReplicas: 1
maxReplicas: 3
instanceType: u1.large
diskSize: 32Gi
roles: ["ingress-nginx"]
maxUnavailable: -1
asserts:
- failedTemplate:
errorPattern: "maxUnavailable"
# Helm caps a HelmRelease name at 53 chars and each pool renders a 38-char fixed
# prefix, so a pool key over 15 chars would create a release the apiserver
# accepts but Flux never reconciles. The render must refuse instead (the same