Skip to content

Commit 4cec269

Browse files
committed
feat(platform): forward kubevirt.disabledFeatureGates to the kubevirt CR
The kubevirt chart reads disabledFeatureGates from its own values, and the iaas bundle is the only writer of the cozystack.kubevirt Package, so nothing could set it: a Package patched by hand is reverted the next time the platform re-renders it. Platform values gain a documented kubevirt.disabledFeatureGates list, forwarded into the emitted Package as components.kubevirt.values.disabledFeatureGates alongside the entries derived from resources.cpuAllocationRatio and the gpu block. The parenthesized value walk is nil-safe, matching the gpu block, so a cluster that nulls out the whole kubevirt key still renders. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent a5f5985 commit 4cec269

4 files changed

Lines changed: 105 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
{{- if .Values.resources.cpuAllocationRatio -}}
1515
{{- $_ := set $kubevirtValues "cpuAllocationRatio" (.Values.resources.cpuAllocationRatio | int) -}}
1616
{{- end -}}
17+
{{- /*
18+
Feature gates the cluster declines, forwarded verbatim. This include is the
19+
only writer of the cozystack.kubevirt Package, and patching that Package by
20+
hand is reverted the next time the platform re-renders it (see
21+
docs/operations/backup-classes.md for the same trap on backupStorage), so
22+
without this hop the chart value has no supported setter. The parenthesized
23+
walk is nil-safe for the reason the gpu block below spells out.
24+
*/ -}}
25+
{{- $disabledFeatureGates := (.Values.kubevirt).disabledFeatureGates -}}
26+
{{- if $disabledFeatureGates -}}
27+
{{- $_ := set $kubevirtValues "disabledFeatureGates" $disabledFeatureGates -}}
28+
{{- end -}}
1729
{{- /*
1830
When cozystack.gpu-operator is enabled the platform mirrors the variant
1931
into the KubeVirt CR: the HostDevices feature gate plus a starter

‎packages/core/platform/tests/bundles_gpu_kubevirt_wiring_test.yaml‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,73 @@ tests:
386386
path: spec.components.kubevirt.values.cpuAllocationRatio
387387
value: 7
388388

389+
# The kubevirt chart reads disabledFeatureGates from its own values, and the
390+
# only writer of a Package CR's components is this bundle — editing the CR by
391+
# hand is undone on the next platform render. Without this hop the chart value
392+
# is unreachable from a supported install.
393+
- it: forwards kubevirt.disabledFeatureGates into the kubevirt component values
394+
set:
395+
bundles:
396+
system:
397+
enabled: true
398+
variant: isp-full
399+
iaas:
400+
enabled: true
401+
enabledPackages: []
402+
kubevirt:
403+
disabledFeatureGates:
404+
- ImageVolume
405+
documentSelector:
406+
path: metadata.name
407+
value: cozystack.kubevirt
408+
asserts:
409+
- equal:
410+
path: spec.components.kubevirt.values.disabledFeatureGates
411+
value:
412+
- ImageVolume
413+
414+
- it: leaves disabledFeatureGates out of the kubevirt component values at the platform defaults
415+
set:
416+
bundles:
417+
system:
418+
enabled: true
419+
variant: isp-full
420+
iaas:
421+
enabled: true
422+
enabledPackages: []
423+
documentSelector:
424+
path: metadata.name
425+
value: cozystack.kubevirt
426+
asserts:
427+
- notExists:
428+
path: spec.components.kubevirt.values.disabledFeatureGates
429+
- equal:
430+
path: spec.components
431+
value:
432+
kubevirt:
433+
values:
434+
cpuAllocationRatio: 10
435+
436+
- it: renders the kubevirt Package without a nil-pointer error when the whole kubevirt block is set to null
437+
set:
438+
bundles:
439+
system:
440+
enabled: true
441+
variant: isp-full
442+
iaas:
443+
enabled: true
444+
enabledPackages: []
445+
kubevirt: null
446+
documentSelector:
447+
path: metadata.name
448+
value: cozystack.kubevirt
449+
asserts:
450+
- equal:
451+
path: kind
452+
value: Package
453+
- notExists:
454+
path: spec.components.kubevirt.values.disabledFeatureGates
455+
389456
- it: appends user-supplied pciHostDevices in vgpu mode so post-kubevirt#16890 SR-IOV vGPU VFs can be advertised alongside the platform mediated defaults
390457
set:
391458
bundles:

‎packages/core/platform/values.yaml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,28 @@ resources:
603603
cpuAllocationRatio: 10
604604
memoryAllocationRatio: 1
605605
ephemeralStorageAllocationRatio: 40
606+
# KubeVirt CR settings that no other platform knob implies. Forwarded into the
607+
# emitted cozystack.kubevirt Package CR as components.kubevirt.values, next to
608+
# the entries the iaas bundle derives from resources.cpuAllocationRatio and
609+
# from the gpu block below.
610+
kubevirt:
611+
# Feature gates switched off under
612+
# spec.configuration.developerConfiguration.disabledFeatureGates, on top of
613+
# the opt-outs the kubevirt chart pins: Template and
614+
# ExternalNetResourceInjection always, ImageVolume below Kubernetes 1.35.
615+
# KubeVirt 1.9 turns every Beta gate on by default, so this is how a cluster
616+
# declines one it cannot carry — a container runtime without image volume
617+
# support on Kubernetes 1.35 or newer is the case this list is for.
618+
#
619+
# kubevirt:
620+
# disabledFeatureGates:
621+
# - ImageVolume
622+
#
623+
# A gate the chart already enables cannot be switched off here. KubeVirt
624+
# refuses a CR that names one gate in both lists, so the chart stops the
625+
# render and names the gate rather than ship a CR the cluster would reject
626+
# on update and misread on install.
627+
disabledFeatureGates: []
606628
# GPU host-device wiring for VirtualMachine workloads. Auto-injected into the
607629
# KubeVirt CR's permittedHostDevices when bundles.enabledPackages contains
608630
# cozystack.gpu-operator. Without it the admission webhook rejects any VM

‎packages/system/kubevirt/values.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ extraFeatureGates: []
2222
# a container runtime without image volume support at 1.35 or newer.
2323
# Naming a gate the chart already disables is a no-op: it renders once.
2424
#
25+
# Admins set this through spec.components.platform.values.kubevirt on the
26+
# cozystack.cozystack-platform Package; the iaas bundle forwards it into the
27+
# emitted cozystack.kubevirt Package as components.kubevirt.values.
28+
#
2529
# A gate this chart already enables cannot be switched off here, and a gate it
2630
# disables cannot be switched back on through extraFeatureGates: KubeVirt
2731
# refuses a CR that names the same gate in both lists, so the template stops

0 commit comments

Comments
 (0)