Skip to content

Commit 2b61498

Browse files
committed
feat(platform): enable the GPU class controllers with VM GPUs
GPUClass status and license copies matter only where gpu-operator hands GPUs to VirtualMachines, which is its default and vgpu variants in the iaas bundle. The platform now passes gpu.enabled to cozystack-controller there, so a hoster enabling VM GPUs gets the class controllers without editing the generated Package, and a cluster on the container variant or without gpu-operator keeps them off. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 620a4bd commit 2b61498

3 files changed

Lines changed: 138 additions & 2 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,18 @@ sliced into /24s ever allowed.
285285
{{- define "cozystack.platform.ciliumPoolRange" -}}
286286
{{- join ".." (splitList " " (include "cozystack.platform.ciliumPoolBounds" .)) -}}
287287
{{- end }}
288+
289+
{{/*
290+
Prints "true" when gpu-operator serves GPUs to VirtualMachines: the iaas
291+
bundle emits it and its variant is default or vgpu. The container variant
292+
serves GPUs to pods only, which no GPUClass describes.
293+
*/}}
294+
{{- define "cozystack.platform.gpu.vmEnabled" -}}
295+
{{- $name := "cozystack.gpu-operator" -}}
296+
{{- $bundles := .Values.bundles -}}
297+
{{- $iaas := and $bundles.system.enabled $bundles.iaas.enabled (has $bundles.system.variant (list "isp-full" "isp-full-generic")) -}}
298+
{{- $enabled := and $iaas (has $name (default (list) $bundles.enabledPackages)) (not (has $name (default (list) $bundles.disabledPackages))) -}}
299+
{{- if and $enabled (has ($bundles.iaas.gpuOperatorVariant | default "default") (list "default" "vgpu")) -}}
300+
true
301+
{{- end -}}
302+
{{- end }}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,15 @@
174174
platform-level key, so `telemetry.disabled: true` plus the installer
175175
flag silences both. Without this, an operator who followed the
176176
documented opt-out kept sending cozy_application_count. */ -}}
177+
{{- $controllerValues := dict -}}
177178
{{- if .Values.telemetry.disabled -}}
178-
{{- $controllerValues := dict "cozystackController" (dict "disableTelemetry" true) -}}
179-
{{- $_ := set $cozystackEngineComponents "cozystack-controller" (dict "values" $controllerValues) -}}
179+
{{- $_ := set $controllerValues "disableTelemetry" true -}}
180+
{{- end -}}
181+
{{- if eq (include "cozystack.platform.gpu.vmEnabled" $) "true" -}}
182+
{{- $_ := set $controllerValues "gpu" (dict "enabled" true) -}}
183+
{{- end -}}
184+
{{- if $controllerValues -}}
185+
{{- $_ := set $cozystackEngineComponents "cozystack-controller" (dict "values" (dict "cozystackController" $controllerValues)) -}}
180186
{{- end -}}
181187
{{- if .Values.authentication.oidc.enabled }}
182188
{{include "cozystack.platform.package" (list "cozystack.cozystack-engine" "oidc" $ $cozystackEngineComponents) }}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
suite: GPU controllers follow gpu-operator's VM variants
2+
templates:
3+
- templates/bundles/system.yaml
4+
release:
5+
name: cozystack
6+
namespace: cozy-system
7+
tests:
8+
- it: enables the GPU controllers when gpu-operator serves GPUs to VMs
9+
set:
10+
bundles:
11+
system:
12+
enabled: true
13+
variant: isp-full
14+
iaas:
15+
enabled: true
16+
gpuOperatorVariant: vgpu
17+
enabledPackages:
18+
- cozystack.gpu-operator
19+
telemetry:
20+
disabled: true
21+
documentSelector:
22+
path: metadata.name
23+
value: cozystack.cozystack-engine
24+
asserts:
25+
- equal:
26+
path: spec.components.cozystack-controller.values.cozystackController
27+
value:
28+
disableTelemetry: true
29+
gpu:
30+
enabled: true
31+
32+
- it: enables them for the default variant on isp-full-generic
33+
set:
34+
bundles:
35+
system:
36+
enabled: true
37+
variant: isp-full-generic
38+
iaas:
39+
enabled: true
40+
enabledPackages:
41+
- cozystack.gpu-operator
42+
documentSelector:
43+
path: metadata.name
44+
value: cozystack.cozystack-engine
45+
asserts:
46+
- equal:
47+
path: spec.components.cozystack-controller.values.cozystackController.gpu.enabled
48+
value: true
49+
50+
- it: leaves them off for the container variant
51+
set:
52+
bundles:
53+
system:
54+
enabled: true
55+
variant: isp-full
56+
iaas:
57+
enabled: true
58+
gpuOperatorVariant: container
59+
enabledPackages:
60+
- cozystack.gpu-operator
61+
documentSelector:
62+
path: metadata.name
63+
value: cozystack.cozystack-engine
64+
asserts:
65+
- notExists:
66+
path: spec.components
67+
68+
- it: leaves them off when gpu-operator is disabled
69+
set:
70+
bundles:
71+
system:
72+
enabled: true
73+
variant: isp-full
74+
iaas:
75+
enabled: true
76+
enabledPackages:
77+
- cozystack.gpu-operator
78+
disabledPackages:
79+
- cozystack.gpu-operator
80+
documentSelector:
81+
path: metadata.name
82+
value: cozystack.cozystack-engine
83+
asserts:
84+
- notExists:
85+
path: spec.components
86+
87+
- it: leaves them off without the iaas bundle
88+
set:
89+
bundles:
90+
system:
91+
enabled: true
92+
variant: isp-full
93+
enabledPackages:
94+
- cozystack.gpu-operator
95+
documentSelector:
96+
path: metadata.name
97+
value: cozystack.cozystack-engine
98+
asserts:
99+
- notExists:
100+
path: spec.components
101+
102+
- it: leaves them off on an iaas cluster without gpu-operator
103+
set:
104+
bundles:
105+
system:
106+
enabled: true
107+
variant: isp-full
108+
iaas:
109+
enabled: true
110+
documentSelector:
111+
path: metadata.name
112+
value: cozystack.cozystack-engine
113+
asserts:
114+
- notExists:
115+
path: spec.components

0 commit comments

Comments
 (0)