Repository navigation
Commit 631580e
committed
fix(vm-disk): fail on storageClass/source edit of existing disk
Editing a VMDisk's storageClass or source after its DataVolume already
exists was silently ignored: dv.yaml reused the existing DataVolume.spec
verbatim (DataVolume.spec is immutable in CDI), so the edit rendered as a
no-op while the HelmRelease reported success and the CR diverged from the
cluster.
When a DataVolume already exists, fail with a clear message if the
requested storageClass or source differs from what the disk was created
with. storageClass is read from the bound PVC (authoritative, and present
even when the DataVolume omits storageClassName), falling back to the
DataVolume spec, and skipped only when neither records a class. source is
compared against the operator input recorded in a vm-disk.cozystack.io/source
annotation at creation, not the rendered spec.source: the image-clone PVC
name carries a chart-version prefix (vm-image- was renamed to
vm-default-images-, commit bec35e3) that drifts across upgrades without
any edit, so comparing the rendered form would falsely reject long-lived
image disks. A disk created before the annotation existed is compared
against its stored spec.source directly for every source type except image
(all of which reproduce the stored spec exactly); image is the one
documented exemption. The annotation is written only at creation and
preserved verbatim afterwards, never overwritten with an unapplied edit. An
unrecognized source type now fails explicitly instead of rendering an empty
source. Storage growth is unaffected and still handled by pvc-resize-hook.yaml.
Mark source as immutable in values.yaml so the generated schema carries
the same x-kubernetes-validations rule already present on storageClass,
and document the vm-disk source contract in docs/storage-immutability.md
and the chart README. Aggregated-apiserver CEL enforcement is tracked
separately in #2657; the chart-level fail is the substantive guard today.
Add helm-unittest coverage for the immutability guard (rejection, no-op
reuse with annotation preserved, legacy image-disk drift, legacy non-image
fallback, annotation non-poisoning, PVC-backed storageClass on an adopted
disk, unknown source) and initial-creation source rendering.
Fixes #2985
Signed-off-by: Alexey Artamonov <[email protected]>1 parent eef95f4 commit 631580e
9 files changed
Lines changed: 535 additions & 26 deletions
File tree
- api/apps/v1alpha1/vmdisk
- docs
- packages
- apps/vm-disk
- templates
- tests
- system/vm-disk-rd/cozyrds
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
2 | 70 | | |
3 | 71 | | |
4 | 72 | | |
5 | 73 | | |
6 | 74 | | |
7 | 75 | | |
8 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
9 | 84 | | |
10 | 85 | | |
11 | 86 | | |
12 | 87 | | |
13 | 88 | | |
14 | 89 | | |
15 | 90 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 91 | | |
| 92 | + | |
38 | 93 | | |
39 | | - | |
40 | | - | |
| 94 | + | |
41 | 95 | | |
42 | 96 | | |
43 | 97 | | |
| |||
0 commit comments