fix(cdi): omit the CDI clone strategy override when unset - #4138
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe CDI chart now omits ChangesCDI clone strategy configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Empty or null clone-strategy overrides are now omitted so CDI can select a StorageProfile-specific strategy, while default and explicit strategy behavior remain covered. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ef31220 to
b3d134f
Compare
829926b to
650ada1
Compare
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]>
650ada1 to
5db7738
Compare
Andrei Kvapil (kvaps)
left a comment
There was a problem hiding this comment.
Verdict
LGTM as of 5db773892. Cleanest of the four CDI-family PRs in this batch, and the test earns its place.
The premise checks out from the tree: packages/system/kubevirt-cdi-operator/templates/cdi-operator.yaml:101-108 (and the v1beta1 copy at :2624-2631) declares cloneStrategyOverride with enum: [copy, snapshot, csi-clone] and no empty member, while the template rendered {{ quote .Values.cloneStrategyOverride }} unconditionally — so an operator who set the value to "" produced cloneStrategyOverride: "", which that enum refuses at admission. There was no way to ask CDI to make its own per-StorageProfile choice.
Wrapping the line in {{- with }} is the right fix and omitting is the right target state rather than substituting something: upstream v1.66.1's own cdi-cr.yaml carries no cloneStrategyOverride at all, and with the field absent CDI falls back to the per-StorageProfile cloneStrategy. Both "" and ~ take the falsy branch, so the key is absent rather than set to a different value.
The test is non-vacuous and I had it checked by execution rather than by reading: reverting the template to the unconditional line turns two cases red (omits the field when no strategy is configured, omits the field when the strategy is null), and the suite also pins the opposite direction with a configured snapshot passing through unchanged, so a template that dropped the field unconditionally would not satisfy it either. The null case cannot pass vacuously — if set: cloneStrategyOverride: null were a no-op the chart default csi-clone would render and the assertion would fail. 9/9 green at head.
No upgrade impact: values.yaml:9 keeps csi-clone as the default, so every existing cluster renders identically and the change only adds a state that was previously unreachable.
It composes with #4107 rather than colliding: no file overlap, and that PR's CR_SHA256 pins the upstream asset rather than the in-tree file, so this edit does not invalidate it. Its tests/local_templates_test.yaml asserts csi-clone against the chart default, which still holds.
One nit, pre-existing and not yours: packages/system/kubevirt-cdi/Makefile declares test: twice with identical recipes, so make warns and uses the last. #4107 removes the duplicate; whichever of these lands first could just as easily take it.
What this PR does
cdi-cr.yamlrenderedcloneStrategyOverrideunconditionally, so there was no way to let CDI pick a clone strategy per StorageProfile. The CRD enum iscopy/snapshot/csi-clonewith no empty member, so neither obvious workaround got there: an empty value renderedcloneStrategyOverride: "", which that enum does not accept, and a null one rendered a bare key. Both checked againstmainwithhelm templaterather than assumed.Now the key is guarded on a non-empty value, same as
uploadProxyURLOverridejust below it in the same file. With the field absent, CDI reads the target StorageClass's StorageProfile and uses its clone strategy.Default stays
csi-clone. Rendered at the default and diffed againstmain, the output is byte-identical, so nothing already deployed moves.Tests
tests/clone_strategy_test.yamlpins both directions: absent when the value is empty, absent when it is null,csi-cloneon the chart default,snapshotthrough unchanged. It sits alongside the existingimporter-resourcesandstandalone_render_testsuites, with its own file and suite name and no shared test names;make testruns all three.I checked the suite can fail rather than assuming it works. Reverting the guard reddens the two absent-field cases, deleting the field outright reddens the default and passthrough cases, hardcoding the value reddens the passthrough case, and rendering a bare key reddens all four. The two sibling suites stay green through every one of those, so the reds are attributable to this suite.
The null case is pinned as an input rather than argued from
withtreating null and empty alike. It cannot pass vacuously: flipping its assertion to expect the default returnsunknown path, not acsi-clonemismatch, which is what shows the null actually reaches the template instead of the assertion passing on a value that never arrived.Known gaps
copyis accepted by the enum but no test drives it, so the suite does not pin that it reaches the CR. Concretely: wrapping the guard in{{- if ne . "copy" }}, which silently drops that one strategy, still passes all nine tests. Named here rather than fixed so the boundary is visible to the next reader instead of being rediscovered.Scope
Context: #2908. This is the first of the three directions that issue lists, so it does not close it and carries no
Closes. The default is deliberately left atcsi-clone, since whether that is the right default is the second direction and a separate decision. The third,vm-diskwarning on a cross-StorageClass request, is untouched. An operator who has not setcloneStrategyOverride: ""sees the reported symptom exactly as before.Screenshots
Not a UI change.
Downstream repositories
Walked the trigger map against the diff. It is one guarded key in a
packages/systemchart, a values comment, and a test suite: no package added or renamed, novalues.schema.json(this chart has none), noApplicationDefinition, no namespace, nothing underhack/, no platform values key. Theccpentry covershack/package.mkand make-target behaviour, and this touches neither. Nothing in the map reaches it.Release note