Skip to content

Commit 829926b

Browse files
committed
fix(cdi): omit the CDI clone strategy override when unset
templates/cdi-cr.yaml rendered cloneStrategyOverride unconditionally, so the chart's values offered no way to leave the choice to CDI's own per-StorageProfile selection. The CRD enum takes copy, snapshot and csi-clone and carries no empty member, so an empty value rendered cloneStrategyOverride: "" which that enum does not accept, and a null one rendered a bare key. Guard the field on a non-empty value, the way uploadProxyURLOverride is already guarded just below it. The default stays csi-clone, so a release that overrides nothing renders what it rendered before. Whether csi-clone is the right default is a separate question, untouched here. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 4f337d6 commit 829926b

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

‎packages/system/kubevirt-cdi/templates/cdi-cr.yaml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ kind: CDI
33
metadata:
44
name: cdi
55
spec:
6-
cloneStrategyOverride: {{ quote .Values.cloneStrategyOverride }}
6+
{{- with .Values.cloneStrategyOverride }}
7+
cloneStrategyOverride: {{ quote . }}
8+
{{- end }}
79
config:
810
{{- with .Values.uploadProxyURL }}
911
uploadProxyURLOverride: {{ quote . }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
suite: cozy-kubevirt-cdi clone strategy
2+
release:
3+
name: kubevirt-cdi
4+
namespace: cozy-kubevirt-cdi
5+
tests:
6+
# The CRD enum takes copy, snapshot and csi-clone and carries no empty
7+
# member, so the only way to ask CDI for its own per-StorageProfile choice
8+
# is for the field to be absent. An empty value used to render
9+
# cloneStrategyOverride: "", which that enum does not accept; this pins
10+
# against it coming back.
11+
- it: omits the field when no strategy is configured
12+
template: cdi-cr.yaml
13+
documentSelector:
14+
path: kind
15+
value: CDI
16+
matchMany: false
17+
set:
18+
cloneStrategyOverride: ""
19+
asserts:
20+
- notExists:
21+
path: spec.cloneStrategyOverride
22+
23+
- it: keeps the chart default
24+
template: cdi-cr.yaml
25+
documentSelector:
26+
path: kind
27+
value: CDI
28+
matchMany: false
29+
asserts:
30+
- equal:
31+
path: spec.cloneStrategyOverride
32+
value: csi-clone
33+
34+
# The other direction: a configured value still has to reach the CR verbatim.
35+
# A test that only covered the empty case would pass against a template that
36+
# dropped the field unconditionally.
37+
- it: passes a configured strategy through unchanged
38+
template: cdi-cr.yaml
39+
documentSelector:
40+
path: kind
41+
value: CDI
42+
matchMany: false
43+
set:
44+
cloneStrategyOverride: snapshot
45+
asserts:
46+
- equal:
47+
path: spec.cloneStrategyOverride
48+
value: snapshot

‎packages/system/kubevirt-cdi/values.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ uploadProxyURL: ""
66

77
## @param cloneStrategyOverride Strategy CDI uses to clone DataVolumes (golden image -> VM disk).
88
## One of: csi-clone, snapshot, copy. Defaults to csi-clone (unchanged behavior).
9+
## Empty omits the field, leaving CDI to pick a strategy per StorageProfile.
910
cloneStrategyOverride: csi-clone
1011

1112
## @param importerResources Resources for CDI's importer/uploader/cloner worker pods.

0 commit comments

Comments
 (0)