Commit Graph
8904 Commits
Author SHA1 Message Date
Andrey Kolkov 6729dd8cfe fix(workloadmonitor): read the MetalLB pool from the metallb.io annotation
MetalLB writes the pool a Service's address came from to
metallb.io/ip-allocated-from-pool since v0.14.9; the
metallb.universe.tf key is only read on input now. The controller still
looked for the old key, so every Service Workload has recorded its
addresses under the "default" pool since MetalLB was updated to v0.15.2,
and a Service without annotations got an empty pool name.

Read the current key first and fall back to the deprecated one, then to
"default".

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-12-02 17:30:58 +07:00
Aleksei Sviridkin 236d039ae3 docs(agents): require an upstream reference for downstream patches (#5437)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, security (a fix that comes through a security
advisory), docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs
for automatically, so do not open backport PRs by hand:
https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->

## What this PR does

A patch this repository carries on top of someone else's code (an image
source patch, a vendored chart patch, a fork pin, a carried backport) is
meant to live only until the same change lands upstream. Nothing written
down asks for that link today, so whether a patch was ever offered
upstream, and when it can be dropped, depends on whoever wrote it.
Existing patch headers provide examples of upstream references and drop
conditions.

The rule is written once, in a new "Patches to other projects' code"
section of `CONTRIBUTING.md`: a PR that adds or changes a downstream
patch links the upstream pull request or submission, or at least the
issue or thread where it was raised; the patch header carries the link
next to its drop condition; a patch with no upstream counterpart says
why in the PR. The other places point to it rather than restating it:

- `AGENTS.md` gets a working principle that links the section and adds
what only agents need: an agent prepares the upstream change and its
text but does not open a pull request, issue or thread in another
project without explicit approval for that submission.
- The PR checklist in `docs/agents/contributing.md` gets one line
linking the section.
- The PR template gets a commented-out `Upstream:` field under "What
this PR does", with a one-line note to uncomment it when the PR touches
a downstream patch.

I checked what reads the PR body or the template: `pr-labeler.yaml`
reads only the title and a `BREAKING CHANGE:` footer, and
`hack/downstream-trigger-map.bats` reads only the `- [ ]
[cozystack/...]` checklist lines. A commented field reaches neither.
`hack/downstream-trigger-map.bats`, `hack/md-no-hardwrap.bats` and
`hack/label-workflows-contract.bats` pass.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

Not a UI change.

### 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.
-->

I left every box empty for a maintainer to decide. The trigger map lists
a PR template change under `cozystack/community`: its
`contributors/README.md` "Open the pull request" section restates the
required parts of the template. The new field is commented out and
optional, so that section stays correct, but the onboarding guide may
also want the new rule itself.

