Skip to content

Commit 0e77e2b

Browse files
committed
fix(kubernetes-nodes): name instanceType in the partial-spec refusal
On a pool with no instanceType, "set both resources.cpu and resources.memory, or neither" sent the user straight into the next refusal, since neither sizing source is refused as well. The message now ends in "or neither and set instanceType" on such a pool; a pool sized by an instancetype keeps the old wording. The tests anchor both spellings, so the suffix cannot leak onto, or drop off, either kind of pool. Signed-off-by: Marian Koreniuk <[email protected]> Assisted-by: LLM
1 parent 1211095 commit 0e77e2b

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎packages/apps/kubernetes-nodes/templates/nodegroup.yaml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,13 @@ spec:
667667
{{- $hasCpu := and $group.resources $group.resources.cpu }}
668668
{{- $hasMem := and $group.resources $group.resources.memory }}
669669
{{- if or (and $hasCpu (not $hasMem)) (and $hasMem (not $hasCpu)) }}
670-
{{- fail (printf "nodeGroup %s: set both resources.cpu and resources.memory, or neither" $groupName) }}
670+
{{- $orElse := "neither" }}
671+
{{- /* Without an instancetype "neither" alone leads straight into the
672+
refusal below, so name the other sizing source too. */}}
673+
{{- if not $group.instanceType }}
674+
{{- $orElse = "neither and set instanceType" }}
675+
{{- end }}
676+
{{- fail (printf "nodeGroup %s: set both resources.cpu and resources.memory, or %s" $groupName $orElse) }}
671677
{{- end }}
672678
{{- /* With neither sizing source the VM has no memory at all, and KubeVirt
673679
refuses it at admission, long after helm has reported success. No pool

‎packages/apps/kubernetes-nodes/tests/resources_cpu_test.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ tests:
212212
memory: 4Gi
213213
asserts:
214214
- failedTemplate:
215-
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither'
215+
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither and set instanceType$'
216216

217217
# A quoted zero is truthy, so it never took the unset path. It was refused
218218
# before this guard existed as well, by the kubelet CPU reservation check,

‎packages/apps/kubernetes-nodes/tests/resources_partial_test.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ tests:
3131
cpu: "2"
3232
asserts:
3333
- failedTemplate:
34-
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither'
34+
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither and set instanceType$'
3535

3636
- it: refuses memory without cpu on a pool with no instancetype
3737
set:
3838
resources:
3939
memory: 4Gi
4040
asserts:
4141
- failedTemplate:
42-
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither'
42+
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither and set instanceType$'
4343

4444
# The case the check always caught. Pinned so the two halves cannot drift:
4545
# the partial check runs before the instancetype lookup, so no stub is needed.
@@ -50,7 +50,7 @@ tests:
5050
cpu: "2"
5151
asserts:
5252
- failedTemplate:
53-
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither'
53+
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither$'
5454

5555
- it: refuses memory without cpu on a pool sized by an instancetype
5656
set:
@@ -59,7 +59,7 @@ tests:
5959
memory: 4Gi
6060
asserts:
6161
- failedTemplate:
62-
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither'
62+
errorPattern: 'nodeGroup md0: set both resources.cpu and resources.memory, or neither$'
6363

6464
- it: refuses a pool with neither an instancetype nor explicit resources
6565
asserts:

0 commit comments

Comments
 (0)