mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 14:42:05 +09:00
## What this PR does Closes #5394. capi-operator v0.30 lists every ConfigMap a provider's `fetchConfig.selector` matches and returns an error when more than one comes back, before it reads `spec.version` (`processProviderConfigMaps`). Five of the six provider packages here selected their bundle on a provider-kind label alone, so a version bump — which renames the ConfigMap — left the old and the new ConfigMap matching for the length of the Helm upgrade and failed that reconcile. Helm deletes the old one in the same upgrade, so the next reconcile succeeds: an error window rather than data loss, but one that hits every upgrade of those providers. `capi-providers-core` and the kubeadm half of `capi-providers-bootstrap` already put `provider.cluster.x-k8s.io/version` on the ConfigMap and in the selector. This does the same for the remaining five pairs: | package | provider | version pinned | |---|---|---| | `capi-providers-bootstrap` | talos | `v0.6.13-bootstrap-talos` | | `capi-providers-infraprovider` | kubevirt | `v0.1.10-infraprovider` | | `capi-providers-infraprovider-proxmox` | proxmox | `v0.7.7-infraprovider-proxmox` | | `capi-providers-cpprovider` | kamaji | `v0.19.0-cozystack.0` | | `capi-providers-ipam-in-cluster` | in-cluster | `v1.0.3-ipam-in-cluster` | The kind label each package already had (`infraprovider-provider`, `cp-components`, `ipamprovider-provider`, `bootstrap-provider`) stays: it is what keeps one provider's bundle out of another's selector, and it is unrelated to the version match. The comment in the Proxmox ConfigMap said the operator would still install the right one because it keys every matched ConfigMap by name. That is not what v0.30 does any more — it rejects the multiple match outright — so the comment is replaced with what the operator does now, and the reason the version label is there. ## Verification New asserts in `hack/capi-provider-components_test.bats`, run with bats 1.14.0 and helm 3.19.0: - `every provider selector pins the ConfigMap version` — for each of the five packages plus core: exactly one provider object and one compressed bundle render, the bundle's `provider.cluster.x-k8s.io/version` label is non-empty, and both the selector and `spec.version` carry that same value. - `an upgrade with the previous ConfigMap present still matches one bundle` — synthesises the upgrade window by adding the previous release's bundle beside the rendered one; the selector has to keep matching exactly one object. - `the double-match fixture fails when the version label is removed` — the negative control: with the version label dropped from both the selector and the ConfigMap copy, that same fixture has to match two, so the assertion above is known to be able to fail. - `both bootstrap providers pin their own ConfigMap version` — the Talos pair, which the single-provider helper cannot cover. ``` $ bats hack/capi-provider-components_test.bats ok 25 every provider selector pins the ConfigMap version ok 26 an upgrade with the previous ConfigMap present still matches one bundle ok 27 the double-match fixture fails when the version label is removed ok 28 both bootstrap providers pin their own ConfigMap version ``` A/B: with the template changes stashed and the tests kept, all four new asserts fail (`selector does not pin the ConfigMap version`, `an upgrade matches more than one ConfigMap`, `talos does not select exactly one bundle`); restored, they pass. Also run, unchanged by this PR: - `bats hack/capi-upgrade-chart_test.bats` — 16/16 - `bats hack/capi-upgrade_test.bats` — 44/44 - `bats hack/capk-provider_test.bats` — 4/4 - `bats hack/bats-no-negated-assert.bats`, `bats-strict-setup.bats`, `bats-no-exit-trap.bats` — 10/10, 19/19, 22/22 - `make -C packages/system/capi-providers-bootstrap test` (helm-unittest 1.1.2) — 9/9 - `bash hack/check-commit-trailers.sh origin/main..HEAD` — OK - `python3 hack/check-helm-document-indices.py main` — clean - `git diff --check` — clean Not covered locally: 8 asserts in `hack/capi-provider-components_test.bats` fail on this machine both before and after this change, all with `sed: illegal option -- -` — `check_sums` / `check_patched_sums` use GNU `sed --quiet`, which is not POSIX and not present in macOS's BSD sed. They are unrelated to this diff and pass in CI on Linux. No full ctest/Go build was needed: the change is Helm templates and bats only. ## Downstream repositories No downstream repository is affected. This changes the labels and selectors inside five `packages/system/` charts; nothing in `cozystack/website`, `terraform-provider-cozystack`, `ansible-cozystack`, `ccp`, `talm`, `cozyhr`, `cozy-proxy`, `cozystack-telemetry-server`, `external-apps-example`, `examples` or `community` reads those label keys or restates these templates. `packages/system/` is not imported into the website's managed-apps reference, and no values key, schema, or release-notes convention changes. ```release-note fix(cluster-api): pin the ConfigMap version in every provider selector Bumping the Talos bootstrap, KubeVirt, Kamaji, Proxmox or in-cluster IPAM provider left its old and new components ConfigMap both matching the provider's selector for the length of the Helm upgrade, which capi-operator v0.30 rejects with "multiple ConfigMaps match selector". Each selector now carries `provider.cluster.x-k8s.io/version`, as the core and kubeadm providers already did, so an upgrade matches exactly one bundle. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Provider configurations now select the components bundle matching their version, avoiding ambiguous matches when older and newer bundles coexist during upgrades. * Bootstrap providers now select their own version-specific bundle, so each provider uses the correct components configuration. * Provider and bundle versions remain aligned across supported infrastructure, IPAM, control-plane, and bootstrap providers. <!-- end of auto-generated comment: release notes by coderabbit.ai -->