Aleksei Sviridkin ff7c2afdbd fix(kubernetes-nodes): label worker disks with the WorkloadMonitor selector (#5393)
## 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 -->
2026-11-23 17:32:04 +03:00
2026-11-04 00:56:56 +01:00
2025-10-08 09:43:34 +05:00
2024-02-08 12:04:32 +01:00

Cozystack Cozystack

GitHub Release Apache-2.0 License Commit activity OpenSSF Best Practices OpenSSF Scorecard CLOMonitor Support

Cozystack

Cozystack is a free and open-source platform and framework for building clouds.

Cozystack is a CNCF Sandbox project that was originally built and sponsored by Ænix.

With Cozystack, you can transform a bunch of servers into an intelligent system with a simple REST API for spawning Kubernetes clusters, Database-as-a-Service, virtual machines, load balancers, HTTP caching services, and other services with ease.

Use Cozystack to build your own cloud or provide a cost-effective development environment.

Cozystack user interface

Use-Cases

Documentation

The documentation is located on the cozystack.io website.

Read the Getting Started section for a quick start.

If you encounter any difficulties, start with the troubleshooting guide and work your way through the process that we've outlined.

Versioning

Versioning adheres to the Semantic Versioning principles.
A full list of the available releases is available in the GitHub repository's Release section.

Contributions

Contributions are highly appreciated and very welcomed!

In case of bugs, please check if the issue has already been opened by checking the GitHub Issues section. If it isn't, you can open a new one. A detailed report will help us replicate it, assess it, and work on a fix.

You are welcome to take on the fix yourself. Commits are used to generate the changelog, and their author will be referenced in it.

If you have a concrete feature request, open an issue. For a cross-cutting or architectural change, open a design proposal in the community repo. For questions or early ideas, use GitHub Discussions. See CONTRIBUTING.md for the full routing.

Community

You are welcome to join us in #cozystack, on either CNCF Slack (get an invite) or Kubernetes Slack (get an invite), in our Telegram group, and at our community meetings. Add them to your Google Calendar or iCal for convenience.

Project documents

Document What it covers
Governance How decisions are made and who makes them
Contributor Ladder How to grow from contributor to maintainer
Maintainers Who maintains the project
Code of Conduct What we expect of each other
Security Policy Reporting a vulnerability, and which releases get fixes
Adopters Who runs Cozystack in production
Roadmap Where the project is going

License

Cozystack is licensed under Apache 2.0.
The code is provided as-is with no warranties.

Commercial Support

A list of companies providing commercial support for this project can be found on official site.

Languages
Go 53.1%
Shell 33%
TypeScript 6.8%
Go Template 4.6%
Makefile 1.3%
Other 1.1%