mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
The worker WorkloadMonitor selects PVCs by its selector labels, but a worker VM's disk PVC carried none of them, so it was never recorded as a Workload. CAPK stamps cluster-name and role on the VirtualMachine and its VMI template only and copies dataVolumeTemplates verbatim apart from a name prefix; CDI then builds the PVC from the DataVolume's labels. Putting the selector on the disk-system template is the only place the labels reach the PVC without teaching the shared controller to walk PVC -> DataVolume -> VirtualMachine owner chains. The disk must not carry cluster.x-k8s.io/cluster-name: the Kubernetes backup strategy selects DataVolumes and PVCs by it, so every worker root disk would be copied into each backup and deleted and restored by an in-place restore as cluster data. The WorkloadMonitor selector therefore drops cluster-name and keeps deployment-name and role; deployment-name already names a single MachineDeployment in the namespace, and the virt-launcher Pods the monitor counts still carry both labels. The KubevirtMachineTemplate is named by a hash of its content, so this renames it and every KubeVirt worker pool rolls once on upgrade. That is safe: the chart keeps any template a MachineSet still references, and the adoption migration matches templates by the 6-hex suffix pattern rather than by a fixed hash. Existing PVCs are not relabelled in place (CDI sets labels only at creation); the roll replaces them with labelled ones. Proxmox pools do not render this template and do not roll. Tested with helm unittest: cases assert the disk template carries exactly deployment-name and role and no cluster-name, and that the WorkloadMonitor selector is those two labels; snapshot and pinned template-name literals are updated for the new hash. Assisted-by: LLM Signed-off-by: Ray Low <crossrt@gmail.com>