mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
## What this PR does 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. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [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(kubernetes-nodes): Fixed worker node disks not showing up as workloads of their Kubernetes cluster. Worker disk PVCs now carry the `cluster.x-k8s.io/deployment-name` and `cluster.x-k8s.io/role` labels that the worker pool's WorkloadMonitor selects on. Upgrading replaces every worker VM in every KubeVirt-backed node pool once. A pool can bring up as many replacement VMs at the same time as its `maxReplicas`, so the management cluster needs room for the extra VMs during the rollout. An old node is drained only once its replacement has joined, except in pools with passed-through GPUs, where one old node at a time can be drained while its replacement starts. Pods on the workers are evicted and rescheduled, and anything stored only on a worker's local disk is lost. Proxmox-backed pools do not restart. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit ## Summary * **Bug Fixes** * Workload monitoring can now match worker-node storage volumes using deployment and worker-role labels, without requiring a cluster-name label. * Corrected the expected machine-template name for configurations that specify CPU cores with leading zeros. * **Tests** * Updated coverage to verify storage-volume labels and leading-zero CPU rendering. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd