fix(vm-disk, kubernetes-nodes)!: refuse golden images whose import keeps failing (#4802)

## What this PR does

New clones can wait forever on a golden image whose import keeps
failing. CDI v1.66.1 retries ordinary HTTP failures without setting
phase `Failed`.

The guards now also refuse goldens with at least three importer restarts
unless they reached `Succeeded`. kubernetes-nodes and the picker require
`Running=False`; vm-disk refuses during running attempts too. Existing
vm-disks and already-cloned pools remain exempt. CDI never lowers the
restart count, so a healthy import with three early restarts stays
refusable until `Succeeded`, including while a recreated importer is
still starting.

An empty worker-pool StorageClass now resolves to the virtualization
default, then the GA Kubernetes default. Beta is a last fallback for the
class written explicitly onto a worker disk, not a CDI fallback. The
strict same-class policy stays.

This can refuse a previously accepted builtin pool on upgrade. The
affected pool has an empty StorageClass, no cloned disk yet, and a
golden on the Kubernetes default while another class is the
virtualization default. StorageClass is immutable: point
`osImage.builtin` at a catalog entry on the virtualization default or
switch to `osImage.factory`. Already-cloned pools keep their disk's
class.

A VMDisk's own HTTP import, golden-image health checks and imports that
hang without restarting remain outside this change.

Closes #4564

Refs #4059

### Screenshots

No UI changes.

### Downstream repositories

The platform values change only updates a comment. The application
schema change updates the StorageClass description without changing
fields, defaults or enums.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(vm-disk, kubernetes-nodes)!: refuse new clones of golden images whose import has not succeeded after at least three importer restarts. kubernetes-nodes and the image picker require the importer to be not running; vm-disk refuses during running attempts too. kubernetes-nodes now resolves an empty storageClass to CDI's virtualization default before the Kubernetes default. A builtin pool with an empty storageClass, no cloned disk yet, and a golden on a different class can now be refused. Point it at a catalog entry on the virtualization default or switch to osImage.factory. Already-cloned pools are unaffected.
```
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-11-17 18:05:01 +03:00
commit 87f160d473
25 files changed
+809 -87

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ type ConfigSpec struct {
// +kubebuilder:default:=""
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="cluster is immutable"
Cluster string `json:"cluster"`
// StorageClass for the worker node system disk. When empty, the cluster default applies. Worker VMs live-migrate, so their disks need ReadWriteMany — the RWX access mode is supplied by the chosen StorageClass's CDI StorageProfile — and linstor-csi rejects RWX volumes that are not on a DRBD-backed StorageClass, so prefer a replicated/DRBD class. On an `osImage.builtin` pool this field also decides whether the pool renders at all: CDI takes the storage-layer clone path only when the worker disk and the golden share a StorageClass, and falls back to a host-assisted copy over the pod network across classes, so the chart refuses a pool whose class differs from its golden's. Leaving it empty resolves to the cluster's default StorageClass, and the same comparison is made against that. On a `builtin` pool the resolved class is then written onto the worker disk rather than left for the cluster to fill in at bind time, so a pool that has already cloned keeps binding on the class its disks are on even after an admin moves the default annotation; on the HTTP path an empty class is still left to the cluster. Has no effect on `substrate: proxmox`, where the worker disk is cloned from the VM template onto the template's storage or `proxmox.storage`.
// StorageClass for the worker node system disk. When empty, CDI picks the class: the one annotated `storageclass.kubevirt.io/is-default-virt-class`, else the cluster default. Worker VMs live-migrate, so their disks need ReadWriteMany — the RWX access mode is supplied by the chosen StorageClass's CDI StorageProfile — and linstor-csi rejects RWX volumes that are not on a DRBD-backed StorageClass, so prefer a replicated/DRBD class. On an `osImage.builtin` pool this field also decides whether the pool renders at all: the chart refuses a pool whose class differs from its golden's, because across classes CDI either falls back to a host-assisted copy over the pod network (different CSI drivers or volume modes) or leaves a clone into the other class to the CSI driver. Leaving it empty makes the same comparison against the class CDI would pick. On a `builtin` pool the resolved class is then written onto the worker disk rather than left for the cluster to fill in at bind time, so a pool that has already cloned keeps binding on the class its disks are on even after an admin moves the default annotation; on the HTTP path an empty class is still left to the cluster. Has no effect on `substrate: proxmox`, where the worker disk is cloned from the VM template onto the template's storage or `proxmox.storage`.
// +kubebuilder:default:="replicated"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="storageClass is immutable"
StorageClass string `json:"storageClass"`