Skip to content

Commit ddd00f8

Browse files
committed
feat(platform): pass multus resources from networking.multus.resources
The multus chart takes its resources from values, but the platform renders the cozystack.multus Package with stageCniPlugins alone, and an edit to that child Package is reverted by the platform reconcile. A running cluster therefore had no way to raise the multus limits. networking.multus.resources is passed to the Package only when set, so an unset key leaves the chart default in charge. A value that is not a map stops the render here; the multus chart keeps refusing a render without a memory limit or request. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent dca2e4f commit ddd00f8

5 files changed

Lines changed: 186 additions & 2 deletions

File tree

‎packages/core/platform/templates/_helpers.tpl‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,31 @@ false
159159
{{- end -}}
160160
{{- end }}
161161

162+
{{/*
163+
Values of the cozystack.multus Package. Call as (list $ <stageCniPlugins default>);
164+
emits YAML. networking.multus.resources is passed only when set, so an unset key
165+
leaves the multus chart default in charge.
166+
*/}}
167+
{{- define "cozystack.platform.multus.values" -}}
168+
{{- $root := index . 0 -}}
169+
{{- $values := dict "stageCniPlugins" (eq (include "cozystack.platform.stageCniPlugins" .) "true") -}}
170+
{{- $multus := index ($root.Values.networking | default dict) "multus" -}}
171+
{{- if kindIs "invalid" $multus -}}
172+
{{- $multus = dict -}}
173+
{{- end -}}
174+
{{- if not (kindIs "map" $multus) -}}
175+
{{- fail (printf "networking.multus: expected a map, got %s" (kindOf $multus)) -}}
176+
{{- end -}}
177+
{{- $resources := index $multus "resources" -}}
178+
{{- if not (kindIs "invalid" $resources) -}}
179+
{{- if not (kindIs "map" $resources) -}}
180+
{{- fail (printf "networking.multus.resources: expected a map, got %s" (kindOf $resources)) -}}
181+
{{- end -}}
182+
{{- $_ := set $values "resources" $resources -}}
183+
{{- end -}}
184+
{{- toYaml $values -}}
185+
{{- end }}
186+
162187
{{/*
163188
Common system packages shared between the isp-full, isp-full-generic, isp-slim and
164189
isp-slim-generic bundles.

‎packages/core/platform/templates/bundles/system.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
networking.stageCniPlugins turns it off, for nodes whose operator
5858
manages that directory. The value is always emitted rather than left to
5959
the chart default, so the rendered Package states which way it went. */ -}}
60-
{{- $multusComponents := dict "multus" (dict "values" (dict "stageCniPlugins" (eq (include "cozystack.platform.stageCniPlugins" (list $ true)) "true"))) -}}
60+
{{- $multusComponents := dict "multus" (dict "values" (include "cozystack.platform.multus.values" (list $ true) | fromYaml)) -}}
6161
{{include "cozystack.platform.package.full" (list "cozystack.multus" "default" $ $multusComponents) }}
6262
{{include "cozystack.platform.package.default" (list "cozystack.linstor" $) }}
6363
{{include "cozystack.platform.package" (list "cozystack.cozystack-scheduler" "linstor" $) }}
@@ -149,7 +149,7 @@
149149
that rewrite is the only path a later plugin version has onto an existing
150150
node, so installing only when absent would pin each node to whichever
151151
version arrived there first. */ -}}
152-
{{- $multusComponents := dict "multus" (dict "values" (dict "stageCniPlugins" (eq (include "cozystack.platform.stageCniPlugins" (list $ true)) "true"))) -}}
152+
{{- $multusComponents := dict "multus" (dict "values" (include "cozystack.platform.multus.values" (list $ true) | fromYaml)) -}}
153153
{{include "cozystack.platform.package.full" (list "cozystack.multus" "default" $ $multusComponents) }}
154154
{{- /* Pass talos.enabled: false to linstor for generic Linux */ -}}
155155
{{- $linstorComponents := dict "linstor" (dict "values" (dict "talos" (dict "enabled" false))) -}}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
suite: networking.multus.resources bundle wiring
2+
templates:
3+
- templates/bundles/system.yaml
4+
release:
5+
name: cozystack
6+
namespace: cozy-system
7+
tests:
8+
# Unset leaves the multus chart default in charge rather than freezing a copy
9+
# of it into every Package.
10+
- it: passes no resources when the key is unset
11+
set:
12+
bundles:
13+
system:
14+
enabled: true
15+
variant: isp-full
16+
documentSelector:
17+
path: metadata.name
18+
value: cozystack.multus
19+
asserts:
20+
- notExists:
21+
path: spec.components.multus.values.resources
22+
- equal:
23+
path: spec.components.multus.values.stageCniPlugins
24+
value: true
25+
26+
- it: passes an override on talos next to stageCniPlugins
27+
set:
28+
bundles:
29+
system:
30+
enabled: true
31+
variant: isp-full
32+
networking:
33+
multus:
34+
resources:
35+
limits:
36+
memory: 8Gi
37+
documentSelector:
38+
path: metadata.name
39+
value: cozystack.multus
40+
asserts:
41+
- equal:
42+
path: spec.components.multus.values
43+
value:
44+
stageCniPlugins: true
45+
resources:
46+
limits:
47+
memory: 8Gi
48+
49+
- it: passes an override on generic Linux
50+
set:
51+
bundles:
52+
system:
53+
enabled: true
54+
variant: isp-full-generic
55+
networking:
56+
multus:
57+
resources:
58+
requests:
59+
cpu: 500m
60+
documentSelector:
61+
path: metadata.name
62+
value: cozystack.multus
63+
asserts:
64+
- equal:
65+
path: spec.components.multus.values.resources
66+
value:
67+
requests:
68+
cpu: 500m
69+
70+
- it: passes an override when multus is opted in on a slim variant
71+
values:
72+
- ../values-isp-slim-generic.yaml
73+
set:
74+
bundles:
75+
enabledPackages:
76+
- cozystack.multus
77+
networking:
78+
multus:
79+
resources:
80+
limits:
81+
memory: 8Gi
82+
documentSelector:
83+
path: metadata.name
84+
value: cozystack.multus
85+
asserts:
86+
- equal:
87+
path: spec.components.multus.values.resources.limits.memory
88+
value: 8Gi
89+
90+
- it: reads an explicit null as unset
91+
set:
92+
bundles:
93+
system:
94+
enabled: true
95+
variant: isp-full
96+
networking:
97+
multus:
98+
resources: null
99+
documentSelector:
100+
path: metadata.name
101+
value: cozystack.multus
102+
asserts:
103+
- notExists:
104+
path: spec.components.multus.values.resources
105+
106+
- it: refuses resources that are not a map
107+
set:
108+
bundles:
109+
system:
110+
enabled: true
111+
variant: isp-full
112+
networking:
113+
multus:
114+
resources: 4Gi
115+
asserts:
116+
- failedTemplate:
117+
errorMessage: 'networking.multus.resources: expected a map, got string'
118+
119+
# An uncommented `multus:` with nothing under it arrives as null.
120+
- it: reads a null multus block as unset
121+
set:
122+
bundles:
123+
system:
124+
enabled: true
125+
variant: isp-full
126+
networking:
127+
multus: null
128+
documentSelector:
129+
path: metadata.name
130+
value: cozystack.multus
131+
asserts:
132+
- notExists:
133+
path: spec.components.multus.values.resources
134+
135+
# false is the spelling most likely to mean "turn multus off", which this key
136+
# does not do, so it must not pass as unset.
137+
- it: refuses a multus block that is not a map
138+
set:
139+
bundles:
140+
system:
141+
enabled: true
142+
variant: isp-full
143+
networking:
144+
multus: false
145+
asserts:
146+
- failedTemplate:
147+
errorMessage: 'networking.multus: expected a map, got bool'

‎packages/core/platform/values.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ networking:
166166
# the child Package cozystack.multus directly is reverted by the platform
167167
# reconcile.
168168
# stageCniPlugins: true
169+
# Resources of the kube-multus container, merged over the defaults in
170+
# packages/system/multus/values.yaml, which also say why there is no CPU limit.
171+
# Unset keeps those defaults. The multus chart refuses to render without a
172+
# memory limit and a memory request. Set on a running cluster the same way as
173+
# stageCniPlugins above.
174+
# multus:
175+
# resources:
176+
# limits:
177+
# memory: 8Gi
169178

170179
# Service publishing and ingress configuration
171180
publishing:

‎packages/system/multus/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
stageCniPlugins: false
99

1010
## @param resources resources of the kube-multus container
11+
## Set this through the platform, not here: networking.multus.resources on the cozystack-platform
12+
## Package. See packages/core/platform/values.yaml.
13+
##
1114
## Every pod sandbox on the node waits on this container, which is why there is no CPU limit:
1215
## after a CNI outage left ~600 dead sandboxes for 220 pods on one node, multus at 100m answered
1316
## slower than kubelet's two-minute CRI deadline, every call was retried and the queue only grew.

0 commit comments

Comments
 (0)