- [ ] 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

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
docs(agents): a pull request that adds or changes a downstream patch now links the same change offered upstream, or says why there is none.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Added guidance requiring downstream patches to link to the related
upstream submission or discussion, or explain why no counterpart exists.
* Clarified that upstream submissions require explicit user approval;
without approval, prepare the change and submission text and ask first.
* Updated the pull request template and checklist to prompt for upstream
links or an explanation when none exists.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 12:46:39 +03:00
Aleksei Sviridkin 137b68f07a test(hack): skip request-timeout calls that name a kubeconfig or context (#5406)
## What this PR does

`hack/check-hook-request-timeout.bats` exempts a file only when it names
`KUBECONFIG`. A hook script under `files/` that gets `KUBECONFIG` from
its template's env has no reason to name it, so a call that goes through
that kubeconfig with `--context` is flagged as an in-cluster call. That
is what turned `capi-providers-core/files/upgrade-providers.sh` red on
main; #5398 fixed that script by naming `KUBECONFIG`, and this keeps the
next script written the same way from hitting it again.

The check now skips a line that passes a non-empty `--context` or
`--kubeconfig`. client-go serves such a call from the loaded kubeconfig,
and without one `--context` fails with "context was not found" instead
of falling back to localhost:8080. An empty value (`--context ""`,
`--context=`, `--kubeconfig=`) does fall back, so it is still reported,
and so is a bare call in the same file. The header notes the limits: a
variable that is empty at runtime is not visible to the check, and the
match is per line.

Tested with `bats hack/check-hook-request-timeout.bats`: 11 of 11 pass,
the new cases fail without the change, and each part of the filter is
pinned by a mutation. The empty-value fallback was reproduced with
kubectl v1.37.2.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

### 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

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
NONE
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Timeout checks now exclude matching lines that specify a non-empty
context or kubeconfig value. Empty option values and bare calls on
separate lines are still reported; files naming `KUBECONFIG` remain
excluded.
* **Documentation**
* Clarified how context and kubeconfig options affect timeout reporting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 12:46:11 +03:00
Aleksei Sviridkin 79ed8e1164 fix(redis): let the operator delete a disabled Sentinel PDB instead of a per-upgrade hook (#5429)
## What this PR does

When a Redis instance runs a single pod, the chart runs one Sentinel and
sets `disablePodDisruptionBudget` on it. The redis-operator stops
ensuring the Sentinel PDB once that flag is set, but never deletes the
PDB it created earlier, and the PDB's owner reference only removes it
together with the RedisFailover. An instance scaled down from three pods
therefore keeps a `minAvailable: 1` PDB on its only Sentinel, and every
node drain blocks on it.

The chart worked around this with a post-upgrade Helm hook: a
ServiceAccount, a Role, a RoleBinding and a kubectl Job, rendered on
every upgrade of every single-replica instance, to delete a PDB the
operator should have removed itself. The operator image is already built
in this repository with carried patches, so I fixed it there instead.

- `redis-operator`: a new source patch makes the operator look the
Sentinel or Redis PDB up on reconcile while its
`disablePodDisruptionBudget` is set, and delete it only when the
RedisFailover is its controller. A PDB without that owner is left alone,
no delete is sent when there is no PDB, and one that disappears between
the lookup and the delete counts as done. It has a unit test next to the
operator's own `EnsureSentinelDeployment` tests, which the image build
runs for every package a patch touches. The patch header says it is
carried until an upstream release includes the change.
- `redis`: the hook, its RBAC, its chart tests and the
`redis.sentinelReplicas` helper extracted for it are removed. The
single-Sentinel change and its tests stay as they were.
- e2e: the base Redis case now scales its instance from two replicas to
one and asserts that `rfs-<name>` existed before and is gone after, and
that the data pods' PDB stays.

Upgrade: an instance that still has the stale PDB loses it on the first
reconcile by the updated operator, which resyncs every RedisFailover
every 30 seconds. Until the operator Deployment rolls, the PDB stays, so
drains on such an instance can block for that window. Hook objects from
earlier upgrades are not release resources, so Helm does not touch them;
the successful runs already deleted theirs through `hook-succeeded`. A
run that failed leaves its ServiceAccount, Role and RoleBinding named
`<release>-sentinel-pdb` behind (its Job goes after an hour through
`ttlSecondsAfterFinished`). They grant only get and delete on one PDB
and can be removed by hand.

Cost: while a PDB is disabled, every reconcile (on each RedisFailover
change and on the 30-second resync) reads it once from the API server; a
delete is sent only when an owned PDB is still there.

I have not run the image build or the e2e suite. The patch series
applies on the v3.3.5 tarball, alone and together with the operator
patch of the open draft #5382, and every package it touches passes `go
test` and `go vet -tags integration`. `helm unittest
packages/apps/redis` passes. Upstream v3.3.5 is the latest release and
its master still has the same code, so there is no version to bump to; a
version of the patch rebased onto upstream master, without the `tlsHash`
parameter the carried TLS patch adds, is open as
freshworks-oss/redis-operator#93, and the patch header links to it.

### Screenshots

Not a UI change.

### Downstream repositories

- [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:

No values key, schema, README or version enum changes; the diff touches
an image patch, chart templates and tests, and the Redis e2e suite only.

### Release note

```release-note
fix(redis): the redis-operator now deletes the Sentinel or Redis PodDisruptionBudget it created once that budget is disabled, so a Redis scaled down to one replica no longer keeps the Sentinel PDB that blocks node drains, and the chart no longer runs a cleanup Job with its own RBAC on every upgrade of a single-replica instance.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Redis and Sentinel PodDisruptionBudgets are removed when their
respective settings disable management, provided they are owned by the
RedisFailover. Missing or unrelated budgets are left unchanged.
* Sentinel replica counts remain at one when Redis is configured with
one replica, and three otherwise.
* When switching to one Sentinel replica with PDB management disabled,
the Sentinel budget is removed while the data-pod budget remains. The
Helm release is then verified as ready.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 12:46:07 +03:00
Aleksei Sviridkin 17eb78d952 docs(agents): require accepted designs before merging implementations (#5465)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
-->

## What this PR does

The contributing guide sends architectural changes to a design proposal
in cozystack/community, but it never said when the code implementing one
may merge. A clean implementation could land while its proposal was
still under review, and the design then had to follow the code that
shipped first.

`CONTRIBUTING.md` now says that such a pull request stays in draft until
the proposal is merged into community, that opening it early as a proof
of concept is welcome, and that it closes if the proposal is closed
without being accepted. The `triage/needs-proposal` line in `AGENTS.md`
and the pull request checklist in `docs/agents/contributing.md` point to
that paragraph, so the rule lives in one place.

### Screenshots

Not a UI change.

### Downstream repositories

- [ ] 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:

None of the code repositories is reached. I left the community box open
on purpose: its `design-proposals/README.md` could state the same rule
from the proposal side, and whether to add it is a maintainers' call, so
I have not opened anything there.

### Release note

```release-note
docs(contributing): a pull request that implements a design proposal stays in draft until the proposal is accepted in cozystack/community.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Clarified that implementation pull requests for design proposals may
be opened early as drafts for proof-of-concept work, but can merge only
after the proposal is accepted.
* Added guidance to link early proof-of-concept work from the proposal
and to close the implementation if the proposal is not accepted.
* Clarified that accepted proposals require a separate implementation
issue, which may be an existing issue that references the proposal.
* Updated the contributor checklist to reference the draft pull request
guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 12:46:03 +03:00
Aleksei Sviridkin 7bf48125ca fix(cluster-api): pin the ConfigMap version in every provider selector (#5400)
## 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 -->
2026-12-02 08:08:15 +03:00
Aleksei Sviridkin 1b5a5e5cf5 test(redis): assert a scaled-down instance loses its Sentinel PDB
Every Redis e2e case runs two replicas, so the single-Sentinel path,
where the chart disables the Sentinel PDB and the operator has to
delete the one it created for three Sentinels, was covered only by the
operator's unit test. Scale the base instance from two replicas to one
and assert that the PDB existed before, is gone after, and that the
data pods' PDB stays.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-12-02 05:45:53 +03:00
Aleksei Sviridkin aeb9bf6fbf fix(redis): drop the post-upgrade hook that deleted the Sentinel PDB
The hook ran a ServiceAccount, Role, RoleBinding and a kubectl Job on
every upgrade of every single-replica instance, to delete the Sentinel
PDB the operator left behind once disablePodDisruptionBudget was set.
The operator now deletes a disabled PDB itself on reconcile, so the
hook, its RBAC and the helper extracted for it have no work left.

An instance that still carries the stale PDB loses it on the first
reconcile by the updated operator.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-12-02 05:45:52 +03:00
Aleksei Sviridkin 56648783b3 fix(redis-operator): delete a PDB once it is disabled
The operator ensures the Sentinel and Redis PDBs only while
disablePodDisruptionBudget is unset. Setting it later stops the
updates but never deletes the PDB already created, and its owner
reference removes it only with the RedisFailover. A Redis instance
scaled down to one pod thus keeps a minAvailable 1 PDB on its single
Sentinel, which refuses every eviction and blocks node drains.

While the PDB is disabled, look it up on reconcile and delete it only
when this RedisFailover controls it: a PDB created by someone else
under the same name is not the operator's to remove. No delete is
sent when there is no PDB, and one that disappears between the lookup
and the delete counts as done. The delete carries the UID and
resourceVersion it checked, so a PDB replaced or re-owned between the
lookup and the delete is left for the next reconcile to judge.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-12-02 05:45:52 +03:00
Aleksei Sviridkin 40a3b0ba2c fix(clickhouse, opensearch): reap finished cleanup Jobs (#5543)
## What this PR does

Every deleted ClickHouse or OpenSearch leaves a Completed
`<release>-cleanup` Job and its pod in the tenant namespace for good,
because the post-delete hooks keep only `before-hook-creation` and have
no TTL. The commit adds `ttlSecondsAfterFinished: 86400` to both Jobs,
the same value `pre-delete-unpin` in kubernetes-nodes uses, so a
succeeded run is reaped and a failed one still keeps its logs for a day.

The cleanup tests of both charts gain a case for the TTL; it fails on
main and passes here, and the 46 ClickHouse and 153 OpenSearch tests
pass.

Closes #5542

### Screenshots

Not a UI change.

### Downstream repositories

- [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(clickhouse, opensearch): the post-delete cleanup Job of a deleted ClickHouse or OpenSearch is removed a day after it finishes instead of staying in the tenant namespace for good.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Improvements**
* Completed PVC cleanup jobs and their pods are now eligible for
automatic removal after one day in ClickHouse and OpenSearch, helping
prevent finished cleanup resources from lingering.
* Failed cleanup jobs remain available for troubleshooting during that
retention period.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 05:13:31 +03:00
Aleksei Sviridkin 279efc5a82 fix(harbor): keep the trivy volume class of the live StatefulSet (#5541)
## What this PR does

A Harbor with trivy enabled and no `storageClass` cannot be changed
after install: every upgrade of `harbor-<name>-system` is rejected on
the trivy StatefulSet, so the release stays not Ready and no later chart
change reaches it. The chart read the class for the trivy
`volumeClaimTemplate` from the PVC, which the default-StorageClass
admission stamps, instead of from the StatefulSet template, which it
never touches. The commit reads the class from the live StatefulSet
template.

The failure was reproduced on a cluster running v1.7.3 by patching a
Harbor created with `spec: {}`. The new helm-unittest suite mocks the
live StatefulSet and its defaulted PVC; all three cases fail on main and
pass here, and the 77 tests of the chart pass.

Closes #5540

### Screenshots

Not a UI change.

### Downstream repositories

- [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(harbor): a Harbor with trivy enabled and no storageClass can be changed after install again; the chart keeps the volume class of the live trivy StatefulSet instead of copying the class the PVC got from the default StorageClass.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Trivy storage-class handling now reflects the storage class configured
on its StatefulSet volume template. Existing fallback behavior is
unchanged.
* **Tests**
* Added coverage for Trivy storage-class behavior when the StatefulSet
template has no storage class, when a storage class is configured, and
when the chart’s `storageClass` setting is present.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 04:59:26 +03:00
Aleksei Sviridkin 24122ed3ad docs(contributing): hold implementations until their design is accepted
The contributing guide sends architectural changes to a design
proposal in cozystack/community, but said nothing about when the code
that implements one may merge. A clean implementation could land while
its proposal was still under review, and the design then had to follow
the code that shipped first.

State that such a pull request stays in draft until the proposal is
merged, and that opening it early as a proof of concept is welcome.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-12-02 04:50:58 +03:00
Aleksei Sviridkin ec576c9369 docs(agents): require an upstream reference for downstream patches
A patch carried on top of someone else's code is meant to be
temporary: it stays only until the same change lands upstream. Without
a link to the upstream submission nobody can tell whether that is
underway, when the patch can be dropped, or whether it was ever
offered at all.

The rule is written once, in CONTRIBUTING.md, so that human
contributors read it in the file addressed to them. AGENTS.md points
to it and adds that an agent prepares the upstream submission but does
not publish it in another project without explicit approval. The
agent PR checklist and the PR template point to the same section; the
template field is commented out so that PRs without a downstream patch
are unaffected.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-12-02 04:42:02 +03:00
Aleksei Sviridkin 0616d251cd docs(contributing): define what counts as a breaking change (#5253)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, security (a fix that comes through a security
advisory), docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer, a `fix` included. What counts as
breaking:
https://github.com/cozystack/cozystack/blob/main/docs/agents/contributing.md#what-counts-as-breaking
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs
for automatically, so do not open backport PRs by hand:
https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->

## What this PR does

Contributing guide and PR template say how to mark a breaking change,
`!` after type/scope or a `BREAKING CHANGE:` footer, but nothing says
what makes a change breaking. This PR adds that to
`docs/agents/contributing.md`: after the upgrade an existing install,
client or consumer is refused, loses something it used, or has to be
edited to keep working.

The case that showed the gap is
[#4973](https://github.com/cozystack/cozystack/pull/4973). It was a
`fix` that made a values shape the previous version ran fail at render
time. It merged with a release note about it and without `!`, and no
written rule decided it either way.

The definition follows what maintainers already mark with `!` on merged
fixes, it is not a new policy:
[#4847](https://github.com/cozystack/cozystack/pull/4847) (runtime
refusal), [#4639](https://github.com/cozystack/cozystack/pull/4639) and
[#4796](https://github.com/cozystack/cozystack/pull/4796) (refusal only
for new or changed objects, existing ones keep working). Not breaking: a
change that only accepts more, makes something broken work, refuses only
what never worked even if it rendered or deployed, or changes how a
working install runs while it keeps working. Refusing what never worked
is how [#4973](https://github.com/cozystack/cozystack/pull/4973) treats
its own no-sizing pool, and it is why
[#4567](https://github.com/cozystack/cozystack/pull/4567) was a plain
`fix`.

I walked the text against
[#4973](https://github.com/cozystack/cozystack/pull/4973) and
[#5083](https://github.com/cozystack/cozystack/pull/5083) (breaking,
both merged without `!`) and against
[#4220](https://github.com/cozystack/cozystack/pull/4220),
[#4974](https://github.com/cozystack/cozystack/pull/4974),
[#3935](https://github.com/cozystack/cozystack/pull/3935) (not
breaking). One place it differs from a marker:
[#4569](https://github.com/cozystack/cozystack/pull/4569) has `!`, but
its value rendered and KubeVirt never admitted it, so by this text it is
not breaking.

The text also says the `fix` type does not exempt a change, and an
`Action required` line in the release note does not replace the marker.
PR template tip line links to the new section (link works after merge,
same as the backports one next to it).

A default change that degrades a working install without failing it is
not covered. If it should be, please say so here.

`contributors/README.md` in
[cozystack/community](https://github.com/cozystack/community) repeats
the marker syntax and has no definition either. No follow-up there yet,
so the downstream boxes stay empty.

Not in this PR: `labels.yml`, `pr-labeler.yaml`, the release docs, and a
check for `Action required` without the marker.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

### 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.
-->

- [ ] 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

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
docs(contributing): the contributing guide now defines a breaking change (after the upgrade an existing install, client or consumer is refused, loses something it used, or has to be edited to keep working), says the `fix` type does not exempt a change and an `Action required` line in the release note does not replace the `!` marker. The PR template links to it.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Documentation**
* Added clearer guidance on what qualifies as a breaking change,
including examples of changes that are not breaking.
* Defined breaking changes by whether an upgrade prevents previously
working installs, clients, or consumers from working, or removes
something they use.
* Linked the pull request template’s breaking-change guidance to the
contributing documentation.
* Clarified that commit markers and release notes are separate
requirements, and that commit type or prior buggy behavior does not
determine whether a change is breaking.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 04:41:53 +03:00
Goldloli 7a94e202ca fix(cluster-api): pin the ConfigMap version in every provider selector
capi-operator v0.30 refuses a provider whose fetchConfig.selector matches
more than one ConfigMap, and it decides that before it reads spec.version
(processProviderConfigMaps). Talos bootstrap, KubeVirt, Kamaji, Proxmox and
in-cluster IPAM selected their bundle by a provider-kind label alone, so a
version bump left the old and the new ConfigMap matching for the length of
the Helm upgrade and failed that reconcile. Core and kubeadm already carry
provider.cluster.x-k8s.io/version in both the ConfigMap and the selector;
this brings the remaining five packages in line.

Each package now defines that version once, in templates/_helpers.tpl, and
the ConfigMap name, its version label, the selector and spec.version all
include it. Hard-coding the value in four places per provider meant a bump
could move the ConfigMap name and leave the label behind, and two bumps in
flight in the same package (as #5243 does for capmox and in-cluster IPAM)
would then disagree with each other. With one definition a bump is one line
and the four references cannot drift. The Talos pair uses its own define
because it tracks CABPT, while the kubeadm pair keeps the chart appVersion.

The comment in the Proxmox ConfigMap claiming the operator would still pick
the right one described the v0.30-or-earlier behaviour and is replaced with
what the operator does now.

Refs: #5394
Assisted-by: LLM
Signed-off-by: Goldloli <39011904+Goldloli@users.noreply.github.com>
2026-12-02 03:43:19 +03:00
Aleksei Sviridkin d27f8c950f fix(tenant): allow etcd and ingress egress to all ancestors at any depth (#5442)
## What this PR does

The `<tenant>-egress` CiliumClusterwideNetworkPolicy builds the list of
ancestor namespaces for the etcd and ingress rules by walking
dash-prefixes of `.Release.Namespace`. A tenant HelmRelease lives in its
parent namespace, so for a tenant at depth >= 2 (e.g.
`tenant-acme-nonprod`, released into `tenant-acme`) the walk never
reaches `tenant-root`.

When an intermediate tenant has no etcd of its own, the child inherits
etcd from `tenant-root` (`namespace.cozystack.io/etcd: tenant-root`) but
is not allowed to reach it. The Kamaji control plane of a tenant
Kubernetes cluster in such a tenant times out on
`etcd.tenant-root.svc:2379` and never becomes ready. Ingress has the
same gap.

The chart already fixed this class of bug for namespace labels
(`tenant.ancestorTenantLabels`). This PR adds
`tenant.ancestorNamespaces`, which derives the chain from the tenant's
own namespace (`tenant-root` plus every dash-prefix except the tenant
itself), and uses it for the etcd and ingress rules. The set of allowed
destinations only grows: every previously reachable ancestor stays
reachable.

The vminsert/vlinsert rule is left untouched; #5257 fixes it separately.

Found while running a second-level tenant (`tenant-root` → `aepdev` →
`nonprod`) with a tenant Kubernetes cluster on v1.7.1.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change

### Release note

```release-note
fix(tenant): tenants nested two or more levels deep can now reach etcd and ingress inherited from tenant-root, so tenant Kubernetes clusters in them start correctly.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Tenant network policies now correctly allow access to required
services in ancestor namespaces, including etcd, ingress, and vminsert.
* Ancestor access is handled consistently across tenant hierarchy
depths, including root tenants and cases where service ownership details
are unavailable.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 03:42:07 +03:00
Myasnikov Daniil 65db30265e docs(contributing): define what counts as a breaking change
The guide says how to mark a breaking change and never says what one
is. A fix that made a values shape the previous version rendered fail
at render time was merged with no marker, and review asked for a
release note instead, because neither this file nor the PR template
gives a test to apply.

The test is what an install that already runs gets after the upgrade:
refused, stripped of something it used, or made to edit its config.
The commit type says what a change is for, not what it does to an
install that is already running.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-12-02 03:40:08 +03:00
Aleksei Sviridkin 8c1e085c92 fix(dashboard): keep re-login working across tabs after logout (#5536)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, security (a fix that comes through a security
advisory), docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list — pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Fixes merged to `main` reach the release lines the backport batch runs
for automatically, so do not open backport PRs by hand:
https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md
-->

## What this PR does

With OIDC enabled, signing out of the dashboard and signing back in
often lands on the oauth2-proxy `403 Forbidden` page right after
Keycloak accepts the password, and the gatekeeper logs `Invalid
authentication via OAuth2: CSRF token mismatch, potential attack`. The
user has to press "Sign in" again to get in.

oauth2-proxy keeps a pending login in a single `kc-access_csrf` cookie.
After a logout every other open console tab hits a 401 on its next API
call or watch reconnect and starts its own sign-in, overwriting that
cookie, so the callback of the tab the user is typing into no longer
matches. The gatekeeper now runs with `--cookie-csrf-per-request` so
each sign-in gets its own CSRF cookie, and
`--cookie-csrf-per-request-limit=10` caps how many abandoned flows can
accumulate in the request headers. Both flags exist in the pinned
oauth2-proxy v7.12.0.

Verified on a test cluster: reproduced the 403 on the current release
with two tabs, then ran the chart-rendered oauth2-proxy v7.12.0 config
against the same live Keycloak with the dashboard host resolved to it.
Without the new flags the tab that submits the password gets the 403 and
the proxy logs the CSRF mismatch; with them both sign-ins complete and
no auth failure is logged. A helm-unittest case pins both flags.

Not covered here: a login page left open for longer than the CSRF cookie
lifetime (`--cookie-csrf-expire`, 15 minutes by default) still ends on
the same 403, because the cookie for that flow has expired; that needs a
separate decision on how the logout should land. `linstor-gui` runs its
own oauth2-proxy with a shared CSRF cookie as well; I have not
reproduced the problem there, so it is left out of this PR.

### Screenshots

No visual change: only the gatekeeper's oauth2-proxy flags change.

### 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

<!--  Write a release note:
- Explain what has changed internally and for users.
- Start with the same `type(scope):` prefix as in the PR title
- Follow the guidelines at
https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md.
-->

```release-note
fix(dashboard): signing back in after a logout no longer fails with a 403 "CSRF token mismatch" when several dashboard tabs are open.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* OIDC sign-in now uses separate CSRF cookies for each request,
supporting concurrent sign-in flows. The number of these cookies is
capped at 10, limiting buildup when sign-in flows are abandoned.
Existing cookie settings remain in place.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-02 03:38:45 +03:00
Aleksei Sviridkin 15126f27ca feat(clickhouse)!: mint tenant passwords through the credentials API (#5378)
## What this PR does

ClickHouse passwords are no longer readable from `<release>-credentials`
and can't be set through `users.<name>.password`. Today every `use`
member reads them there, and a leaked one can't be taken back. Now an
administrator mints a password on the user's `Credential`, sees it once,
and the next mint or a revoke kills it. This is the ClickHouse part of
the user secrets API design (cozystack/community#137).

Stacked on #4922. Review only the top four commits:

- `credentials-migrate` gets `--reserved-user`, `--values-path` and
`--rotate-key`.
- `credentials-migrate` can hold a kind's releases until given
Deployments run their new images.
- The chart renders a `sha256` CredentialTemplate per user and reads the
stored hash through `valuesFrom`, since the ClickHouse operator reads no
Secrets. `backup`, `default` and `clickhouse_operator` are refused as
user names.
- Migration 65 seeds the account Secrets from `<release>-credentials`
and suspends the ClickHouse releases before the chart switches. Its
finish Job, under its own `cozystack-credentials-migration-65` identity,
resumes them only after the new cozystack-controller and cozystack-api
run, then removes the tenant keys and rotates `backup` once, because
tenants could read it. The hold exists because the old controller strips
the `valuesFrom` entries the migration adds: without it the new chart
rendered no users, and clients were locked out for 10 minutes on the
first upgrade run.

Tested on a three-node cluster, fresh install: a minted password logs in
after about 60 s (the Helm re-render), the old one dies 2 s after the
next mint, revoke works, and removing a user removes everything. Mints
restart nothing. Full upgrade from 1.7.1 on the same cluster, all
engines at once with a client loop each: migrations 64-71 ran in order
and every account was adopted with its old password. The ClickHouse
releases were held for 19 minutes and the client loop saw no
authentication error.

Breaking for users: passwords can't be read any more, and each mint
costs a Helm upgrade of about a minute. Pods restart once during the
conversion for the `backup` rotation. While the hold lasts (19 minutes
on the test cluster) the ClickHouse apps can't be changed or deleted. A
release with a user named `backup`, `default` or `clickhouse_operator`
is not converted and raises `CredentialsMigrationIncomplete`.

Open questions:

1. `users.default` is refused, as the design says. Tenants may be using
it today, so should it be a mintable account instead?
2. A Helm upgrade already running during the `backup` rotation can write
the old value back. Should finish wait for the release to be idle?

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, a ClickHouse note for the credentials API docs
(cozystack/website#753) and an upgrade note that clients must mint
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_clickhouse` still sends
`users.<name>.password`
- [ ]
[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
feat(clickhouse)!: ClickHouse passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies after the next Helm upgrade of the release, about a minute. Existing passwords keep working through the upgrade, and migration 65 rotates the platform `backup` password, which restarts each ClickHouse instance once. A release with a user named `backup`, `default` or `clickhouse_operator`, or with a name that does not map to a valid account name, is not converted until the user is renamed; renaming a ClickHouse user means changing the apps that log in as it. Switch clients to minted passwords after the upgrade.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* ClickHouse account passwords can now be issued and revoked through the
credentials API. Newly issued passwords are available once and can be
used to log in after the release is upgraded.
* Platform-managed accounts are reserved, and account names are
validated for conflicts and supported formats.
* Platform upgrades now migrate existing ClickHouse credentials and
support backup-password rotation.
* **Bug Fixes**
* Tenant account passwords are no longer stored in the ClickHouse
credentials Secret; only the platform backup password remains there.
  * The credentials Secret is no longer exposed as a tenant resource.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-01 22:05:13 +03:00
Aleksei Sviridkin a1e938767c fix(external-dns): stop enabling the service source on tenant instances (#5470)
## What this PR does

Every `ExternalDNS` application crash-loops about a minute after it
starts and never publishes a record. It always enables the `service`
source, which starts a Node informer, but the instance runs namespaced,
so its Role has no `nodes` rule and the informer never syncs (`failed to
sync *v1.Node: context deadline exceeded`).

Closes #4958

The single commit drops `service` from the hardcoded sources, as agreed
on the issue, so the default configuration uses only `ingress`. The
rendered Gateway API source list is preserved; its separate cluster-wide
informer permissions problem remains outside this fix. It also adds a
`test` target and a helm-unittest suite to the package that pins the
rendered sources in both cases. Both tests fail on current `main`.

Nobody loses records: tenants can't annotate the Services the platform
renders, so the `service` source published nothing. The kuberture guide
already pairs its annotated Services with the cluster-wide
`cozystack.external-dns` package, not this application.

### Screenshots

N/A, no UI changes.

### Downstream repositories

- [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(external-dns): ExternalDNS applications no longer crash-loop on "failed to sync *v1.Node". The tenant instance stops enabling the `service` source, which needs cluster-wide read on Nodes that its namespaced Role cannot grant, and publishes records from Ingresses in the default configuration.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Configuration**
* ExternalDNS monitors ingress resources by default. Service resources
are no longer included as a discovery source.
* When Gateway API support is enabled, ExternalDNS also monitors Gateway
API HTTP and TLS routes.
* **Tests**
* Added checks confirming the default discovery sources and the sources
used when Gateway API support is enabled.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-12-01 21:47:44 +03:00
Yan Bondarenko 9227c2e211 fix(clickhouse, opensearch): reap finished cleanup Jobs
The post-delete PVC cleanup Jobs of ClickHouse and OpenSearch keep only
before-hook-creation, so a failed run stays for post-mortem. Helm drops
the hook once the release is gone, and nothing else deletes the Job, so
every deleted instance leaves a Completed <release>-cleanup Job and its
pod in the tenant namespace for good; on the cluster the oldest had sat
there for 85 days.

Set ttlSecondsAfterFinished to a day, as pre-delete-unpin in
kubernetes-nodes does, so a succeeded run is reaped and a failed one
still keeps its logs long enough to read.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-12-01 19:33:36 +01:00
Yan Bondarenko 1ca2a943cf fix(harbor): keep the trivy volume class of the live StatefulSet
A Harbor with trivy enabled and no storageClass could not be changed
after install: the next upgrade of the release failed with

  StatefulSet.apps "<release>-trivy" is invalid: spec: Forbidden: updates
  to statefulset spec for fields other than 'replicas', 'ordinals',
  'template', 'updateStrategy', 'revisionHistoryLimit',
  'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are
  forbidden

The chart took the class for the trivy volumeClaimTemplate from the
data-<release>-trivy-0 PVC. The default-StorageClass admission stamps
the class onto that PVC but never onto the StatefulSet, so the render
put a class into a template created without one. Read the class from
the template of the live StatefulSet instead.

Fixes: bdf520bf74 ("fix(harbor): preserve jobservice and trivy storageClass on upgrade")
Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-12-01 19:28:46 +01:00
AuricX 5a0ee76edf fix(external-dns): stop enabling the service source on tenant instances
An ExternalDNS application crash-loops a minute after every start and
publishes no records:

  level=fatal msg="failed to sync *v1.Node: context deadline exceeded with timeout 1m0s"

The instance runs external-dns namespaced, so the vendored chart renders
a Role and leaves out the nodes rule, because a Role cannot grant a
cluster-scoped resource. The service source still starts a Node
informer, which never syncs without that grant.

Drop service from the hardcoded sources rather than grant nodes through
a ClusterRole. The source only publishes Services that carry the
external-dns hostname annotation, and tenants cannot annotate the
Services the platform renders in their namespace, so it published
nothing here. A ClusterRole would be cluster-scoped RBAC created by a
tenant application for a source with no use.

Tested with a new helm-unittest suite that pins the rendered sources
with and without gatewayAPI. Both cases fail while service is listed.

Closes: #4958
Assisted-by: LLM
Signed-off-by: AuricX <auricx.business@gmail.com>
2026-12-01 17:05:45 +02:00
Andrei Kvapil 6d72324818 feat(platform): migration 65 converts ClickHouse credentials
Existing ClickHouse releases keep working across the chart switch: the
hook writes each tenant account's Secret from the password in
<release>-credentials and adds the valuesFrom entries the converted
chart reads the verifiers from, so its first render already lets every
client in. A release with a user under a reserved name is left out and
keeps its previous chart.

The hook also holds every ClickHouse release, suspended, until both
cozystack-controller and cozystack-api run their new revision. Without
the hold the converted chart switched while the old controller was still
running; it had already rebuilt each release's valuesFrom without the
account entries this migration added, so the first render left every
tenant user out of the installation and clients were locked out until
the new controller put them back, ten minutes later on a test cluster.
The old cozystack-api drops the same entries on any tenant write.

The finish Job then resumes the releases with the entries put back,
strips leftover users.*.password, keeps only the backup password in
<release>-credentials and rotates it once, because tenants could read it
before. Its ServiceAccount, ClusterRole and binding are named
cozystack-credentials-migration-65 like the Job, so an operator finds
them next to it and this hook never deletes the identity migration 64's
Job may still run as. The role may read Deployments for the hold.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-12-01 14:30:31 +01:00
Andrei Kvapil 2f4f82a36c feat(clickhouse)!: render a CredentialTemplate per user
Tenant passwords move to platform-minted credentials. The chart no
longer generates, looks up or renders any tenant password and ignores
users.<name>.password: it renders one CredentialTemplate per user, and
cozystack-controller keeps the account Secret holding the SHA-256 of
the password the Cozystack API mints.

The operator watches no Secrets, and a hash inline in the
ClickHouseInstallation is the only path it applies without a restart,
so the template asks for a valuesPath: the HelmRelease pulls each
stored hash into _accounts.u<digest of the user name>, the chart
renders it as password_sha256_hex, and the Flux watch label upgrades
the release when a mint changes the Secret. A user with no verifier in
the values is left out of the installation, because the operator would
give a passwordless user the password "default".

backup stays a platform account in <release>-credentials, which now
holds only it, is labelled not tenant visible and is no longer selected
by the ApplicationDefinition. The names backup, default and
clickhouse_operator are refused for tenant users. A rotation of the
backup password restarts the pods once, since the backup sidecar reads
it from its environment at start.

A user whose account name is longer than 63 characters, does not start
and end with a letter or a digit, or is shared with another user is
refused at render, as credentials-migrate refuses it, so an install and
an upgrade accept the same names. A users.<name>.password left in
values draws an admission warning that points at a mint on the user's
Credential.

Existing clients lose readable passwords; an administrator mints a new
one.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-12-01 14:30:31 +01:00
Andrei Kvapil 85243d43f1 feat(credentials-migrate): hold releases until their deps roll out
Every application chart is copied out of the one cozystack-packages
source, so all of them switch the moment the platform chart moves it,
while cozystack-controller and the operators roll out on their own
schedule. A Package dependsOn does not order that: tenant releases carry
no dependsOn, and Flux only asks that a dependency be Ready, which it
is on its old revision. On a live upgrade the old controller stripped
the ClickHouse valuesFrom entries and the old redis-operator rolled the
converted Redis pods its own way, locking clients out for minutes.

--hold-until-rollout lets the hook record the images a Deployment runs
and suspend every release of the kind; the finish Job resumes them, with
their valuesFrom re-seeded, once each Deployment runs other images on
all of its pods. Neither the old controller nor the old API touches
spec.suspend. A hold that times out keeps the releases suspended and
reports them left out, since running on the old chart is safer than a
converted one the old components act on.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-12-01 14:30:31 +01:00
Andrei Kvapil e1880c5a00 feat(credentials-migrate): reserved users, values path and rotation
ClickHouse is the first kind whose operator reads no Secret and which
keeps a platform account next to its tenant ones, and three things it
needs are not specific to it.

A tenant user under a name the converted chart refuses (the platform
backup account, the engine's default user) makes the release
unresolvable, so it is left out instead of converted in part.

The CredentialTemplate controller adds the valuesFrom entries of a
valuesPath kind only after the converted chart has rendered its
templates, so that first render would carry no stored value and the
chart would drop every tenant account from the engine until the next
upgrade. The hook now adds the same entries ahead of the switch; the
old chart ignores the values they fill.

finish rotates the platform passwords tenants could read once, with
the release suspended, then forces an upgrade so the chart applies
them, and records the rotation on the source Secret so a rerun does not
rotate twice.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-12-01 14:30:31 +01:00
Alexey Artamonov 4ad4a44014 fix(dashboard): keep re-login working across tabs after logout
With OIDC enabled, signing out of the dashboard and signing back in
often ends on the oauth2-proxy 403 page even though Keycloak accepted
the password. The gatekeeper log shows

  Invalid authentication via OAuth2: CSRF token mismatch, potential attack

oauth2-proxy keeps the state of a pending login in a single
kc-access_csrf cookie. After a logout every other open console tab
gets a 401 on its next API call or watch reconnect and starts its own
sign-in, which overwrites that cookie, so the callback of the tab the
user is typing into no longer matches. Giving each flow its own CSRF
cookie keeps concurrent sign-ins independent; the limit caps how many
abandoned flows can accumulate in the request headers.

Tested by running the chart-rendered oauth2-proxy v7.12.0 config
against a live Keycloak with two tabs signing in after a logout:
without the flags the first tab gets the 403 above, with them both
sign-ins complete.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-12-01 16:07:22 +03:00
Aleksei Sviridkin ce04ec3fb8 perf(ci): build release lines from their own cache, in parallel (#5484)
## What this PR does

Release-line image builds read only main's build cache. After main moved
its builder and base images, release-1.7 Dockerfiles stopped matching
that cache, and rc Build step went from 19 to 53 minutes on amd64 and
from 10 to 46 on arm64
(https://github.com/cozystack/cozystack/actions/runs/43213142925 for
v1.7.1-rc.2,
https://github.com/cozystack/cozystack/actions/runs/45853634981 for
v1.7.2-rc.2).

Each line now keeps own cache. `build-release.yaml` writes
`buildcache-release-X.Y` on every push to the line, and rc builds import
it together with main's `buildcache` through new `CACHE_FROM_TAGS`
(defaults to `CACHE_TAG`, so other builds don't change). Lines have no
arm64 push build, so arm64 rc build writes
`buildcache-arm64-release-X.Y` itself.

Image units now build four at a time (`make build-parallel`,
`hack/build-units.sh`), most of their time is registry round trips
anyway. Every output line carries its unit and is written as it comes.
`objectstorage-controller` waits for the rest because it writes
seaweedfs `values.yaml`. Local `make build` stays sequential. rc jobs
also set `cleanup: false` on buildx, teardown took up to 11 minutes on
arm64 (682s in v1.7.2-rc.2).

Known limits: two rc tags of the same line building at the same time
write the same arm64 cache ref, last one wins and only cache hits
suffer. `capi-providers-cpprovider` keeps its own inline cache, as
before.

This gets real check only after merge: `build-release.yaml` on next push
to a line, `tags.yaml` on next rc. Both run from line's own copy, so
lines need ports, I'll open them after this one.

Tests: bats for the cache macro (lists every import, writes only
`CACHE_TAG`, writes nothing without `WRITE_CACHE=1`), for
`hack/build-units.sh` against fake make (the `BUILD_JOBS` limit,
ordering, failing unit, failing `objectstorage-controller`, failing unit
list, output that shows while a unit still builds) and for the workflow
settings. I also ran `hack/build-units.sh` over the real units with
`make -n`.

### Downstream repositories

- [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
perf(ci): release lines build images from their own build cache, several units at a time, so rc builds no longer rebuild most images from scratch once main's Dockerfiles move on
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Build Improvements**
* Release builds now compile eligible components in parallel, while
retaining the required order for dependent components. Build parallelism
can be configured.
* Release-line builds use line-specific caches alongside shared caches.
Release-candidate builds reuse available caches, with arm64 builds
writing to an architecture-specific cache. Cache-write errors no longer
interrupt builds.
* **Documentation**
* Build guidance now covers parallel build settings, cache behavior, and
release build steps.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
v1.8.0-rc.1
2026-12-01 06:32:29 +03:00
Andrei Kvapil 684ef5464d feat(linstor): migrate an existing LINSTOR cluster to blockstor (#5466)
Stacked on #2942, and based on its branch, so the diff shows only the
migration.

<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list; pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

#2942 adds blockstor as a backend for new clusters. This PR adds the way
to move a cluster that already holds LINSTOR volumes onto it, following
blockstor's `linstor-migrate` runbook: freeze CSI and stop LINSTOR,
deploy blockstor, apply the converted manifests, wait for adoption, and
repoint CSI last. Setting `storage.backend: blockstor` alone does all of
that in one step: piraeus-operator goes external, deletes
linstor-controller and repoints linstor-csi before a single volume is
adopted.

- `storage.blockstorMigration` on the platform, passed to the linstor
chart, splits the switch into the runbook's steps. With `hold` blockstor
is deployed with its controller held at zero replicas while the
converted manifests are applied. With `adopt` the controller runs and
adopts the volumes. In both steps every piraeus object renders exactly
as under `backend: linstor`, so an operator started again still finds
LINSTOR's shape. Removing the value moves `LinstorCluster` to external
mode with piraeus-operator running. The platform checks the value, so a
typo or a step left over after switching back to linstor fails the
platform render rather than the linstor release.
- linstor-scheduler and linstor-gui stay on LINSTOR through `hold` and
`adopt` and move to blockstor-apiserver in the same step as linstor-csi.
Before that blockstor serves nothing, or Resources it has not adopted
yet, and the scheduler extender panics on a Resource without volumes.
- piraeus-operator keeps running through the migration, as in
blockstor's runbook. Given LINSTOR's shape during `hold` and `adopt` it
has nothing to change, it does not own the replica counts the freeze
sets to zero (the `LinstorCluster` sets none), and its webhooks keep
serving, so the release passes them. Earlier revisions stopped it and
relaxed its webhooks from hook Jobs; those are gone.
- The post-install/upgrade hook from #2942 that points
`ControllerConfig/default` at the passphrase Secret now merge-patches
that one field, and creates the object only when it is missing. It used
a server-side `kubectl apply`, and on an object last written by a
client-side `kubectl apply` kubectl first hands every client-side-owned
field to the applying manager and re-sends the apply, which then removed
the migrated cluster-wide DRBD options (timeouts, `verify-alg`,
`on-no-data-accessible` and the rest) that the satellites apply live.
The README applies the converted manifests server-side as well, so a
server-side apply run by hand later cannot take them over either.
- `packages/system/linstor/README.md` marks the migration experimental
and gives the order step by step, with the way back from every step and
the two steps after which there is none (repointing CSI and unfreezing
it), the replica count piraeus-operator does not restore, how to check
the master key ID while the controller is held at zero, and that no step
is run together with a platform upgrade. The values files and the
backend-switch guard now point at that path instead of saying the
platform does not move such a cluster.

### Testing

A live run on blockstor v0.4.0 with the operator kept running, on the
revision before the last README-only change: a three-node cluster with
LINSTOR volumes (3 and 2 replicas with a tiebreaker, local, LUKS, a
detached volume and a CSI snapshot) taken through every README step with
nothing done by hand beyond them:

- adoption without a resync, and `drbdsetup show` on every node
identical to the capture before the freeze, the cluster-wide DRBD
options included;
- data intact in place and after moving volumes to other nodes through
blockstor's CSI, restore from the pre-migration snapshot, new PVCs,
online resize of adopted volumes;
- linstor-scheduler and linstor-gui on blockstor-apiserver after the
last step without a manual reconcile, after one failed render each;
- piraeus webhooks left at `Fail` and untouched throughout;
- the way back from `hold` and from `adopt` (on two nodes): DRBD
unchanged, no resync, data intact, LINSTOR serving again. That run found
the restarted linstor-controller locked; the README now says to enter
the passphrase.

Earlier runs on alpha builds covered the node-by-node satellite rollout
with `OnDelete`.

Unit tests:

- `make test` in `packages/system/linstor`: helm-unittest 145/145 in 21
suites, Python 26/26. `test_controllerconfig_hook.py` runs the
ControllerConfig script against a client-side-applied object carrying
DRBD options.
- `helm unittest` in `packages/core/platform`: 403/403.
- The new cases fail when a migration step changes a piraeus object,
when the consumer switch follows the backend alone, and when the
ControllerConfig hook goes back to a server-side apply.

### Not tested

- The way back from steps 3 and 4 followed by a second migration
attempt; the README's guidance for leftover blockstor objects is from
the code, not from a run.
- The migration in CI: no lane runs DRBD, so none can start from
populated LINSTOR state.

### Known limitations

- A Cozystack upgrade during the migration can bring a new
piraeus-operator or linstor-csi, which the running operator rolls out
mid-migration. The README says to run each step as its own change.
- There is no way back once `blockstorMigration` is removed.
- `linstor-csi-controller`'s replica count comes back only by hand, on
the way forward and on the way back.

### Screenshots

N/A, no UI change.

### 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.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/667 carries the
LINSTOR to Blockstor migration guide; it has to follow the order in this
PR's README and `storage.blockstorMigration` before it merges.
- [ ]
[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:

The new `storage.blockstorMigration` key in
`packages/core/platform/values.yaml` belongs in website#667 with the
rest of the backend docs. Nothing else on the trigger map is touched.

### Release note

```release-note
feat(linstor): A cluster with LINSTOR volumes can be moved to the Blockstor backend in place with `storage.blockstorMigration` (`hold`, then `adopt`, then removed) on the platform, following the order in the linstor package README. Experimental.
```





<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Added a staged process for migrating existing LINSTOR volumes to
BlockStor, with `hold` and `adopt` stages before completing the switch.
* During migration, the BlockStor controller remains stopped during
`hold` and runs during `adopt`; existing LINSTOR resources are
preserved.
* **Documentation**
* Added migration guidance, including rollback paths and operational
constraints.
* Documented optional graceful shutdown settings for Talos satellites
and their prerequisites and limitations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 18:15:22 -05:00
Myasnikov Daniil 09f6fb5757 perf(ci): build release lines from their own cache, in parallel
Release-line image builds read only main's build cache. Once main moved
its builder and base images, release-1.7's Dockerfiles stopped matching
that cache, and the rc Build step went from 19 to 53 minutes on amd64
and from 10 to 46 on arm64 between v1.7.1-rc.2 and v1.7.2-rc.2.

Each line now keeps a cache of its own. build-release.yaml writes
buildcache-release-X.Y on every push to the line, and rc builds import
it together with main's buildcache. The arm64 rc build, the only arm64
build a line has, keeps buildcache-arm64-release-X.Y itself.
CACHE_FROM_TAGS lists every cache a build imports; unset, it is
CACHE_TAG, as before.

The units of hack/build-matrix.sh now build four at a time (make build-
parallel, hack/build-units.sh), since they spend most of their time on
registry round trips, one image after another. Every output line carries
its unit and is written as it comes, so a job that times out still shows
where it stopped. objectstorage-controller waits for the rest because it
writes seaweedfs' values.yaml. The rc jobs also leave their buildx
builder to the throwaway runner: removing it took up to 11 minutes on
arm64.

A cache write that fails no longer fails the build (ignore-error=true on
every --cache-to): OCIR refuses a blob upload now and then, which
already failed the arm64 nightly twice in its last thirty runs, and rc
and line builds now write a cache too.

Tested with bats: the cache macro, the unit builder against a fake make
(the BUILD_JOBS limit, ordering, a failing unit, a failing
objectstorage-controller, a unit list that cannot be generated, and
output that shows while a unit still builds) and the workflow settings,
plus a dry run of hack/build-units.sh over the real units with make -n.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-12-01 02:10:21 +03:00
Aleksei Sviridkin a4ddf5422e docs(release): add changelog for v1.7.3 (#5498)
This PR adds the changelog for release `v1.7.3`.

✅ Changelog has been automatically generated in
`docs/changelogs/v1.7.3.md`.
2026-12-01 01:54:17 +03:00
Timofei Larkin fa9b8f07a2 feat(postgres)!: mint tenant passwords through the credentials API (#4922)
## What this PR does

Postgres passwords are no longer readable from `<release>-credentials`,
which every `use` member and every parent tenant can read today, and
`users.<name>.password` is ignored. An administrator mints a password on
the user's `Credential` and sees it once. The account Secret stores only
the SCRAM verifier, CloudNativePG applies it, and the next mint or a
revoke kills the previous password. This is the Postgres part of the
user secrets API design (cozystack/community#137) on top of #4921.

- The chart renders one `scram-sha-256` CredentialTemplate per user and
points each managed role at its account Secret.
- The CloudNativePG bootstrap secret of the `app` owner is now that
user's account Secret, so the chart no longer generates a password into
`<release>-app-owner`.
- `users.<name>.createRole: true` is refused at render. A CREATEROLE
user becomes a member of each role it creates, CloudNativePG revokes
every membership a managed role does not declare, and that revoke fails
on the dependent grant, so the role gets stuck in `cannotReconcile`.
CloudNativePG has no per-role switch to leave memberships alone.
- `credentials-migrate` and migration 64 convert existing releases. The
pre-upgrade hook applies the CredentialTemplate CRD, writes each account
Secret from the current password as a verifier, and marks the release
for seeding only when every account got one. The finish Job runs under
its own `cozystack-credentials-migration-64` identity and removes
`<release>-credentials` once the controller adopted the accounts. A
transient API error is retried before a release is recorded as left out.

Live results, on a three-node test cluster upgraded from 1.7.1, with a
client logging in every second:

- Upgrade: the migration wrote the verifiers, the controller adopted
them, the finish Job removed the old Secret, and the client logged in
1014 times with no failure. A later run that upgraded all converted
engines at once (migrations 64-71) also had no Postgres failure, for
`web` and for the database owner `app`.
- A mint returns a password that logs in over TCP; the next mint and a
revoke each kill the previous password within 2 s. A stale precondition
gets 409 with no password, and a tenant viewer can't mint.
- Removing a user removes its template, Secret and role. `createRole:
true` fails at render.
- After a mint on `app`, the password survived a primary failover and
two restarts: CloudNativePG did not reset it from the bootstrap Secret.

Breaking for users: passwords can't be read any more, so clients switch
to a minted one after the upgrade. A release with `users.*.createRole:
true` is left out of the conversion: it keeps its previous chart
version, raises `CredentialsMigrationIncomplete`, and fails every
upgrade until the flag is set to `false`.

The red `E2E (in-tree)` comes from `mariadb-2-backup-roundtrip`, where
SeaweedFS rejected a freshly granted BucketAccess key before any
Postgres code ran; the three postgres tests pass.

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: needed, a Postgres note for the credentials API docs
(cozystack/website#753) and an upgrade note that clients must mint and
`createRole` must be off
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: needed, `cozystack_postgres` still sends
`users.<name>.password`
- [ ]
[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
feat(postgres)!: Postgres passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. Existing passwords keep working through the upgrade: migration 64 converts every Postgres release and then removes the old Secret. `users.<name>.createRole: true` is no longer supported: a release that sets it is not converted, raises `CredentialsMigrationIncomplete` and fails its upgrades until the flag is set to `false`. Switch clients to minted passwords after the upgrade.
```
2026-12-01 00:44:53 +03:00
Aleksei Sviridkin 48d91c2413 feat(release): sign the release images and attach their SBOMs (#5042)
## What this PR does

Follow-up to #4997 (merged as d32092ac9), which puts the SBOM into each
release image's index. Rebased onto `main` at that merge, one commit
`57346c16d`; bats on the touched files 36/36, shellcheck clean. This is
the follow-up agreed there, and the image half of #4759: the release
images get signed, and their SBOMs become a release asset, along the
lines of #4861.

Refs #4759, #2937, #3278

`hack/sign-release-images.sh` runs in `tags.yaml::prepare-release` after
the stitch, before `make upload_assets`. It enumerates every first-party
`<repo>@<digest>` the repinned tree holds the way
`hack/stitch-multiarch.sh` does (the shared enumeration, refs under the
registry, `cozystack-packages` left out), skips each one that already
verifies, signs the rest with the job's OIDC identity, one `cosign sign
--yes` call per ref so that cosign's per-call `--timeout` (3 minutes by
default) does not have to cover every ref's key, Fulcio certificate,
Rekor entry and registry round trips, and verifies every one against the
identity regexp of `hack/sign-release-assets.sh` before returning; the
two scripts' regexps are held equal by bats. A signature that does not
verify fails the job with nothing uploaded. A signature over an index
covers every manifest the index lists by digest, the attestation
manifest with the SBOM included, so the SBOM has no signature of its
own. cosign v3.1.3 writes the signature as a Sigstore bundle, an OCI
referrer of the digest in the same repository (`--new-bundle-format`
defaults to true). GHCR answers `/v2/<name>/referrers/<digest>` with
404, so go-containerregistry lists the referrer under the fallback tag
`sha256-<hex>`, without `.sig`, which `cosign verify` reads the same
way; the `.sig` tag exists only with `--new-bundle-format=false`.
`hack/promote-retag.sh` copies a digest to its stable tag inside that
repository, so the stable release's images carry the rc's signatures.
`promote-rc.yaml::promote` runs the rc tree's script with
`--verify-only` before it stages the stable release, and prints a notice
instead for an rc cut from a tree without the script. Under
`--verify-only` cosign's stderr is kept, so a registry 429 or a Rekor
fetch error is not reported as a missing signature;
`docs/release/ci-failures.md` has a row for that step.

`hack/collect-image-sboms.sh` reads `docker buildx imagetools inspect
<ref> --format '{{ json .SBOM }}'` for the same refs, takes the
platforms the index serves from `--raw` (entries that are not
attestation manifests, keyed as buildx keys them), and writes
`<image>.<os>-<arch>.spdx.json` per platform (or `<image>.spdx.json` for
an image with one platform, whose SBOM buildx prints unkeyed) into
`cozystack-images-sbom.tar.gz`, with fixed order, times and owners so a
re-run gives the same bytes. An image without a non-null SBOM for every
platform its index serves fails the run, naming it and the platforms:
after #4997 every pinned first-party image is built with `SBOM=1`, so a
missing one is a lost attestation, and I preferred no allowlist over one
with no entry (the Talos installer image, which has no SBOM, is not
pinned in the tree).

`hack/upload-assets.sh` adds `cozystack-images.txt` (the refs, one per
line, from `--list`) and the archive to the list it hands to
`hack/sign-release-assets.sh`, so the existing checksums signature
covers both and nothing new signs anything. `promote-rc.yaml` downloads
every rc asset, so both travel to the stable release as the other assets
do. `docs/release/signatures-and-sbom.md` describes the two files and
the image signatures, drops #4997's "The attestations are not signed",
and gains a "How to verify a release" block that checks the checksums,
every asset, every image signature and unpacks the SBOMs in one go, the
image loop in a subshell that exits on the first image that fails;
`docs/agents/image-refs.md` lists the two new consumers of the
enumeration; the SBOM row and the "Signed / reproducible builds" gap of
`docs/security/self-assessment.md` now say what a release publishes and
signs.

### How it was checked

- Bats 1.14.0: `hack/sign-release-images.bats` (13 tests: the refs it
signs and skips, one `cosign sign` call per ref, the identity and issuer
it verifies, equality with the assets regexp and with
`docs/release/signatures-and-sbom.md`, the fenced verify block of
`docs/release/signatures-and-sbom.md` run with cosign stubbed, which
fails on a rejected first image, on a list read from stdin, on a
checksums file that lacks either image asset and on one that lists one
asset twice in place of the other, a failed verify, `--verify-only`,
`--list`, an empty tree, and the shape of both workflow steps by `yq`)
and `hack/collect-image-sboms.bats` (5: file names and content per
platform, member order, owners and times read from the archive headers,
the same bytes twice, an image without an SBOM, an index with an SBOM on
one platform only, a platform with `"SPDX": null`, an empty tree;
dropping `--sort=name`, the owner flags or `--mtime` fails it on XFS and
ZFS), both with cosign and docker stubbed; `hack/upload-assets.bats`
updated for the two assets; `hack/sign-release-assets.bats` and
`hack/ci-tool-installs-contract.bats` unchanged and green. The
repository's bats contract suites (strict setup, no negated asserts, no
exit traps, runner coverage) pass with the two new files. `make
bats-unit-tests`: see the last comment of this PR for the count.
- `shellcheck -x` on both scripts; `zizmor` on `tags.yaml` and
`promote-rc.yaml` reports nothing.
- Checked against the registry, not the code: GHCR has no referrers API
for a cozystack image (404), so the referrer lands in the `sha256-<hex>`
fallback tag; `hack/promote-retag.sh` copies within the repository; `gh
release download` in promote takes every rc asset.
- Not checked: a real keyless run (the first alpha after the merge, like
#4861 and #4997), a stitched index against a live registry (the `.SBOM`
shape follows buildx v0.31.0 `util/imagetools/printers.go`: keyed by
platform for more than one platform, bare otherwise; @lexfrei's ttl.sh
run on #4997 saw the map), and the time the signing adds to
`prepare-release`.

### Decisions for the release owners

- The packages artifact (`cozystack-packages`) and the installer chart
are not signed: promotion republishes both under a new digest, so
signing them means a signing step in `promote` too. Follow-up if wanted.
- Every pre-release signs about forty indexes, each with its own Fulcio
certificate and Rekor entry. #4861 already writes one per release, so
the policy question is settled; the volume is new.
- An image without an SBOM fails the release rather than being listed as
missing. If an exception appears, an allowlist with a reason, as
`hack/multiarch-allowlist`, is the shape to add.
- The identity regexp accepts `promote-rc.yaml` on `main` as well as
`tags.yaml` on a `v*` tag, though only `tags.yaml` signs images today,
so that `docs/release/signatures-and-sbom.md` has one expression for
every release signature. A reader who wants the tighter check drops the
alternative.

### Screenshots

<!-- REQUIRED for UI changes: attach screenshots or screen recordings
demonstrating
the visual impact of your changes. PRs with UI changes without
screenshots will not be merged. -->

### Downstream repositories

- [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:

I walked the trigger map against the diff. `hack/upload-assets.sh` adds
two assets and renames none, so the install pages that hardcode asset
filenames on the website are untouched. `tags.yaml` gains a step between
the stitch and the upload and `promote-rc.yaml` a check before the
upload; who cuts and who promotes a release, which the ccp guidance
rests on, is the same. `hack/package.mk` and `hack/common-envs.mk` are
not touched.

### Release note

```release-note
feat(release): every first-party container image of a release is signed with cosign, keylessly, by the `tags.yaml` run that prepared it, and a release carries `cozystack-images.txt` (the pinned images by digest) and `cozystack-images-sbom.tar.gz` (the SPDX SBOM of each image, per platform) as assets covered by the signed checksums. `docs/release/signatures-and-sbom.md` shows how to verify a release end to end. Releases cut from this change on have them.
```



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* Releases now include a list of pinned first-party image digests and an
archive of image software bills of materials (SBOMs), with coverage for
each image platform.
* Release image digests are signed, and release checksums cover the
image list and SBOM archive.
* RC promotion checks image signatures before creating a stable release;
unsigned images can block promotion.
* **Documentation**
* Added guidance on release image signatures, SBOM assets, verification,
and related release failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 21:41:44 +03:00
Timofei LarkinandIvanHunters 8a31d2b09f test(postgres): check that a minted password is shown only once
The e2e test mints a password, logs in with it, and checks every place
it could be read again: the account Secret must hold a SCRAM verifier,
decoded rather than matched in the raw base64; neither the application,
any Helm revision nor what the tenant's super-admins read through
tenantsecrets may carry it; and they cannot read the account Secret.
Each read is captured in an assignment, which stops the script on
failure, so a failed kubectl, base64 or gunzip cannot leave a check with
nothing to assert on, and at least one Helm release Secret is required.
The step runs under bash and passes the password to psql on stdin, never
as an exec argument.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
d7144cda9e feat(platform): migrate Postgres accounts to minted credentials
Migration 64 converts the existing Postgres releases. It first applies
the CredentialTemplate CRD baked into its image, owned by the
cozystack-controller release so that release's upgrade adopts it: on a
live upgrade the tenant releases switched to the converted chart about
17 minutes before cozystack-controller upgraded, and every render in
between failed on the unknown kind. It then runs credentials-migrate
seed, which writes the account Secrets from <release>-credentials so
clients keep logging in at every point of the upgrade. A release that
grants createRole is left out and keeps its previous chart.

The finish half runs from a Job the migration creates, not from the
platform chart: a chart-rendered Job has a fixed name and an image that
changes every release, so the next platform upgrade cannot patch its
immutable pod template, and helm-controller would wait on a Job that
runs up to 30 minutes and exits non-zero while any release is left out.
The Job runs the image the hook runs as, read from its own pod, under a
least-privilege ClusterRole rather than cluster-admin, and its
ServiceAccount is owned by the Job so the garbage collector removes it.
The identity carries the migration number like the Job, so a later
conversion migration cannot delete the ServiceAccount a still-running
earlier Job uses.

The CredentialsMigrationIncomplete alert keys on the incomplete label of
the state ConfigMap through kube-state-metrics, which allowlists only
that one ConfigMap label, so a release whose plaintext was never retired
stays visible after the Job's TTL. The bats suite pins the CRD apply,
seed, image read, Job apply, ownership and stamp steps as fail-closed;
its fake kubectl counts the Job's name inside the Job document only.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
Timofei LarkinandAndrei Kvapil c9653cbb79 build(platform): build credentials-migrate into the migrations image
The conversion migrations run credentials-migrate, which shares the
password format functions with the API so a converted release and a mint
store the same form, so the migrations image now builds it from this
repository and its build context is the repository root. The image also
carries the CredentialTemplate CRD for the migrations to apply. The
builder pins the Go version go.mod requires.

Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
Timofei LarkinandIvanHunters f982ea2cb9 fix(examples): mint the Postgres password in the backup examples
The examples read the application password from <release>-credentials,
which the chart no longer renders. They now mint it and pass it to psql
on stdin rather than as a kubectl exec argument, which travels in the
request URI the audit log records at any level. The minted password is
cached in a per-run mktemp -d directory, private and fresh each run, so
a later run never reads a password a mint has since replaced and no
other host user can read it. The helper's tests stub the mint.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
a67fa94fdb feat(postgres)!: issue user passwords through the credentials API
The chart generated every user's password at render time into
<release>-credentials, which tenants could read again at any time and
which Helm history kept for MaxHistory revisions, so a deployment whose
policy requires a credential shown once could not run PostgreSQL here.

The chart now renders a CredentialTemplate per user, and the users move
under CloudNativePG's managed roles, each pointing at its account
Secret, so the operator creates the role with the SCRAM verifier the
Secret holds, applies a changed Secret live, and reverts a password set
inside PostgreSQL. Every role is rendered as the init-script created it,
because the operator reverts an attribute that differs, revokes a parent
role missing from inRoles and clears a comment the spec leaves unset.
The init-script stops creating, passwording and altering accounts, where
it would be a second writer, and keeps the two things the operator has
no field for: the marker membership and the reset of the
createrole_self_grant an earlier chart set. Its marking pass waits a
bounded time for CloudNativePG to create the declared roles before it
marks them. users.app adopts the owner CloudNativePG bootstraps, whose
password the instance manager applies again from the bootstrap secret
on every pod start, so that secret is the app user's account Secret
and both writers apply the one stored verifier. A users.<name>.password
left in values draws an admission warning that points at a mint on the
user's Credential.

createRole is refused on every render path. A role a CREATEROLE user
creates makes that user a member of it, CloudNativePG revokes every
membership a managed role is not declared to hold, and the revoke fails
on the dependent self-grant, so the user would sit in cannotReconcile on
ordinary use; there is no per-role switch to leave memberships alone.
The account-name checks render with the managed roles too, so a restore
cannot bypass them: a user CloudNativePG or PostgreSQL reserves, a
database whose derived <name>_admin or <name>_readonly role starts with
pg_ or cnpg_ (which makes the CloudNativePG webhook reject the whole
Cluster), and a user whose account name is no valid object name are
refused. The chart's account naming is pinned to the API's on one table
of names.

A pre-upgrade hook refuses to let CloudNativePG adopt a role the chart
did not mark, because the operator adopts a managed role within seconds
of the spec reaching it, before any post-upgrade job could look. It
reads the live Cluster first and connects to the database only when the
upgrade adds a name CloudNativePG does not manage yet, so a database
that is down does not block the resize that might fix it. For each
absent declared database role it creates and marks the role as the
superuser before the Cluster applies, so no tenant can plant it in the
adoption window. The refusal and the create run in one psql session,
keyed on a snapshot of the role's existence taken at the top, so a role
planted in between collides with the CREATE and stops the hook; the
statements are built with format() and \gexec, since psql does not
substitute :'role' inside a DO $$ block. Verified on postgres:18: a
fresh role is created NOINHERIT, commented and marked, a role planted
after the snapshot fails the hook, and an existing unmarked role is
refused. The hook reads the Cluster at run time with a ServiceAccount
that may get only that Cluster, rather than through a template lookup,
which nothing re-renders when the object changes. The flag an earlier
chart set when a user held createRole is still read and never set, so
such a release keeps refusing to adopt a role it did not mark.

The EndpointAttachment e2e suite read testuser's password from that
Secret to probe the attached addresses. It now mints one per probe and
waits until the application's own Service accepts it, so the attached
address is still queried exactly once.

BREAKING CHANGE: PostgreSQL passwords are no longer readable from
<release>-credentials. A password is issued once, by a mint on the
account's Credential in core.cozystack.io, and replaced by the next
mint. users.<name>.createRole is refused; a release that sets it keeps
its previous chart version and passwords until it is false. Deleting a
Postgres application whose release is suspended is refused. The
conversion needs a platform variant with migrations enabled.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:27 +01:00
780a358083 feat(credentials-migrate): convert accounts to minted credentials
A converted chart reads each account's stored value from an account
Secret the platform keeps, and nothing writes those Secrets for the
applications that exist before the chart switches. Without a conversion
every existing account would stop logging in at the switch.

The command has two halves. seed runs from the platform's pre-upgrade
hook, before any component chart changes version: it writes the account
Secrets unowned, with the stored form of the password the tenant could
read until now and origin Migrated, records each release's chart
version, and marks a release for seeding only when every account got its
Secret, so the CredentialTemplate controller never seeds a random
password over one the release's clients still use. It takes the kind's
format and accounts path from flags, because the hook runs before the
converted chart renders any template. finish runs from a Job once the
charts have switched: per release it waits for the converted chart to be
Ready, strips any password left in the values and deletes the old source
Secret.

seed fails closed. Only a release whose accounts cannot be resolved from
its values is left out; any other error fails the hook and the upgrade
retries, since a left-out release whose source Helm then deletes would
keep neither an account Secret nor the plaintext. finish holds a release
recorded without a chart version rather than retiring it as soon as it
renders, old chart included.

A transient API or connection error is retried on the same release a few
times. If it persists, the release is recorded for the incomplete alert
but announced with CredentialsMigrationRetrying, a Normal event, since
the Job's restart retries it; only an error no retry fixes records the
Warning CredentialsMigrationSkipped "left this release out", which reads
as a release that needs a person. While any release is left out, the
state ConfigMap carries credentials.cozystack.io/incomplete=true.

The stored form comes from the platform's own format package, so a
migrated release and a mint store the same value.

Co-authored-by: IvanHunters <xorokhotnikov@gmail.com>
Co-authored-by: Andrei Kvapil <kvapss@gmail.com>
Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:14 +01:00
IvanHunters b4f2f13ce3 feat(credentials): tell whether a legacy password survives login
PostgreSQL applies SASLprep to the presented password at login, and
ALTER ROLE ... PASSWORD did the same when it stored the old verifier, so
a SCRAM verifier built from the raw bytes of a legacy password silently
fails to authenticate any password SASLprep changes, such as one
carrying a soft hyphen. CarriesOver tells the conversion which passwords
it may keep, so the rest are left to their first mint.

pg_saslprep returns every all-ASCII input unchanged through its
pg_is_ascii fast path before the prohibited-character step runs, so an
all-ASCII password, ASCII controls included, carries over. Every format
other than scram-sha-256 stores or hashes the raw bytes and always
carries over.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-30 18:21:13 +01:00
Aleksei Sviridkin c8ffc87717 fix(postgres): run the collation repair outside the Helm hook (#5479)
## What this PR does

Refs #5459 (item 3: "Waiting for rollout eats Job budget").

**Depends on #5505.** Merge #5505 first or together with this PR. Here a
failed repair no longer fails the HelmRelease. #5505 makes the
WorkloadMonitor report the failed repair Job as `WorkloadsReady=False`
with reason `JobFailed`. Without it the failure shows only on the Job
itself.

Moving tenant PostgreSQL to another image (for example bullseye `17.7`
to `17.12-standard-trixie`) fails the first Helm upgrade of every
release whose clients keep sessions open. The collation repair at the
end of the post-upgrade init-job waits for CNPG to move the primary to
the new image. CNPG rolls the primary last, and every instance spends up
to `smartShutdownTimeout` (180 s) in smart shutdown, so the wait uses up
the init-job's 540 s deadline and the HelmRelease goes `UpgradeFailed`
until Flux retries. When the repair instead meets the primary restart,
psql fails with `FATAL: the database system is shutting down` and the
upgrade fails the same way.

The one commit moves the repair out of the hook. A short
post-install/post-upgrade hook, run after the init-job, creates a
`<release>-collation-repair` Job through the API (outside the release,
so helm-controller does not wait for it) and returns. That Job keeps the
OID mark / fingerprint resume and the in-place attempt records. It waits
for the new image whenever the image changes, not only when an index
already depends on a versioned collation: a plan built on the previous
primary would miss an index created meanwhile, which the release
recorded at the end would then claim as repaired. In the hook that wait
was too expensive to make unconditional. The Job gets an hour, is owned
by the Cluster, and its fixed name keeps two repairs from running at
once. It carries the WorkloadMonitor's selector labels plus the opt-in
`workloads.cozystack.io/report-failure: "true"` from #5505, and has no
`ttlSecondsAfterFinished`, so a failed repair stays until the next
upgrade replaces it (see the proposal in #5459). Both Jobs now rerun
their idempotent script on psql exit status 2 (connection refused or
dropped) with backoff instead of failing.

Decisions for reviewers:

- **Repair failures no longer fail the HelmRelease.** A repair that
cannot finish (for example duplicates under a UNIQUE index) shows up as
a Failed `<release>-collation-repair` Job and its log, kept until the
next upgrade starts a new run. The next upgrade retries it. Before, it
showed up as `UpgradeFailed`.
- **The repair also runs after install.** The install-time init-job used
to record which Debian release each database starts on. Without that
record, a cluster whose first upgrade moves the image would have its C.*
indexes rebuilt only if the repair reached the primary before it
restarted. On a fresh cluster the run only writes that record. The Job
sets `PGCONNECT_TIMEOUT=10`.
- **A failed rebuild no longer holds back the PostGIS update.** The
update runs after the collation pass whatever it found, and the Job
still fails at the end if a rebuild failed.
- **The e2e upgrades twice.** The second upgrade finds the first repair
Job complete on the same image, and the test waits for its replacement
to complete.
- **Lock waits are bounded by the Job's remaining hour, not about 8
minutes.** This is harmless for `REINDEX CONCURRENTLY`. For the in-place
rebuild of an exclusion-constraint index, writers to that table can
queue behind its lock wait for longer. Capping it separately means
touching the per-index code that the parallel PRs on #5459 also edit, so
I left it out.
- **The hook's Role** has `get`/`delete` on the repair Job and `get` on
the release's Cluster, both by `resourceNames`. It also has `create` on
jobs, which RBAC cannot narrow by name. The SA, Role and RoleBinding are
deleted once the hooks succeed.
- **Verified under Flux.** helm-controller v1.5.0 runs the post-upgrade
hooks about a second after it patches the Cluster, without waiting for
the rollout. The rollout therefore no longer counts against the release
timeout. Details in the PR thread.

Rebased onto main after #5477 and #5485. The PostGIS extension update
from #5477 waits for the same rollout, so it moves into `repair.sh`
after the collation pass; left in the init-job, it would bring the
hook-budget problem back for postgis clusters. Every message about a
repair or update that did not finish says that the next upgrade of the
release starts it again. The starter and the repair Job take their names
from one base, which stays distinct and within 63 characters for any
release name.

### Testing

- `helm unittest packages/apps/postgres`: 32 suites, 257 tests pass,
including a new `collation_repair_test.yaml`. It checks gating (upgrade
only, skipped while bootstrap is on), hook order after the init-job, the
Role rules, RBAC removal on success, name length, and the init-job
command.
- Docker, with the rendered `run.sh` + `repair.sh` against
`postgres:17-bullseye` and stale ICU / en_US collations:
- Killing the `REINDEX INDEX CONCURRENTLY` backend mid-rebuild made the
pass exit 2. `run.sh` reran it, the already rebuilt index was skipped by
the OID mark, and the other index was rebuilt. amcheck was clean and the
versions were refreshed.
- With the server stopped before the first connection, the script
retried with 5 s and 10 s pauses and finished once the server came back.
  - An SQL error exits 1 and is not retried.
- dev7 (cozystack v1.7.0): two 3-instance v17 releases installed from
v1.7.1 (bullseye `17.7`), with ICU and en_US UNIQUE indexes on 200k rows
and `pg_sleep(3600)` sessions held on `-rw` and `-ro`. Both were
upgraded with `helm upgrade --timeout 10m`:
- origin/main: the init-job waited for `PostgreSQL 17.12 pgdg13`, hit
`DeadlineExceeded`, and the command failed with `UPGRADE FAILED:
post-upgrade hooks failed: resource Job/tenant-root/rr-main-init-job not
ready. status: Failed` (exit 1 after 611 s).
- This branch: exit 0 after 70 s (init-job 9 s, starter 10 s, starter
RBAC removed afterwards). The repair Job waited out the rollout and
rebuilt `t_u` and `t_k`. Collation versions were refreshed to `2.41` /
`153.128`, `bt_index_check(..., true)` passed on all three instances,
and the resume mark was reset.
- A second upgrade replaced the finished repair Job, and the rerun found
nothing to do.
- The rebuild sat in `waiting for old snapshots` behind the test
client's open transaction. That is expected for `REINDEX CONCURRENTLY`;
I ended that session to finish the run.

### Downstream repositories

Walked against the diff (the new template, test and init-script/init-job
changes in `packages/apps/postgres`). The diff changes no values,
schema, `ApplicationDefinition`, Secret or Service names, package
layout, or tooling. The only new objects are a hook-scoped
ServiceAccount/Role/RoleBinding/Job and a Job created at runtime, which
no listed repository refers to.

- [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:

- Flux (dev cluster, helm-controller v1.5.0): a tenant app on the v1.7.0
chart (bullseye `17.7`, 3 instances, sessions held on `-rw`/`-ro`) was
upgraded by switching the platform's postgres chart.
- With this PR, the HelmRelease reached `UpgradeSucceeded` in 21 s, and
the repair Job finished after the rollout with `bt_index_check` clean on
all instances.
  - With main, the upgrade took 7 min 06 s of the 10-minute timeout.
- Docker: the rendered `repair.sh` for the postgis flavor moved PostGIS
3.6.1 → 3.7.0 after the collation pass. A tenant trigger on
`spatial_ref_sys` did not run.

### Release note

```release-note
[postgres] An image change of a tenant PostgreSQL no longer fails the Helm upgrade while CNPG rolls the instances. The collation repair now runs in a separate `<release>-collation-repair` Job, started after each upgrade, which waits for the new image and retries after connection drops. Check that Job's status and log to confirm the repair finished.
```
2026-11-30 18:24:14 +03:00
Aleksei Sviridkin 0c00c4545e ci(release): refuse a Promote RC dispatch from any ref but main (#5181)
## What this PR does

Adds a first step to the `parse` job of `promote-rc.yaml` that fails
when `github.ref` is not `refs/heads/main`, before anything is written.
This is A20 in #3278.

A `workflow_dispatch` runs the copy of the workflow at the dispatched
ref. On 2026-10-16 a dispatch from `release-1.6` ran that branch's older
copy (one job instead of five,
https://github.com/cozystack/cozystack/actions/runs/38882938797) and was
re-run from `main`. Since #4861 the release assets are signed, and the
same dispatch would now fail at the upload step, after the staging
branch, the `promotion-*` candidate and the draft release already exist.
`docs/release.md` also pins the signature identity to this workflow on
`main`, so a dispatch from another ref should stop at the front door.

The step follows the shape of `Validate dispatch branch` in
`cut-prerelease.yaml`: one shell comparison, an `::error::` that names
`main`, `exit 1`.

## Test

`hack/promote-rc-dispatch-ref_test.bats` extracts the step's `run` with
`yq` and executes it under `dash` for `refs/heads/main` (passes), a
release branch, a tag and an empty ref (each fails and names `main`),
and pins the step to be `parse`'s first step reading `github.ref`. It
runs with the rest of `hack/*_test.bats` via `make bats-unit-tests`.
`zizmor` on the workflow reports no findings.

## Docs

One clause in step 3 of the regular release sequence in
`docs/release.md`. #5169 edits the same file further down and the
`promote` job of the same workflow; the hunks do not overlap.

## Checklist

- [x] Commit is signed off with `--signoff`
- [x] Commit carries exactly one `Assisted-by: LLM` trailer
- [x] `hack/check-commit-trailers.sh upstream/main..HEAD` passes
- [x] `bats hack/promote-rc-dispatch-ref_test.bats` and `bats
hack/bats-strict-setup.bats` pass

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Workflow Updates**
* Release candidate promotions dispatched from branches or tags other
than `main` are rejected. Older workflow copies on release branches may
still create a staging branch and draft release before stopping.
* **Documentation**
* Release instructions clarify that promotions must be dispatched from
`main`, regardless of the release line, and note the behavior of older
workflow copies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-30 18:18:50 +03:00
Marian Koreniuk b08b4949eb feat(release): sign the release images and attach their SBOMs
A release has signed its assets since #4861, but not the container
images a cluster installed from it pulls, and the SBOM each image carries
since #4997 sat in the registry only, readable with buildx and signed by
nothing. A user could verify the ISO they booted and not the platform it
installed.

hack/sign-release-images.sh signs every first-party digest the repinned
tree holds with cosign, keylessly, in prepare-release after the stitch,
one cosign call per digest so that cosign's per-call timeout does not
grow with the number of images. It skips a digest that already
verifies, so a re-run stacks no second signature, and verifies each one
against the identity docs/release/signatures-and-sbom.md names before
hack/upload-assets.sh runs, so nothing is uploaded over an unsigned
image. The draft release is created only after that step, so a failed
signing run leaves no draft for a re-run to take for a finished
release. The signature over an index covers the attestation manifest
the index lists, so the SBOM needs none of its own, and cosign stores it
as a referrer of the digest in the repository hack/promote-retag.sh
copies the digest within, so promote-rc.yaml only verifies, with the rc
tree's script, before it stages the stable release, and prints cosign's
reason for every digest that fails.

hack/collect-image-sboms.sh reads the SBOM attestation of every such
image back into cozystack-images-sbom.tar.gz, one SPDX document per
platform, and fails on an image that lacks one for any platform its
index serves. With cozystack-images.txt, the digests the signatures are
bound to, both join the asset list hack/upload-assets.sh hands to
hack/sign-release-assets.sh, so the existing checksums signature covers
them. docs/release/signatures-and-sbom.md gains the verification recipe
for a whole release, which requires a signed checksum entry for each of
the two image assets; cozystack-scheduler, whose image a separate
repository builds, is not in the list. The bats files pin the scripts,
the recipe, the upload list and the two workflow steps.

Refs #2937, #3278

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
2026-11-30 15:22:01 +01:00
Aleksei Sviridkin a768c81b49 feat(linstor): add Blockstor as a selectable storage backend (#2942)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
- Scopes are not an exhaustive list; pick the most specific scope for
the change and extend the list when a genuinely new area appears.
Examples:
- System components: dashboard, platform, operator, cilium, kube-ovn,
linstor, fluxcd, cluster-api
- Managed apps: postgres, mariadb, redis, kafka, clickhouse,
virtual-machine, kubernetes
- Development and maintenance: api, hack, tests, ci, docs, maintenance
- Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or
add a `BREAKING CHANGE:` footer
- If it's a work in progress, consider creating this PR as a draft.
- Don't hesistate to ask for opinion and review in the community chats,
even if it's still a draft.
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

Adds Blockstor as a second control plane the `linstor` package can
deploy, chosen at install time with `storage.backend` on the platform.
LINSTOR stays the default, and a cluster that does not select blockstor
renders exactly what it renders on `main`. Blockstor serves the LINSTOR
REST API, so linstor-csi, piraeus-operator and the StorageClasses are
the same for both.

This PR is for new clusters only. Moving a cluster that already holds
LINSTOR volumes to blockstor (the `storage.blockstorMigration` steps,
the hook Jobs that relax piraeus's webhooks while the operator is
stopped, and the README order) is split out into #5466, stacked on this
one.

Blockstor is experimental. The package pins blockstor 0.4.0, all three
images by digest, and the chart refuses to render if the controller,
apiserver and satellite tags name different releases. 0.4.0 advertises
REST API 1.29, which the linstor-csi v1.13 on `main` requires. A LUKS
volume formatted by blockstor 0.2.x is neither opened nor re-formatted
by 0.3.0 and later, since 0.3.0 wraps a per-volume password under a
master key. This only matters for clusters that ran an earlier revision
of this branch; nothing on `main` ever shipped blockstor.

Default path:

- `helm template packages/system/linstor` is byte-identical to `main`
(defaults, `talos.enabled=false`, `drbd.enabled=false`, explicit
`backend=linstor`).
- The platform renders the `cozystack.linstor` Package without
components, as on `main`, so an upgrade rolls no new revision of the
release.

Selecting the backend: `storage.backend` falls back to `linstor` only
when the key is absent. Any other present value fails the render, `""`,
`false` and `0` included. `null` is the one case the chart can't see,
Helm drops a null key before rendering. The `linstor` chart checks the
value on its own too. Changing the backend of a running cluster fails
the render, the same way the networking variant guard works: the
platform looks up the live `cozystack.linstor` Package, and
`storage.acknowledgeBackendChange: <target>` confirms the switch on a
cluster that has no volumes yet.

Under blockstor the package renders blockstor's controller, apiserver
and satellite, plus its CRDs with `helm.sh/resource-policy: keep`, since
those objects are the whole blockstor database. piraeus-operator runs in
external mode against the apiserver's mTLS port and uses a client cert
from the same CA for its own version probe (#4016). linstor-scheduler
and linstor-gui are told only the backend by the platform and read the
endpoint and client Secret from that same `LinstorCluster`
(`spec.externalController.url`, `spec.apiTLS.clientSecretName`), the
object that points linstor-csi there, so the names of blockstor's
Service and Secret live only in the linstor package and nothing renders
objects under piraeus's names. Under linstor they get no values and keep
their defaults; the scheduler chart takes this through one more vendored
patch. Under blockstor a `LinstorCluster` that names no external
controller yet fails their render instead of falling back to
linstor-controller: on a backend switch they can upgrade before the
linstor release has rewritten that object, and the fallback left them on
a Service the operator then deletes, with nothing to render them again.
The platform's HelmReleases retry a failed render every retry interval
without counting it as a failure, so they follow once the linstor
release is through.

Every blockstor component finds the Secret that opens its master key
through `ControllerConfig/default`. A post-install/post-upgrade hook Job
server-side applies `spec.passphraseSecretRef` there, pointing at
piraeus's `linstor-passphrase` (key `MASTER_PASSPHRASE`, the name is the
`blockstorPassphraseSecret` value), and leaves the rest of the object to
blockstor. It is a Job and not a release object because the CRD comes
with the same release. The controller opens nothing and creates no
keyring until the reference is there, so starting before the Job is
harmless. Because the passphrase Secret is always named, `linstor
encryption create-passphrase` is refused under this chart: the operator
creates `linstor-passphrase` by hand before the first encrypted volume.

piraeus still runs a `linstor-satellite` pod on every node it picks for
`linstor-csi-node`, and `LinstorCluster` has no setting that stops one
without the other. So cozystack's satellite configuration, its internal
CA and the satellite scrape stay under both backends: the pod is pinned
to our image, with TLS, limits and host networking, and the address the
operator registers a node with is the node's own. The plunger and the
opt-in Talos graceful-shutdown hook stay LINSTOR-only (the hook is
refused under blockstor), because they act on DRBD resources that under
blockstor belong to blockstor-satellite. blockstor-satellite runs the
plunger's DRBD workarounds itself, and the chart lets it act on a
stalled resync (LINBIT/drbd#149) instead of only reporting it:
`blockstorSatellite.stalledResyncAct`, on by default.

There is one `LinstorCluster` document for both backends, only the keys
that differ are gated, so the CSI part (strict topology and main's
group-snapshot gate included) can't drift.

RBAC and exposure:

- `cozy-linstor` is shared with piraeus, so no blockstor component can
read an arbitrary Secret there. Each has a namespaced Role naming only
`blockstor-master-key`, `blockstor-unlock` and the passphrase Secret:
the satellite gets `get`, the controller and the apiserver get `get` and
`update`, plus `create`, which RBAC cannot limit by name. The named
rules also allow `list` and `watch`, which newer blockstor releases use
with a `metadata.name` field selector;
- because that `create` is unnamed, a ValidatingAdmissionPolicy admits a
Secret create by a blockstor ServiceAccount in the release namespace
only for the keyring and the generated `blockstor-unlock` Secret, with
the types blockstor gives them;
- no component has cluster-wide Secret access;
- the apiserver's plain HTTP listener is bound to `127.0.0.1`,
port-forward still works;
- the controller has no leader election, so its Deployment uses
`Recreate`, and neither it nor the satellite gets leases;
- the satellite deletes nothing but the PhysicalDevices it discovers,
and the roles name every blockstor kind they grant;
- the satellite's host ports (3372, 9101, 8080) are closed to the world,
same as drbd-reactor's;
- the controller and the apiserver get 21s to stop, so a SIGTERM does
not cut a detached rollback short.

The snapshot stream between satellites runs on port 3372 over mutual
TLS, with a CA of its own from `ca-bootstrapper`, kept apart from the
API CA.

The `blockstor-satellite` DaemonSet rolls one node at a time and holds
each node for `blockstorSatellite.minReadySeconds` (180 by default)
after Ready, because the satellite is Ready seconds after start while
its first pass over the node's DRBD resources ended 1.5 to 2.7 minutes
later on a test cluster with about 110 resources per node.
`maxUnavailable` is fixed at 1 and `maxSurge` at 0, and `OnDelete` is
there for an upgrade checked node by node; the README describes that
procedure. The trade-off to review: the HelmRelease waits for the whole
rollout, about 3.5 minutes per node at the default, so on more than two
or three nodes the first upgrade attempt times out and the retry
finishes it, and `HelmReleaseNotReady` fires meanwhile.

None of the three components sets a CPU limit, as the LINSTOR controller
and satellite don't: under a 500m limit every reconcile pass got
throttled and each volume create took tens of seconds. Memory stays
limited.

The e2e scripts prepare and check whatever `COZY_STORAGE_BACKEND` says,
and refuse an unset or unknown value. Under blockstor the prep waits
until every satellite reports its pool before applying StorageClasses.

`make update-blockstor-crds` refreshes `definitions/` from the blockstor
tag the images are pinned to. For 0.4.0 it reproduces the release's CRDs
byte for byte. Every `DrbdOptions/*` key the chart sets on the
controller and the e2e StorageClasses set passes the whitelist 0.4.0
enforces.

### Testing

- `make test` in `packages/system/linstor`: helm-unittest 133/133 in 20
suites, Python 20/20.
- `helm unittest` in `packages/core/platform`: 394/394;
`packages/system/linstor-scheduler`: 31/31;
`packages/system/linstor-gui`: 28/28.
- `bats`: `hack/linstor-storage-mode_test.bats` 33/33,
`hack/post-install-prep.bats` 25/25, `hack/platform-packages_test.bats`
16/16.
- Every guard was checked by reverting it and watching its test fail:
empty backend, shared strict topology, loopback bind, `Recreate`, the
satellite role, the pool report wait, the pool guard retrying a read
that exits 2, the graceful-shutdown refusal, the stream port and its
TLS, no cluster-wide Secret access, the named Secret grants, the
admission policy, the stop grace, the one-release image check, the
rollout strategy and pause.
- `hack/check-commit-trailers.sh origin/main..HEAD`: OK.

### Not tested

- A live run on 0.4.0 passed on a three-node stand installed with
`storage.backend: blockstor` and upgraded to this PR's pin, see
https://github.com/cozystack/cozystack/pull/2942#issuecomment-7225299079:
Filesystem and Block PVCs, LUKS, snapshot and restore, group snapshots
across nodes, online resize, `vmdisk-clone`, and the `vminstance`
chainsaw suite including the VM backup roundtrips. That run predates the
scheduler and GUI render guard above, which is unit-tested only. No CI
lane can run blockstor: every e2e lane runs Talos in containers without
DRBD.
- The passphrase hook Job and the admission policy are rendered and
unit-tested here; this PR has no run of them on a fresh install.
- The satellite rollout strategy has not rolled on a live cluster; the
timing figures come from a manual node-by-node `OnDelete` upgrade.

### Screenshots

N/A, no UI change.

### 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.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/pull/667 documents the
backend, `storage.acknowledgeBackendChange` and this chart. It still
describes blockstor 0.2.0 and has to follow this PR to 0.4.0 and to the
master key opened from `linstor-passphrase`. Its LINSTOR to Blockstor
migration guide belongs with #5466. It stays unticked and merges after
this PR.
- [ ]
[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:

I walked the trigger map against the diff. Only the website is affected:
the new `storage.backend` key in `packages/core/platform/values.yaml`
and the backend docs, both in website#667. No app package, installer
values, variant, bundle, `hack/package.mk` or `hack/update-crd.sh` is
touched.

### Release note

```release-note
feat(linstor): Blockstor can be selected as the storage control plane for new clusters with `storage.backend: blockstor` on the platform. LINSTOR stays the default and existing clusters are unchanged. Blockstor is experimental, and moving a cluster that already has LINSTOR volumes to it is not part of this change.
```
2026-11-30 15:47:15 +03:00
Aleksei Sviridkin 23b94d6d1a feat(workloadmonitor): report failed Jobs that opt in as not operational (#5505)
## What this PR does

Refs #5459

A chart that runs workload-critical work in a Job outside its Helm
release has no way to report a failed run on the Application today:
`Ready` mirrors the HelmRelease, which is already applied, and
`WorkloadsReady` only looks at pods, PVCs, Services, BucketClaims and
DataVolumes. The immediate case is #5479, where the postgres collation
repair and PostGIS update move out of a blocking hook into a Job started
outside the release. If that Job fails (duplicates under a UNIQUE index,
a PostGIS update that does not go through), the indexes stay wrong while
the Application shows `Ready=True` and `WorkloadsReady=True`.

This PR implements the proposal in
https://github.com/cozystack/cozystack/issues/5459#issuecomment-7268007229
by adding a generic rule to the WorkloadMonitor controller: a `batch/v1`
Job in the monitor's namespace that carries the monitor's selector
labels plus `workloads.cozystack.io/report-failure: "true"`, and has
`Failed=True`, makes the monitor not operational, with reason
`JobFailed` and a message such as `Job postgres-x-collation-repair
failed: BackoffLimitExceeded: Job has reached the specified backoff
limit`. cozystack-api passes it through unchanged as
`WorkloadsReady=False` with that reason and message. The rule knows
nothing about postgres: a chart opts a Job in explicitly with that
label. A Job with only the selector labels, which every chart and every
operator inheriting labels from the workload may carry, never affects
the monitor. The postgres side (the labels on the repair Job, no
`ttlSecondsAfterFinished`) lands on #5479.

Behaviour:

- A Job that is deleted, or replaced by a run that does not fail, clears
the verdict. Of the Jobs one controller owns, only the newest counts, so
a CronJob's failed run that stays in its history after a later success
does not keep the monitor down.
- The message lists failed Jobs sorted by name, at most three, then `N
more Jobs failed`.
- Precedence: a DataVolume verdict comes first (unchanged; its stored
value is kept while DataVolumes cannot be read), then `JobFailed`, then
`BucketClaimNotReady`. `minReplicas` still sets `Operational=false`
without a reason, so a failed Job beside too few replicas reports
`JobFailed`.
- Jobs are watched and mapped to monitors the same way pods are. The
manager caches only Jobs that carry the opt-in label, with a transform
that keeps only metadata (labels, owners, timestamps) and conditions.
- RBAC: a `+kubebuilder:rbac` marker for `jobs.batch` get/list/watch
documents the need. The markers under `internal/controller` do not
generate YAML, and the cozystack-controller ClusterRole in
`packages/system/cozystack-controller/templates/rbac.yaml` already
grants get/list/watch on every resource, as it does for pods, PVCs,
BucketClaims and DataVolumes, so the chart needs no change.

No chart sets the opt-in label yet, so nothing reports until a chart
adopts it. The postgres chart sets the selector labels in the Cluster's
`inheritedMetadata`, so CNPG's initdb and join Jobs carry them; without
the opt-in they are ignored, as are backup CronJob runs and any other
labelled Job.

### Testing

- `go build ./...`, `go vet` on `./internal/controller/`,
`./cmd/cozystack-controller/`, `./api/v1alpha1/`: clean.
- `go test ./internal/controller/... ./pkg/registry/apps/application/...
./api/...`: pass.
- New unit tests (fake client): a failed Job sets `Operational=false`,
reason `JobFailed` and the message; a succeeded, running, `Failed=False`
or other-selector Job, and a failed Job without the opt-in label or with
it set to anything but `"true"`, has no effect; a failed Job deleted or
replaced by a successful run clears the verdict; a stale `JobFailed` is
cleared before the DataVolume reader is installed; precedence against
`minReplicas`, an unprovisioned BucketClaim and a DataVolume verdict;
message sorting, the three-Job bound, newest-run-per-controller and Jobs
being deleted; the cache transform keeps what the rule reads.
cozystack-api: a monitor with `JobFailed` yields `WorkloadsReady=False`
with that reason and message.
- `make generate`: no changes.
- Not run against a cluster: the Job watch and the transformed cache
were not exercised end to end.

### Downstream repositories

Walked the trigger map against the diff
(`api/v1alpha1/workloadmonitor_types.go` constant only, no CRD schema
change; `internal/controller`; `cmd/cozystack-controller`; tests). No
package, platform values, ApplicationDefinition, installer, hack
tooling, telemetry or commit-convention change.

- [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
feat(workloadmonitor): a failed Job that carries a WorkloadMonitor's selector labels and `workloads.cozystack.io/report-failure: "true"` now makes the workload not operational, so the Application reports `WorkloadsReady=False` with reason `JobFailed` and a message naming the Job and its failure. Deleting the Job, or a later run that does not fail, clears it.
```
2026-11-30 14:04:15 +03:00
Andrey Kolkov 66bba3bf1e fix(postgres): run the collation repair outside the Helm hook
The collation repair ran at the end of the post-upgrade init-job and,
when the image moved, waited for the primary to run it. Helm starts that
hook as soon as the Cluster is patched; CNPG then rolls the replicas
first and the primary last, and every instance whose clients hold
sessions sits in smart shutdown for smartShutdownTimeout (180s on
existing clusters). With three instances the wait took about eight of
the Job's nine minutes, the Job printed "the init-job is out of time,
the next run of it carries on" and the HelmRelease went UpgradeFailed
until Flux retried. When the Job's psql met the primary restart instead,
it failed with "FATAL: the database system is shutting down" and failed
the upgrade the same way. A rebuild of a large index does not fit the
hook budget either.

Moving the repair into an ordinary manifest does not help:
helm-controller waits for every Job of a release to complete within the
same upgrade timeout. So a short post-upgrade hook, run after the
init-job, creates the repair Job through the API, outside the release,
and returns. The repair Job has an hour, keeps the wait for the new
image and the resume marks it had, and is owned by the Cluster. It has a
fixed name, so two repairs never run against one Cluster: the hook
leaves one still running on the same image alone and deletes any other,
waiting for its pod to go, before creating the new one, which also
retries a repair that failed. The hook's Role reaches only that Job and
the release's Cluster by name, apart from create, which RBAC cannot
narrow, and is deleted once the hooks succeed.

psql exits with status 2 both when an instance refuses connections while
shutting down and when it drops a session, so both Jobs now rerun their
script after a growing pause on that status instead of failing; the
scripts are idempotent and their elapsed-time bounds keep counting
across attempts. A connection lost during an index rebuild is reported
the same way. smartShutdownTimeout stays as it is: the repair no longer
waits inside the hook, so the rollout's length does not matter.

The PostGIS extension update waits for the same rollout, so it moves
into the repair Job with the collation pass, and the messages of both
name the next upgrade of the release as what starts them again. A lost
connection in the PostGIS pass is reported with the same status as in
the collation pass, so the Job reconnects instead of giving up.

The repair runs after install as well. The init-job used to record there
which Debian release each database started on, and without that record
the first image move is detected only if the repair reaches the primary
before it restarts. The Job sets PGCONNECT_TIMEOUT, so a primary that
does not answer is retried instead of using up the Job's deadline.

A failed index rebuild no longer stops the PostGIS update that follows
it: a unique index that duplicates keep from being rebuilt would
otherwise hold the extensions back until an operator removes them. The
Job still fails at its end.

With an hour to spend, the repair now waits for the new image whenever
the image changes, not only when an index already depends on a versioned
collation. Otherwise it planned on the previous primary, missed an index
created meanwhile, and the release it recorded at the end claimed that
index repaired.

The repair Job carries the WorkloadMonitor's selector labels, opts in to
having its failure reported with workloads.cozystack.io/report-failure,
and has no ttlSecondsAfterFinished, so a failed repair stays visible until the next
upgrade replaces it instead of vanishing while the indexes stay wrong.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-30 17:58:17 +07:00
Andrey Kolkov 5795b5f658 feat(workloadmonitor): report failed Jobs that opt in as not operational
Some charts run work that matters to the workload in a Job outside the Helm
release, such as an index repair after an image upgrade. Once the release has
applied, Ready stays True whatever that Job does, so a failed run was visible
only to someone who went looking for the Job.

A Job that carries a monitor's selector labels and
workloads.cozystack.io/report-failure set to "true", and has Failed=True, now
makes the monitor not operational with reason JobFailed and a message naming
the Job and its failure, which the Application surfaces as
WorkloadsReady=False. The opt-in is explicit because the selector labels
alone are carried by Jobs that say nothing about the workload's health: Jobs
an operator labels by inheritance from the workload, such as CloudNativePG's
initdb and join Jobs under the postgres chart, and backup runs. Of the Jobs
one controller owns only the newest counts, because a CronJob keeps failed
runs in its history after a later run succeeds; a Job that is deleted or
replaced by a successful run clears the verdict.

A DataVolume verdict still comes first, since its stored value is kept across
restarts until the DataVolumes can be read again. A failed Job outranks an
unprovisioned BucketClaim: it stays failed until something replaces it, while a
claim is usually still being provisioned.

The manager caches only Jobs that carry the opt-in label, and of them only
their metadata and conditions. The controller's ClusterRole already grants
read on every resource.

Refs: #5459
Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-30 13:42:03 +07:00
Andrei Kvapil ee5d2adceb docs(linstor): cover the locked controller and retries after a way back
The live run of the ways back found the restarted linstor-controller
with its master key locked: the LinstorCluster sets no
linstorPassphraseSecret, so new LUKS volumes fail until the passphrase
is entered. Every way back restarts the controller, so each one now
says to unlock it.

Starting again after a way back from step 3 or 4 finds the converted
objects still there. A plain delete of a Resource or Snapshot is not
safe: the satellite's finalizer is released only after it has deleted
the replica's storage, so the next hold would destroy the volume.
Say what a retry overwrites, what it leaves, and how to clear the
rest and keep the LUKS passwords under one keyring.

Also warn that the scheduler and GUI show one UpgradeFailed when the
migration completes, which clears on its own.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:37 +01:00
Andrei Kvapil 8d0e577afe docs(linstor): mark the migration experimental, give a way back per step
blockstor has run on test clusters only, so the procedure says so and
asks for a maintenance window. Each step now says how to go back from
it, and the two after which there is none, repointing CSI and
unfreezing it, say so, since that decides when an operator can still
abort. Until CSI is repointed every way back is the same switch to
backend linstor, so it is written out once.

linstor-scheduler and linstor-gui may fail their render and retry
when CSI is repointed, until the linstor release has written the
external controller, which reads as a failure without the note.

Assisted-by: LLM
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2026-11-29 23:04:37 +01:00