Commit Graph
8662 Commits
Author SHA1 Message Date
IvanHunters 902909dbe7 feat(postgres): add an audit toggle for access and statement logging
Managed Postgres could already load pgaudit through the
sharedPreloadLibraries allowlist and set pgaudit.log and log_connections
through postgresql.parameters, but that leaves an orchestrator depending
on internal parameter names to answer who connected and what they ran.

This adds an audit block that bundles access and statement auditing
behind one switch. With audit.enabled the chart adds pgaudit to
shared_preload_libraries and seeds pgaudit.log (from audit.log,
default "write, ddl, role"), log_connections and log_disconnections. The
parameters are seeded as defaults, so an explicit pgaudit.log or
log_connections in postgresql.parameters still wins. The audit trail
goes to the instance log, which the platform log stack already collects,
so it is queryable per database without extra wiring.

Postgres only; the other managed databases are left for follow-ups.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-11-23 17:25:17 +03:00
Aleksei Sviridkin 1ab20ea96e fix(cluster-api): name the kubeconfig the upgrade hook runs with (#5398)
<!-- 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

The "Unit & controller tests" job fails on `main` and on every PR
rebased on it: `hack/check-hook-request-timeout.bats` reports "no
in-cluster kubectl call carries a non-zero --request-timeout" against
`packages/system/capi-providers-core/files/upgrade-providers.sh`. #4902
added that script and #5360 extended the check to `files/` a few hours
apart, so neither ran against the other.

It is a false positive. The hook Job exports
`KUBECONFIG=/scripts/kubeconfig` and the script talks to the API only
through that explicit kubeconfig, which is exactly the case the check
exempts, but the exemption keys on the file naming `KUBECONFIG` and the
script only named `KUBE_CONTEXT`.

The single commit makes the script require `KUBECONFIG` with its other
inputs, so the dependency is explicit and the script refuses to fall
back to the in-cluster config. The check and the 10s per-call timeout
are left as they are. It adds a test that the script exits before any
API call when `KUBECONFIG` is unset, and asserts in the chart test that
the Job sets `KUBECONFIG` to the mounted kubeconfig. Reverting the
script change makes both the check and the new test fail.

### 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
fix(cluster-api): the provider upgrade hook script now requires the kubeconfig its Job mounts, which also unblocks the unit test job on main.
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* Upgrade operations now require `KUBECONFIG` to be set and stop with an
error if it is missing, before making API calls.
* Added checks that the upgrade job uses the expected kubeconfig path
and that the configured current context is `capi-upgrade`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:49:40 +03:00
Aleksei Sviridkin 8f0082a1c8 fix(clickhouse): delete the archive when its Backup is deleted (#5224)
<!-- 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

Builds on #5229 (merged), which gives every backup run an archive of its
own.

Deleting a `Backup` taken with the Altinity (ClickHouse) strategy
released its finalizer at once and left the archive in the bucket. On
the system bucket nothing else prunes it, so every ClickHouse backup
stayed until someone called the sidecar by hand, and the route the chart
and the examples documented for that, `DELETE /backup/<name>/remote`,
does not exist in clickhouse-backup 2.7 and answers 404.

The driver names each archive `<application>-<start time as
YYYYMMDDHHMMSS>-<first 12 hex digits of the BackupJob UID>` (#5229) and
records it on the `Backup` under
`altinity.strategy.backups.cozystack.io/archive`. This PR also records,
under `altinity.strategy.backups.cozystack.io/use-system-bucket`, the
application's `backup.useSystemBucket` as it read when the backup Job
was created: the setting is stamped on the backup Job and copied onto
the `Backup`, because the application may switch before the controller
sees the Job complete. A Job created before the stamp existed falls back
to the application as it reads at completion. For a system-bucket
application the bucket the projected credentials (`cozy-backups-creds`)
name is recorded the same way, under
`altinity.strategy.backups.cozystack.io/bucket`. The `Backup` is created
with its cleanup finalizer already set, so a `Backup` deleted before the
`Backup` reconciler first sees it still has its archive deleted.

On `backup.useSystemBucket: true`, deleting the `Backup` runs a one-shot
cleanup Job that calls `POST /backup/delete/remote/<name>` on the
application's sidecar and holds the finalizer until it completes. The
sidecar refuses a delete with 423 while any other operation runs and
cannot be reached while its Pod restarts, so the Job waits both out
within its deadline; an archive that is already gone counts as deleted,
and any other answer fails the Job, which is reported as an
`ArtifactCleanupFailed` Warning Event carrying the reason the Job failed
and retried after a wait that starts at 30 seconds and doubles with each
failure up to 30 minutes (kept on the `Backup` under
`altinity.strategy.backups.cozystack.io/cleanup-failures` and
`.../cleanup-retry-after`, since the failed Job is deleted to make room
for the next). The Job starts only once the projected credentials have
reached the sidecar, as the backup and restore Jobs do. It is built by
the controller, not rendered as a whole from the strategy template,
because the shipped and the example templates run `restore_remote` for
every mode other than `backup`; only the image, how to pull it and where
the Pod may be scheduled (node selector, tolerations, affinity, priority
class) come from the template, rendered as for the strategy's own Pods.

When the delete cannot or must not run, the `Backup` is released with an
`ArtifactNotDeleted` Warning Event naming the archive left behind: the
namespace is terminating, the strategy, the application or its API
Secret is gone, the application no longer uses the system bucket (also
when it leaves while the delete runs), the system bucket is no longer
the one the `Backup` records or cannot be read (also when it changes
while the delete runs; a sidecar on another bucket would answer "not
found" and the delete would count as done), another Job holds the
cleanup Job name, or the archive has the older
`clickhouse-<application>-<YYYYMMDDTHHMMSSZ>` form, without its
BackupJob's UID. Such a name comes from a controller that predates
per-run names; two runs of one application started within the same
second share it, and a run still in flight when the controller is
upgraded records it later, so it is never deleted.
`backups.cozystack.io/skip-artifact-cleanup: "true"` releases a `Backup`
without deleting anything. An application on its own bucket keeps the
archive's lifecycle, as with MongoDB. The wrong delete route is
corrected in the chart comments and the restore scenario.

A BackupJob or RestoreJob no longer takes the outcome of a batch Job of
its name that it does not control. A Job left by an earlier owner of the
same name is waited out, with the `Ready` condition
(`PredecessorJobPending`) naming it, until the garbage collector removes
it; any other Job holding the name fails the BackupJob or RestoreJob
with a message naming the Job. The condition is dropped once the run's
own Job starts.

The example strategy under `examples/backups/clickhouse` now uploads
under the archive name the controller chose and restores the archive the
`Backup` records, as the shipped strategy does, keeping its clock-made
name and the newest archive only as the fallback for a run given no
name; `hack/clickhouse-example-strategy.bats` runs it against a stubbed
sidecar. The backup scenario no longer says the archive is expired by
the upstream tool's retention, which the chart does not configure.

Known limitations: a `Backup` taken before #5208, or by a custom
strategy that does not use `.ArchiveName`, does not name its archive and
keeps it; a `Backup` that names its archive but not the bucket setting,
as every `Backup` taken before this change does (a 1.7.x release that
carries #5208 among them), keeps its archive too and is released without
an Event; a `Backup` that records no bucket, taken before buckets were
recorded, is deleted without the bucket check; a `Backup` deleted during
an application uninstall can lose its cleanup Job to the chart's own
`<release>-cleanup` hook and is then released with a Warning Event,
leaving the archive; the recorded setting and bucket are read when the
backup Job is created, not observed from the upload, so a switch made
just before a backup, while the sidecar still runs on the previous
bucket, is recorded for an archive written to the previous one.

Related gap outside this PR, in main today: an archive uploaded by a run
whose `Backup` name is already taken is recorded by nothing, so no
`Backup` deletes it.

Verified with unit tests that drive the cleanup path through a fake
client and the cleanup script against a stub `curl`, with mutation
checks on every guard, and on a test cluster running v1.7.0 with the
backup controllers built from this branch (before #5229 shortened the
run name to its current form, which leaves the deletion side unchanged),
against the real clickhouse-backup sidecar and SeaweedFS: a backup
records a per-run archive name and the bucket setting on a `Backup`
created with its finalizer; deleting the `Backup` deletes the archive's
objects in the bucket; a restore from a `Backup` brings the data back; a
BackupJob recreated under a used name waits for the earlier Job and then
writes an archive of its own; a Job of that name created by anything
else fails the BackupJob; a `Backup` recording an archive named without
a UID is released with `ArtifactNotDeleted` and its objects stay. The
changes made after that run (the recorded bucket, the retry wait, the
credentials wait before the cleanup Job, the rendered cleanup Pod
settings, the cleared predecessor condition, the example strategy) are
covered by the unit tests and bats, not by a live run.

### 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
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#809 (for cozystack/website#808; its `next/`
pages should merge 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:

### 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(clickhouse): deleting a Backup taken on the system bucket from this release on now deletes its clickhouse-backup archive and keeps the Backup until the delete finished, reporting an archive it cannot or must not delete (including one named without its BackupJob's UID, or in a system bucket the platform has left) as a Warning Event and retrying a failed delete with a growing wait; the cleanup Pod is scheduled as the strategy's own Pods; a BackupJob or RestoreJob no longer reports the outcome of a batch Job it did not create; the documented sidecar delete route is corrected to POST /backup/delete/remote/<name>.
```


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

## Summary by CodeRabbit

* **New Features**
* ClickHouse backups using the system bucket now remove their recorded
archive when the backup is deleted. Deletion waits for cleanup to
finish.
* Backup and restore operations use the controller-provided archive name
when available. Restores can fall back to the latest matching archive.
* **Bug Fixes**
* Temporary sidecar failures are retried with increasing delays. If
cleanup cannot safely remove an archive, it completes with a warning
rather than risking deletion of the wrong archive.
* **Documentation**
* Clarified that archives in tenant-owned buckets remain until manually
deleted or removed by bucket lifecycle rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:27:05 +03:00
Aleksei Sviridkin 836f280426 fix(monitoring): spread monitoring replicas over nodes (#4989)
## What this PR does

The monitoring chart renders its VMCluster, VLCluster, VTCluster and
VMAlertmanager without `affinity` or `topologySpreadConstraints`, and
vm-operator v0.68.4, which main and release-1.6 ship, copies both fields
onto the pods as written and adds none of its own
([build/statefulset.go#L11-L36](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/statefulset.go#L11-L36),
[build/deployment.go#L11-L36](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/deployment.go#L11-L36)).
Nothing keeps two replicas of one tier off the same node.

Seen on three three-node clusters, on v1.6.4 and v1.6.5, which both
render these resources without a placement rule and ship the same
operator. In the root tenant of one of them both vmstorage replicas of
`longterm` and both vmselect replicas of `shortterm` shared a node, with
their volumes on the node-local `local` class. On another both vlstorage
replicas shared a node, on `replicated`. On all three, two of the three
Alertmanager replicas shared a node. With `replicationFactor: 2` both
copies of every `longterm` series sit on that node, and vmalert
evaluates its rules through the vmselect of the first metrics storage,
`shortterm` by default, so losing that node also stops alert evaluation.
A StatefulSet pod on a lost node is not replaced until its Pod or Node
object is deleted, so this holds for the Alertmanager replicas too,
which have no volume.

This PR gives every tier a per-node spread keyed to the
`app.kubernetes.io/name` and `app.kubernetes.io/instance` labels the
operator puts on that component's pods
([ClusterSelectorLabels](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/api/operator/v1beta1/vmextra_types.go#L108-L124),
[VMAlertmanager](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/api/operator/v1beta1/vmalertmanager_types.go#L323-L330)).

- The tiers that run as StatefulSets, vmstorage, vmselect, vlstorage,
vtstorage and the Alertmanager, get `maxSkew: 1` on
`kubernetes.io/hostname` with `whenUnsatisfiable: DoNotSchedule` and
`nodeTaintsPolicy: Ignore`, as #4986 proposes for etcd members and #4947
for the SeaweedFS masters, for the reasons given there. A preference
only adds to a node's score and #4986 shows other scores outweighing it,
while a replica placed wrong on a node-local volume stays there. More
replicas than nodes still start, and a replica evicted by a drain goes
to a node without a peer or waits for its own node instead of joining a
peer. As in #4986, a node the pods can never run on, such as a tainted
control plane, still counts as an empty node, so next to such a node the
three Alertmanagers need three schedulable nodes.
- The tiers that run as Deployments, vminsert, vlinsert, vlselect,
vtinsert and vtselect, get the same spread with `ScheduleAnyway`. A
Deployment replaces their pods on another node by itself, and a
requirement would only add Pending pods during drains on small clusters.
- When `_cluster.scheduling.globalAppTopologySpreadConstraints` is set,
every tier gets that policy instead, with the tier's selector added to
each constraint that has none and a selector the policy sets itself left
as written, the rule the keycloak chart applies to its database
constraints. A value that does not parse or holds no non-empty
`topologySpreadConstraints` list fails the render, as an empty
`logsStorages` already does, instead of silently leaving the policy out.
The `traces-central` VMAuth keeps the spread it already has.

### On upgrade

The new pod templates make the operator update every tier once.
StatefulSets default to `OnDelete` in the operator
([build/defaults.go#L84-L87](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/build/defaults.go#L84-L87)),
and it replaces their pods itself, one at a time because the chart sets
no `rollingUpdateStrategyBehavior`, in ordinal order through the
Eviction API, waiting for each new pod to become Ready
([reconcile/statefulset.go#L156-L176](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/statefulset.go#L156-L176),
[#L215-L359](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/statefulset.go#L215-L359)).
The wait is `VM_PODWAITREADYTIMEOUT`, 80s by default
([config.go#L578-L587](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L578-L587)),
which the victoria-metrics-operator package leaves alone. Deployments
roll through the Deployment controller
([reconcile/deploy.go#L26-L80](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/deploy.go#L26-L80)).
Within a VMCluster the order is vmstorage, vmselect, vminsert
([vmcluster.go#L81-L143](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/vmcluster/vmcluster.go#L81-L143)),
within a VLCluster vlstorage, vlselect, vlinsert
([vlcluster.go#L65-L74](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/vlcluster/vlcluster.go#L65-L74)).

A replica without a volume, like the Alertmanager, or with a volume that
can be attached on another node, like vlstorage on `replicated`, is
placed again under the new rule during that rollout, so given enough
nodes those tiers end up spread with nothing else to do.

A replica on a node-local volume cannot leave its node, and `local` is
the default class for the metrics storage in the documented layout. If a
peer of the same tier runs on that node while another node has none, the
new pod cannot be scheduled, since the volume allows only that node and
the spread refuses it, so it stays Pending. The operator gives up the
wait after 80s and keeps the resource `expanding`, because a wait
timeout counts as retryable
([reconcile.go#L141-L143](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/factory/reconcile/reconcile.go#L141-L143),
[controllers.go#L343-L353](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/controller/operator/controllers.go#L343-L353)),
and tries again on the next reconcile. The later tiers of that VMCluster
or VLCluster are not updated meanwhile, and the peer keeps serving. For
a VLCluster the monitoring HelmRelease waits on that status through its
`healthCheckExprs`, so the release upgrade times out as well.

Such a replica does not move by itself, and this PR does not move it.
Moving it means recreating its volume on another node. For vmselect that
drops a cache. For vmstorage it drops that replica's copy, and with
`replicationFactor: 2` the series written before the move keep one copy
until they age out of retention. vlinsert shards logs over vlstorage
rather than replicating them, so for vlstorage it drops the logs on that
volume. A platform that wants to defer the move can set
`globalAppTopologySpreadConstraints` to a `ScheduleAnyway` policy, which
the other charts that read it pick up too.

#4947 gives the same tiers a preferred pod anti-affinity in its second
commit and argues against a required rule because of exactly this case.
Since then the Alertmanager layout showed up on a third cluster, and
#4986 found tenant etcd members on one node despite a `ScheduleAnyway`
spread on the same storage classes, so this PR takes the other side for
the tiers that keep state and states the cost. The two touch
neighbouring lines but merge cleanly, and the monitoring suite passes on
the merge, 27 suites and 327 tests. If you prefer this approach, the
monitoring commit of #4947 is no longer needed.

### Tests

`tests/topology_spread_test.yaml` pins the whole constraint list of
every tier for the default, for a second VMCluster name, for an empty
platform policy, for a zone policy, for a policy with two constraints,
for a policy constraint that brings its own selector, and for a
constraint without a selector after and before one with its own, with
`matchLabels` and with `matchExpressions`.
`tests/topology_spread_invalid_policy_test.yaml` pins the failure for a
policy that does not parse, a bare list, an empty list and a map.
Against the templates on main all 18 cases fail, and against
0dbbb3b157 only the two new ones. The suites also catch each of 19
mutations, which are a soft default for every tier, no
`nodeTaintsPolicy`, `Honor`, `maxSkew: 2`, a soft vmselect, vlstorage,
vtstorage or Alertmanager, a hard vminsert, ignoring the platform
policy, adding the selector to the last platform constraint only, keying
vmstorage to the release name, dropping the failure, dropping either of
its two conditions, overwriting a selector the policy brings, and
merging the tier's selector into the shared selector map, into the
parsed policy constraint or into every constraint. The first of those
three is the merge order of the first commit. With a policy that mixes
both kinds of constraints it wrote the policy's own selector into the
selector of every constraint without one, and only the two new cases
catch it.

```console
$ docker run --rm -v "$PWD":/apps -w /apps/packages/system/monitoring helmunittest/helm-unittest:4.2.3-1.1.2 .
Charts:      1 passed, 1 total
Test Suites: 26 passed, 26 total
Tests:       322 passed, 322 total
```

On main the same command gives 24 suites and 304 tests, with
helm-unittest 1.1.2 as CI pins it, and `packages/extra/monitoring` stays
at 4 suites and 31 tests. With default values `helm template` differs
from main only in the new blocks and in the alerta key and Grafana
password the chart generates at random, and an empty
`globalAppTopologySpreadConstraints` renders the same as none. I also
decoded the rendered VMCluster, VLCluster, VTCluster and VMAlertmanager
specs strictly into the operator's v0.68.4 API types, which rejects
unknown fields, and checked each selector against the labels the
operator's `PodLabels` gives its component. Each matches its own
component and no other one in the release. With a policy that mixes both
kinds of constraints the same holds for every selector the chart adds,
and the policy's own selector stays as written. I have not run the e2e
suite or rolled this out on a cluster.

`vmcluster.yaml` and `vlogs.yaml` are the same on release-1.6, and
`alerta.yaml` differs from main in one unrelated line. release-1.6 has
no VictoriaTraces, so the backport leaves those lines and their tests
out. That backport is a separate PR.

### Screenshots

Not a UI change.

### Downstream repositories

Only templates and tests of `packages/system/monitoring` change. No
values, schema, README, `ApplicationDefinition`, platform values or
tooling change, and the website shows the monitoring PVCs and pods of an
install but documents no placement workaround, so no trigger map entry
applies.

- [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(monitoring): spread vmstorage, vmselect, vlstorage, vtstorage and Alertmanager replicas with DoNotSchedule; other tiers use ScheduleAnyway. Pods pinned to a node-local volume can remain Pending if a peer already occupies that node. Before upgrading, set scheduling.globalAppTopologySpreadConstraints to a topologySpreadConstraints list with maxSkew: 1, topologyKey: kubernetes.io/hostname and whenUnsatisfiable: ScheduleAnyway to retain permissive scheduling. This platform-wide override also applies to other charts that consume it. It can also unblock an upgrade already stalled on the spread constraint without deleting volumes. To retain hard spreading instead, plan the affected replica's storage migration or recreation on another node. Recreating its PVC discards that replica's data: vmselect loses cache, vmstorage loses one copy of historical series, and vlstorage loses the logs on that volume. Verify replication or restore coverage before any destructive recovery; do not delete a primary or the last data copy.
```


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

- **New Features**
- Improved monitoring workload distribution across hosts and zones to
increase resilience.
- Added topology-aware scheduling for metrics, logs, traces, and
alerting components.
- Supports configurable platform scheduling policies, including required
and preferred placement rules.
- Provides sensible hostname-based defaults when no custom policy is
configured.

- **Bug Fixes**
- Ensures scheduling constraints consistently target the correct
monitoring components, including when custom constraints are supplied.
- Added validation for malformed or unsupported topology scheduling
policies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:09:45 +03:00
Aleksei Sviridkin 4131169c3c fix(redis, valkey, harbor): spread sentinels and data pods over nodes (#4990)
## What this PR does

The RedisFailovers rendered by the `redis` and `valkey` apps and by the
Harbor system chart set no placement, so the operator applies its
default, a preferred pod anti-affinity on `kubernetes.io/hostname`
([generator.go#L795-L816](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L795-L816),
the same in spotahome v1.3.0-rc1 that release-1.6 ships). A preference
only decides where a pod starts. A sentinel evicted by a drain is
recreated while both other nodes already run one, and a rollout of the
sentinel Deployment adds each new sentinel before it removes an old one,
so either can leave two sentinels on one node, and nothing moves them
back.

Seen on a three-node cluster running v1.6.4 and on clusters running
v1.6.5. A tenant Redis with three replicas had its three Redis pods on
three nodes and two of its three sentinels on one node, and Harbor's
Redis had two of its three sentinels on one node too. Losing that node
leaves one sentinel, below the quorum of two, so no failover can happen
while it is down. The operator does not step in either, because it skips
its checks while a pod of the instance is Pending or terminating
([checker.go#L101-L111](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L101-L111)),
and the pods of a lost node stay terminating, so if the master was on
that node the instance has no master until the node is back.

This PR gives the sentinels and the data pods a spread with `maxSkew: 1`
on `kubernetes.io/hostname`, `whenUnsatisfiable: DoNotSchedule` and
`nodeTaintsPolicy: Ignore`, the default #4986 proposes for tenant etcd.
The selector is the `app.kubernetes.io/name` and
`app.kubernetes.io/component` pair the operator puts on every pod,
without `redisfailovers-role`, which the operator switches between
`master` and `slave` at runtime. No `affinity` is set, so the operator's
anti-affinity stays. When
`_cluster.scheduling.globalAppTopologySpreadConstraints` is set it
replaces the default, and the selector is added to each of its
constraints that has none, as the keycloak chart does for its database
constraints. The etcd and postgres charts add it under the last
constraint only, and a constraint without a selector counts no pods
([helpers.go#L36-L39](https://github.com/kubernetes/kubernetes/blob/v1.33.12/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go#L36-L39)),
so with a zone and a node constraint the zone one would spread nothing.
A policy that does not parse or has no non-empty
`topologySpreadConstraints` list fails the render.

The sentinels get a hard constraint because of the quorum. A sentinel
that waits Pending while its node is away leaves two sentinels on two
nodes, which still form the quorum, while two sentinels on one node turn
the loss of that node into a lost quorum. With `Ignore` a cordoned node
still counts, so an evicted sentinel waits for its node instead of
starting next to another one. The data pods get the same constraint
because on a node-local StorageClass a pod that starts next to another
one stays there with its volume. An instance with more pods than nodes
still starts, because the skew is counted between the nodes that exist
([filtering.go#L338-L356](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/filtering.go#L338-L356)).

The sentinel constraint also has `matchLabelKeys: [pod-template-hash]`.
The operator sets no strategy on the sentinel Deployment
([generator.go#L546-L551](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L546-L551)),
so a rollout of three sentinels adds one new pod at a time while the old
ones run. Counted together with the old pods, a new sentinel can start
on a node that already has another new one, and that pair stays once the
old pods are gone. With the key, new pods are counted only against each
other
([common.go#L95-L105](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/scheduler/framework/plugins/podtopologyspread/common.go#L95-L105)),
and the ReplicaSet removes old pods that share a node with another pod
first
([replica_set.go#L863-L878](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/replicaset/replica_set.go#L863-L878),
[controller_utils.go#L859-L865](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/controller_utils.go#L859-L865)),
so a rollout on three or more nodes ends with one sentinel per node.
`matchLabelKeys` is beta and on by default since Kubernetes 1.27
([kube_features.go#L1502-L1505](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/features/kube_features.go#L1502-L1505)).
The RedisFailover CRD on main has both fields, and the redis-operator
package replaces the CRD on upgrade.

On upgrade the operator writes the StatefulSet and the sentinel
Deployment in the same pass
([ensurer.go#L49-L57](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/ensurer.go#L49-L57)).
The Deployment controller rolls the sentinels one at a time and removes
an old one only after its replacement is ready, so three sentinels stay
available. The StatefulSet uses `OnDelete`
([generator.go#L376-L379](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L376-L379))
and the operator replaces its pods itself
([checker.go#L14-L83](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/checker.go#L14-L83)).
It waits while any Redis or sentinel pod is Pending or terminating
([check.go#L547-L559](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/check.go#L547-L559))
or a replica is not in sync, so the Redis pods are normally replaced
after the sentinel rollout, one outdated replica per pass and the master
last. The master's preStop hook asks the sentinels to fail over before
the pod stops
([generator.go#L263-L267](https://github.com/freshworks-oss/redis-operator/blob/v3.3.5/operator/redisfailover/service/generator.go#L263-L267)),
so an instance with replicas goes through one failover during the
upgrade, and a single-pod instance restarts its pod. The charts do not
set `disableMasterRollout`. The Cozystack patches to the operator do not
change any of this.

This has two costs. With `Ignore` a node the pods can never run on, such
as a tainted control plane, counts as an empty node, so on such a
cluster each usable node takes one pod at most and the rest stay
Pending, and for Redis a Pending pod also stops the operator's checks
for the instance, including the choice of the first master of a new one.
And data pods that already share a node on a node-local volume cannot be
separated by a reschedule. The replica the operator recreates there
during the rollout cannot be placed, the rollout stops before the
master, and the instance runs one replica short, with the operator's
checks stopped, until that replica's volume is recreated on another
node. On storage that attaches from any node the recreated replica moves
to a free node instead. A platform that wants the old behaviour can set
`scheduling.globalAppTopologySpreadConstraints` to `ScheduleAnyway`,
which the other charts that read it pick up too.

#4880 adds a zone spread to the same two blocks of Harbor's
RedisFailover and leaves the per-node part to the operator's
anti-affinity, so whichever of the two lands second has to merge them.
#2665 adds `affinity` values to the redis app, which would replace the
operator's anti-affinity and do not touch the spread. The valkey app had
no `test` target, so this PR adds the same three lines as #4346.

New suites `packages/apps/redis/tests/topology_spread_test.yaml`,
`packages/apps/valkey/tests/topology_spread_test.yaml` and
`packages/system/harbor/tests/redis_spread_test.yaml` pin both default
constraints, that no `affinity` is rendered, that a cluster-wide policy
renders in place of the default with the selector added to every
constraint that has none, that a selector the policy sets itself is
kept, and that a malformed policy fails the render. Against the
templates on main every new case fails, 9 for redis, 5 for valkey and 5
for Harbor, and against the first commit the 12 cases the second commit
adds fail. Each of 21 mutations fails at least one case. In the default
constraints they are `ScheduleAnyway` or no `matchLabelKeys` for the
sentinels, `Honor` or `redisfailovers-role` in the selector for the data
pods, `maxSkew: 2` in valkey and the Harbor sentinel selector set to
`redis`. In the cluster-wide branch they are the policy ignored,
`nodeTaintsPolicy` added to it, the selector added to no constraint, a
selector the policy sets overwritten, the sentinel selector set to
`redis`, the Harbor name without its `-redis` suffix, the policy check
dropped or reduced to the empty list, and the parse error left out of
the message.

```console
$ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/redis helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 6 passed, 6 total
Tests:       77 passed, 77 total
$ docker run --rm -v "$PWD":/apps -w /apps/packages/apps/valkey helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
$ docker run --rm -v "$PWD":/apps -w /apps/packages/system/harbor helmunittest/helm-unittest:4.2.3-1.1.2 .
Test Suites: 3 passed, 3 total
Tests:       14 passed, 14 total
$ hack/check-render-matrix.sh packages/apps/redis packages/apps/valkey packages/apps/harbor
check-render-matrix: 3 rendered, 0 skipped
```

On main the redis chart has 68 tests in 5 suites and Harbor 9 in 2. With
the render fixtures `helm template` of the three charts differs from
main only in the added constraints, apart from the values they generate
on every render. I have not rolled this out on a cluster, and the
scheduling was not exercised against a running kube-scheduler.

The files are the same on release-1.7. release-1.6 ships spotahome
v1.3.0-rc1, whose CRD has neither `nodeTaintsPolicy` nor
`matchLabelKeys` and is not replaced on upgrade, so its backport is a
separate PR without those two fields.

### Screenshots

Not a UI change.

### Downstream repositories

Templates and tests of `packages/apps/redis`, `packages/apps/valkey` and
`packages/system/harbor`, plus a `test` target in the valkey Makefile.
No values, schema, default, README or `ApplicationDefinition` change.
The website already describes `globalAppTopologySpreadConstraints` as
applied to all managed applications and documents no placement
workaround for Redis, so no trigger map entry applies.

- [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(redis, valkey, harbor): spread Redis, Valkey and Harbor Redis data pods and sentinels with DoNotSchedule. The operator rolls existing instances, including one failover when replacing a replicated master. With nodeTaintsPolicy: Ignore, untolerated tainted nodes count as empty domains: if fewer nodes are usable than sentinels, some pods stay Pending. The operator skips its checks while any pod is Pending, so a new instance may never get its first master and an upgrade may stall. Node-local PVCs can also strand recreated replicas beside a peer. Before upgrading, set scheduling.globalAppTopologySpreadConstraints to a topologySpreadConstraints list with maxSkew: 1, topologyKey: kubernetes.io/hostname and whenUnsatisfiable: ScheduleAnyway to opt out. The override also applies to other charts that consume it. For an already stranded instance, apply that override, let the chart and operator reconcile, and verify all pods are Ready and a master is selected. This avoids deleting data. Keeping hard spreading instead requires enough usable nodes and a separate storage-migration plan for any stranded node-local replica.
```


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

## Summary by CodeRabbit

- **New Features**
- Added support for configuring topology spread constraints across
Redis, Valkey, Sentinel, and Harbor Redis workloads.
- By default, pods are spread across hostnames with workload-specific
selectors.
- Custom constraints apply to Redis and Sentinel pods. Existing
selectors are preserved; component-specific selectors are added when
none is provided.

- **Bug Fixes**
- Invalid or empty topology spread configurations now fail validation
during rendering.

- **Chores**
  - Added a test command for the Valkey chart.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 16:09:36 +03:00
Aleksei Sviridkin 7380828271 fix(api): validate workload memory before storing an application (#5348)
## What this PR does

The application API accepts `memory: 8` and stores an eight-byte
workload request. On main, #5009 catches it later when Helm renders the
chart. This patch returns HTTP 422 to the caller on create, upsert, or
an update that introduces such a value.

The check follows declared workload resource fields in the chart schema.
An unrelated edit to an existing application with a smaller value still
passes admission. Existing chart checks continue to apply at render
time. A tenant's zero memory quota and arbitrary chart configuration
keep their existing meaning.

The regression tests exercise the REST create and update paths and
verify that a rejected edit leaves storage untouched. The same change
passed the application registry package tests on main and on
release-1.7. Related to #5004 and #5009.

### 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(api): reject new workload memory values below 1Mi before storing an application. Updates to unrelated fields on existing applications with smaller values still pass admission.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* Application creation and updates reject workload memory settings below
the supported minimum of 1 MiB. Values at or above the minimum are
accepted, and existing below-minimum values may remain unchanged.
* Memory settings in quotas and free-form configuration are not
affected. When concurrent updates occur, memory is rechecked against the
latest stored values, preserving repairs and preventing stale updates
from restoring below-minimum settings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 15:51:34 +03:00
Mattia Eleuteri 5e6772ec3f fix(cluster-api): name the kubeconfig the upgrade hook runs with
The provider upgrade hook reaches the API through the kubeconfig its
Job mounts at /scripts/kubeconfig and exports as KUBECONFIG, never
through the in-cluster config. The script only named KUBE_CONTEXT,
so hack/check-hook-request-timeout.bats, which since it started
reading files/ exempts a script only when it names KUBECONFIG, took
its "kubectl --context ... --request-timeout=10s" for an in-cluster
call and failed "no in-cluster kubectl call carries a non-zero
--request-timeout" on main.

Require KUBECONFIG alongside the other inputs instead of loosening the
check or dropping the timeout: the per-call timeout is safe because
the explicit kubeconfig is what serves it, and the script now refuses
to fall back to the in-cluster config, where the timeout would hit the
bug the check guards against.

Tested with bats on hack/check-hook-request-timeout.bats,
hack/capi-upgrade_test.bats and hack/capi-upgrade-chart_test.bats; with
the script change reverted, the check and the new missing-KUBECONFIG
test both fail.

Fixes: 9680ed64df ("feat(cluster-api)!: update Cluster API to v1.14.4 (#4902)")
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 13:24:41 +01:00
Aleksei Sviridkin 2af1e21299 fix(gateway): copy allowed routes for the edge listener (#4167)
## What this PR does

Fixes #4118. The `edge` listener retained the renderer's local
`edgeAllowedRoutes` value, while `edge-apex` and child listeners already
received independent copies. Give `edge` its own `DeepCopy()` as well,
so later changes to the local value cannot reach the rendered listener.
The rendered Gateway configuration is unchanged.

The change is confined to that one assignment. Current main already
creates independent allowed-routes values for HTTPS and TLS-passthrough
listeners.

Validation: `go test ./internal/controller/tenantgateway -count=1`
passes. No new test is added, as accepted in the maintainer's review.

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

The diff changes only ownership of a local allowed-routes value; API
fields, namespace selectors, route kinds, package layout and rendered
resources stay the same, so it reaches none of the downstream trigger
map's contracts.

### Release note

```release-note
fix(gateway): give the edge TenantGateway listener its own allowed-routes copy; rendered Gateway configuration is unchanged
```


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

* **Bug Fixes**
* Fixed edge-mode gateway listeners so each retains its own
allowed-routes configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 15:12:14 +03:00
IvanHunters 69ba61547e fix(api): make monitor watch versions usable as delete preconditions (#5326)
## What this PR does

A resourceVersion from an Application watch event triggered by a
WorkloadMonitor can now be used as a delete precondition. Today such a
delete always gets 409, because the event carries the monitor's version
and it never matches the HelmRelease.

The event keeps the monitor's version. #2356 added it so a status-only
change reaches informer handlers: client-go's shared informer treats an
update with an unchanged resourceVersion as a resync and hides it from
handlers that are not resyncing. That reason still holds.

The event is now built from a release no older than the monitor. The
cached release is used when it is new enough, otherwise the release is
read live. Before this, the spec came from a cache that can lag behind
the monitor, so the version and the spec in one event could describe
different states. The event carries the newer of the two versions.

A delete precondition is checked against the live release, and only an
older value is a conflict. A newer value is safe to accept because
HelmReleases and WorkloadMonitors live in one etcd, so their versions
come from one sequence. If the live release is still not newer than the
value the client sent, it has not changed since the event's spec was
read. A malformed precondition now gets 400 instead of 409.

Update is not touched. On main it overwrites the caller's
resourceVersion on conflict. #5234 makes it strict with the same rule.

### Limitations

- Late or replayed monitor event. The two backing watches are not
ordered, and a resumed watch replays monitors. When an event would
repeat a version the client may already hold, it falls back to the
monitor's own version, and the object's version steps back. A delete
with that version gets 409 at least until the object's next release
event or monitor change. No write is lost.
- Watch start. An application whose monitors are older than its release
gets an extra MODIFIED event with the lower monitor version. The same
409 window applies.
- Cost. At start and on reconnect a watch reads the release live once
per monitor written after its release last changed. After that it is at
most one live read per monitor status change per open watch. A monitor
whose release is gone or not cached yet now costs a live 404 per event,
where main skipped the event.
- A release event that comes after a monitor event already carried its
version is hidden from informer handlers. Its spec already arrived, and
each monitor's own change still arrives. With several monitors per
application it no longer corrects another monitor's status taken from a
lagging cache. That problem exists on main too: #5325.
- A live read gets one minute, retries included. When it runs out, the
watch ends and the client reconnects. There is no fallback to the cache:
it would pair a stale spec with a newer version again.
- Resuming a watch can still skip an undelivered HelmRelease change of
another application, same as on main: #5324.

Checked consumers: the in-tree console, the Terraform provider (GET then
PUT, no watch), and a downstream UI. None of them filters events by
resourceVersion equality.

### 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(api): a resourceVersion from a WorkloadMonitor-triggered Application watch event now works as a delete precondition, and the event's spec matches its version.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* Application watch events now report consistent resource versions,
including when updates arrive out of order or are replayed after
reconnecting.
* Watch events use current release data when cached data is missing or
outdated, retry transient read failures, and stop promptly when the
watch is canceled or times out.
* Deletion requests validate supplied resource versions against the
latest release, preventing stale requests from deleting newer changes
and returning clear errors for invalid versions.
* **Tests**
* Added coverage for watch-event version handling, read retries and
cancellation, replay behavior, and deletion requests with current,
stale, or invalid versions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 15:02:12 +03:00
Aleksei Sviridkin 7d64fb7a53 fix(linstor): run the NFS server wait init container on the platform CSI image (#5358)
## What this PR does

Closes #5307

The LinstorCluster in `packages/system/linstor/templates/cluster.yaml`
had no `nfsServer.podTemplate`. The NFS server DaemonSet's
`linstor-wait-node-online` init container therefore ran
piraeus-operator's default `quay.io/piraeusdatastore/piraeus-csi` image,
at the operator's own tag. Every other container on the CSI image is
pinned to `linstorCSI.image`.

Changes:
- Adds `nfsServer.podTemplate`, which pins that init container to `{{
.Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag
}}`, the same way `csiNode` pins its `linstor-wait-node-online`.
- Sets `nfsServer.enabled: true` explicitly. In piraeus-operator
v2.12.1, `ComponentSpec.IsEnabled()` is `c == nil || c.Enabled`. An
absent `nfsServer` is enabled today, and the CRD also defaults `enabled`
to `true`. Stating it keeps the DaemonSet deployed exactly as now and
doesn't rely on that default.
- Adds a helm-unittest case in `tests/linstor_test.yaml`, next to the
existing CSI image pins. It checks that the init container's image is
the cozystack-built `linstor-csi` and that `nfsServer.enabled` is
`true`.

I checked the container name against upstream
`pkg/resources/cluster/nfs-server/nfs-server-daemon-set.yaml` at
v2.12.1, the vendored operator version. The operator applies
`podTemplate` as a strategic merge patch keyed on the container name
(see `ComponentPodTemplate("DaemonSet", "linstor-csi-nfs-server",
...)`), so only the image changes.

### How I checked it

- `helm unittest .` in `packages/system/linstor`: 6 suites and 25 tests
pass. With the template change reverted, the new case fails.
- `helm template` renders `nfsServer` with the pinned
`ghcr.io/cozystack/cozystack/linstor-csi:v1.6.0@sha256:…` image.
- I haven't tried it on a running cluster.

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

This only changes one rendered LinstorCluster field in
`packages/system/linstor`. No values keys, images or versions change.

### Release note

```release-note
fix(linstor): the NFS server's linstor-wait-node-online init container now runs the platform-built linstor-csi image instead of the operator's default.
```


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

## Summary by CodeRabbit

* **New Features**
* LINSTOR clusters now enable the NFS server. Its startup check uses the
image repository and tag configured for LINSTOR CSI, including when
those values are overridden.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:59:53 +03:00
Aleksei Sviridkin b7e72840f9 fix(gateway): skip a child apex the wildcard certificate already covers (#5148)
## What this PR does

In DNS-01 mode the controller added every inheriting child tenant's apex
to the parent Gateway's wildcard Certificate. When the child's host
derives one label below the parent (`ci.mgmt.example.com` under
`mgmt.example.com`), the parent's `*.mgmt.example.com` already covers
that apex, and Let's Encrypt refuses the whole order as redundant, so
the parent Gateway is left with no certificate for any of its hostnames.

`renderWildcardCertificate` now skips a child apex when `*.` plus the
apex without its first label is among the wildcards in the same
Certificate, which is the check Boulder runs in `wildcardOverlap`. The
child's own `*.<child-apex>` stays, and an apex two labels below every
wildcard stays listed, because a certificate wildcard matches exactly
one label. That is also why this does not reuse `hostnameCovers`, which
follows Gateway API matching at any depth. The wildcard set is collected
before the loop because `childApexes` is sorted by name and a covering
child wildcard can sort after the apex it covers.

`TestReconcile_DNS01WildcardCertCoversInheritingChildApexes` asserted
the redundant `alice.example.org` SAN and now asserts its absence. The
new `TestRenderWildcardCertificate_SkipsChildApexCoveredByWildcard`
covers the reported case, a child two labels down, a covering wildcard
that sorts late, and an empty or unrelated apex; the reported case and
the late sorting case fail without the fix. The README paragraph that
describes the SAN list is updated to match. `go test -p 2 ./internal/...
-count=1` and `go vet ./internal/controller/tenantgateway/` pass
locally.

Fixes #5125

### Screenshots

No UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/issues/779
- [ ]
[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(gateway): the DNS-01 wildcard Certificate no longer lists a child tenant's apex that the parent's wildcard already covers, so Let's Encrypt stops refusing the order and the parent Gateway gets its certificate again.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* Wildcard certificates now omit child apex names already covered by an
existing wildcard while retaining the child wildcard names. Apex names
not covered by a wildcard remain included, and duplicate or empty apex
names are excluded. This keeps certificate names focused on the names
needed for coverage.
* **Documentation**
* Clarified how child apex and wildcard names are included in DNS-01
certificates, including when a child apex is covered by an existing
wildcard.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:58:09 +03:00
Aleksei Sviridkin ec8088e54c fix(api): skip an invalid ApplicationDefinition instead of failing startup (#5357)
## What this PR does

Refs #4976. This covers the startup half of that issue. Admission-time
validation is left for a follow-up, so the issue should stay open.

`resourceConfigFrom` built one resource per ApplicationDefinition and
returned the first error from `buildResourceFromCRD`. A single
definition with an unparseable `release.cozystack.io/*` annotation
therefore stopped cozystack-api for every tenant. The definition
controller rolls cozystack-api when those annotations change, so the bad
definition also triggered the rollout that then failed. Since #4308 a
connected repository can install definitions, so this is no longer only
an operator's own mistake.

Changes:
- `resourceConfigFrom` no longer returns on the first error. It leaves
the definition out of the served kinds, logs `Skipping invalid
ApplicationDefinition "<name>": <reason>`, and returns the errors so
tests can check them. This matches how a definition that loses its kind
to an older one is already left out.
- `buildResourceFromCRD` now also rejects an `openAPISchema` that isn't
valid JSON. `BuildPostProcessV2/V3` parse every served kind's schema
with `patchSpec` and fail the whole OpenAPI spec on one that doesn't
parse. Rejecting it here leaves only that kind out.
- The comment that called a bad annotation "a loud startup failure" is
updated.

Things I deliberately left out:
- Platform and repository definitions are treated the same. The issue
left open whether a broken platform definition should still fail hard.
Skipping keeps the API up either way, and the log line names the
definition, but I'm happy to make platform definitions fatal if you
prefer.
- Nothing surfaces the problem on the definition itself (an event or
status condition). cozystack-api doesn't write to ApplicationDefinitions
today, and that seemed like a separate change.
- Admission validation in
`internal/lineagecontrollerwebhook/appdef_validator.go` (point 1 of the
suggested fix). Its `failurePolicy: Ignore` means it couldn't be the
only guard anyway.

### How I checked it

- Added `TestResourceConfigFromSkipsInvalidDefinition` next to
`TestResourceConfigFromRegistersOwnerOnly`. It uses two valid
definitions, one with `release.cozystack.io/helm-install-timeout: ten
minutes`, and one with a truncated `openAPISchema`. Only the two valid
kinds are served, and both broken ones are reported with their names.
- `go vet ./pkg/cmd/server/` and `go test ./pkg/cmd/server/` pass.
- I haven't run this against a cluster.

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

This only changes how cozystack-api starts up. No API, values or CRD
changes.

### Release note

```release-note
fix(api): an ApplicationDefinition with an unparseable release.cozystack.io/* annotation or an invalid openAPISchema is now skipped and logged instead of stopping cozystack-api from starting.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* The server can start when an application definition has an invalid
timeout setting, malformed OpenAPI schema JSON, or other
resource-construction error. Invalid definitions are skipped and
reported, while valid definitions continue to be loaded and served. This
prevents a single invalid definition from blocking startup or preventing
other valid application definitions from being available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:55:02 +03:00
Aleksei Sviridkin 7a2d532d16 feat(seaweedfs): bump chart to 4.48 and backport Gateway API HTTPRoutes (#4879)
## What this PR does

This adds Gateway API HTTPRoutes for the SeaweedFS S3 endpoint and the
filer, as groundwork for moving tenant ingress to Gateway API (#4788).
This builds on #4893, which is now merged and keeps Object Lock working
for COSI credentials once SeaweedFS is on 4.48. Nothing is switched.
Both routes are off by default, and the route commit leaves the rendered
release unchanged.

The chart is bumped from 4.45 to 4.48 first, together with the in-tree
SeaweedFS image, so the patched binary matches the chart. Every carried
chart patch still applies. `s3-grpc-tls.patch` is dropped because 4.48
ships the same `[grpc.s3]` section. The in-tree image also drops
`volume-layout-crowded-lock.diff` from main. 4.48 already has that fix
(seaweedfs/seaweedfs#11216), so the patch no longer applies. CI rebuilds
the in-tree image and stamps its digest into the E2E and installer
artifacts.

The image also fixes peer discovery during startup. Peer changes could
be lost between the bootstrap scan and consumer setup, leaving S3
gateways subscribed to only one filer's metadata. Before the reconnect
fix I checked a CI image binary for the handoff and bootstrap replay
floor. The image for this head has not been checked that way.

The checked-in image ref is from an earlier build. Main and
release-candidate builds rebuild SeaweedFS and stamp its actual ref into
the packages before publication. To get this fix from a chart installed
straight from git, build the image first.

With this package's values, the render changes only in image references,
chart labels and new `checksum/*` annotations on master and s3 pods, so
those pods roll once on upgrade. With lifecycle enabled, the admin
container also gets an explicit `-ip=0.0.0.0`. Names, selectors and
volumeClaimTemplates stay the same. Suites that render master or s3 now
list the templates the checksum annotations include, because
helm-unittest only loads the templates a suite names.

The routes come from upstream commit seaweedfs/seaweedfs@68af030e38,
first released in 4.49. This package stays on 4.48, so they arrive as a
new patch. Only the s3 and filer routes and their values are taken. One
line differs from upstream on purpose. The s3 route's default backend is
`<name>-s3`, built from `seaweedfs.name` like the Service that
`s3-service-name.patch` renders. Upstream uses `componentName`, which
matches that Service only while the fullname equals `seaweedfs.name`, so
the new tests override `fullnameOverride` and fail on upstream's form.

The patch is temporary. Drop `patches/httproute-backport.patch` and its
Makefile line when bumping to 4.49 or later. From that release on, `make
update` fails on the patch, because it creates both templates. Before
dropping it, move the s3 backend name change into
`s3-service-name-consumers.patch` and the BackendTLSPolicy note into
`s3-tls-main-port.patch`. Upstream also ships master, volume and admin
routes, which I left out on purpose. The patch header carries the same
note.

Enabling the s3 route needs one more thing. With security on and no
`httpsPort`, the standalone s3 gateway serves TLS on its main port
(`s3-tls-main-port.patch`), so the Gateway needs a BackendTLSPolicy to
reach it. The chart does not render one, and a note next to
`s3.httpRoute` says so.

Extracting the chart from the 4.48 source archive and applying the
patches in `make update` order reproduces the committed `charts/` byte
for byte. Both in-tree image patches apply to the 4.48 source, and the
chart tests pass.

The tests reproduce peer changes lost during startup, and a peer kept
from an earlier master stream after a reconnect. With the current
patches, the filer, wdclient and server suites and focused race checks
pass on Linux. Before the reconnect fix I tested a native build with two
filers, shared PostgreSQL and two S3 gateways. Both filers returned the
identities, and both gateways accepted valid keys and rejected an
unknown key. These checks do not cover COSI driver RPCs or establish the
original failed run's persisted IAM state.

The E2E run on 79f2cfe passed all 33 cases, including Kafka metadata
backup. It does not validate the image for this head.

The earlier human review threads are answered. The PR needs a fresh
review after this update.

### 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
feat(seaweedfs): bump the vendored SeaweedFS chart and the in-tree image to 4.48 and add opt-in Gateway API HTTPRoutes for the S3 endpoint and the filer (`s3.httpRoute`, `filer.httpRoute`, both disabled by default). Existing exposure does not change. Fix lost peer discovery during filer startup.
```



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

## Summary by CodeRabbit

* **New Features**
* Added configurable Gateway API HTTP routes for filer and S3 services.
* Added configurable labels for ingress resources and support for
combining global and component pod annotations.
* Added admin address configuration with authentication checks for
non-loopback bindings.
  * Updated SeaweedFS to version 4.48.
* **Bug Fixes**
  * Improved pod rollouts when master or S3 configuration changes.
  * Expanded read-only S3 credentials to allow listing.
  * Improved filer handling of peer updates during startup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:45:08 +03:00
Aleksei Sviridkin e86ef94185 feat(api, kubernetes, virtual-machine): declare tenant quota reservations on ApplicationDefinitions (#5349)
<!-- 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

Second phase of the accepted [tenant quotas as reservation
limits](https://github.com/cozystack/community/pull/48) design, after
the evaluator in #4983. An `ApplicationDefinition` can now declare what
an application of its kind reserves from its tenant's budget, as CEL
over its defaulted values, and the four IaaS kinds (`vm-instance`,
`vm-disk`, `kubernetes`, `kubernetes-nodes`) declare theirs. Nothing
reads the declarations yet: the usage oracle and the generalized
admission gate are the next phase, behind a flag.

- `fix(api)`: the evaluator could not sum quantities. The Kubernetes CEL
library returns a pointer from `add` and `sub`, which the evaluator did
not recognize, so any declaration summing components failed. Found while
writing the `kubernetes` declaration, which sums four control-plane
components.
- `fix(api)`: the evaluator refused exact products.
`resource.Quantity.Mul` returns false once the product leaves an int64
coefficient, not when it is wrong, so any fractional binary size above
about 8.5Gi (`20.5Gi × 3`) failed as an overflow.
- `fix(api)`: a null value stayed present wherever the schema had no
default to replace it, so `has()` saw a key Helm deletes, and evaluation
failed on a spec the chart renders.
- `feat(api)`: `spec.consumption` on `ApplicationDefinition` (`exempt`,
ordered `let` bindings, `resources` per quota key), owned as a whole so
that a binding and the expressions reading it are replaced together. The
evaluator's `Declaration` is now an alias of the API type. The CRD
rejects an exempt declaration that still carries expressions and a
non-exempt one that names no resource.
- `refactor(extra)`: ComputePlane's default `md0` pool now writes its
ceiling, instance type and disk size into its release instead of relying
on the pool chart's schema defaults, so the release alone says what the
pool can reserve. The rendered pool does not change.
- `feat(api, kubernetes, virtual-machine)`: the four declarations, each
following its chart's own precedence, plus a test that evaluates the
shipped declarations against the shipped instance types and preset
table, with the failures that must stay errors.

Validated locally: `go test ./pkg/reservation/` with each commit built
and tested on its own, `helm unittest` on computeplane and the touched
`-rd` charts, the four definitions plus three invalid ones validated
against the generated CRD schema and its CEL rules, and `make generate`
in the touched packages left the tree unchanged (with `cozyvalues-gen`
v1.7.0, the version CI pins).

Decisions worth a reviewer's look:

- **Proxmox worker pools reserve nothing.** Their VMs and disks run on
the external hypervisor, so they draw nothing from this cluster's
capacity. The `kubernetes` kind reserves one `services.loadbalancers` on
Proxmox, for its published apiserver Service, and one on KubeVirt when
the ingress addon is exposed by a load balancer, which the tenant
cluster's cloud controller realizes in the tenant namespace.
- **GPUs are not declared.** Their quota key is the device name
(`nvidia.com/<model>`), and `resources` keys are fixed strings.
Expressing them needs either a dynamic-key form in the declaration or a
class key for GPUs; I would rather settle that in its own change than
guess here. Until then the namespace `ResourceQuota` keeps bounding
them.
- **A spec the chart refuses to render is refused, not estimated.** A
partial `resources` block on a VM or a worker pool, a non-whole core
count or a memory below 1M fails the evaluation with the declaration's
reason, through a `fail(reason)` function the evaluator now offers, so
the gate in the next phase can answer with the same reason the render
would give.

Two decisions left for the next phase, both about what values alone
cannot see:

- A `vm-disk` whose `storage` is lowered keeps its larger volume,
because the chart only ever grows it, while its declaration reads the
lowered value. The admission gate has to refuse a storage decrease on
Update before it relies on this declaration.
- A worker pool's rollout runs one surge worker and its disk next to the
old ones (`maxUnavailable: 0` by default), which `maxReplicas` does not
cover. Whether that overlap counts against the tenant's budget or is
platform margin decides whether a tenant at its ceiling can roll a pool
at all.

Refs: cozystack/community#48

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

I walked the trigger map against the diff. Two repositories are
affected, and each has a follow-up issue:

- `cozystack/website`: the map lists "Change `ApplicationDefinition`
semantics". This adds a field nothing reads yet; documenting it seems
more useful once the gate in the next phase gives it an effect.
- `cozystack/external-apps-example`: the map lists changes to the
`ApplicationDefinition` CRD. The field is optional, so nothing breaks
there now, but the next phase refuses orders of a kind that declares
neither its consumption nor an exemption, so out-of-tree catalogs will
need a declaration before that phase is switched on.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#820
- [ ]
[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:
- [x]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up: cozystack/external-apps-example#6
- [ ] [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
feat(api, kubernetes, virtual-machine): ApplicationDefinitions can declare the tenant quota reservation of their kind, and the VM, disk, Kubernetes and worker pool kinds declare theirs. Nothing enforces the declarations yet.
```


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

## Summary by CodeRabbit

* **New Features**
* Application definitions can declare resource consumption for CPU,
memory, storage, and load balancers, with reservations based on
configured sizing and substrate choices.
* Kubernetes worker-pool reservations reflect replica counts, resource
overrides, instance types, and disk size; control-plane reservations
reflect component sizing and replica counts.
* VM instance and disk definitions report resource and storage
consumption.
* Default compute clusters now specify a node-pool limit of 10, an
instance type, and a disk size.
* **Validation**
* Invalid or incomplete resource sizing and consumption declarations now
produce errors, including mismatched CPU and memory settings.
Consumption declarations also enforce limits on resource entries and
bindings.
* **Bug Fixes**
* Null values are treated as absent when calculating reservations, and
quantity calculations support larger and fractional results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:16:14 +03:00
Aleksei Sviridkin 82f6cab63f feat(apps): per-app schedulingClass field for selective workload placement (#2622)
<!-- 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

Closes the per-application gap of the SchedulingClass system. Today a
SchedulingClass can only be attached to a `Tenant`, which propagates it
to every workload in the namespace through the namespace label. The
lineage webhook already prefers the owner Application's class over the
namespace label ("owner Application field takes priority, then fall back
to namespace label" in `applySchedulingClass`), but
`Application.SchedulingClass()` was a `TODO` that always returned `""`,
so that path was unreachable.

### Changes

1. `feat(api)`: `Application.SchedulingClass()` reads the top-level
`schedulingClass` key from `Spec.Raw`. A nil spec, an empty or missing
field, and invalid JSON all return `""`, so the webhook falls back to
the namespace class.
2. `feat(apps)`: every managed application whose pods go through the
webhook gets an optional `schedulingClass` field. Under
`packages/apps/`: bucket, clickhouse, foundationdb, harbor, kafka,
kubernetes, mariadb, mongodb, nats, openbao, opensearch, postgres,
qdrant, rabbitmq, redis, tcp-balancer, valkey, vm-disk, vm-instance,
vpn. Under `packages/extra/`: bootbox, etcd, external-dns, ingress,
monitoring, seaweedfs. Skipped: `tenant` (already has the field), `vpc`
and `info` (no pods), `gateway` (not an Application), `computeplane` (it
only wraps `kubernetes` and `kubernetes-nodes` releases), and
`kubernetes-nodes` itself, whose worker pods resolve to the parent
Kubernetes application, so a class set on a pool would be ignored.
3. `fix(apps)`: the field is capped at 63 characters (`maxLength: 63` in
the schemas, `+kubebuilder:validation:MaxLength=63` in the Go types),
because its value becomes a Pod label value while a SchedulingClass name
may be up to 253 characters. As defence in depth, `applySchedulingClass`
skips only the label when the resolved name is not a valid label value,
keeping `schedulerName` and the annotation, so a long-named class
degrades to annotation-only injection instead of having the apiserver
reject every Pod.
4. `test(lineage-webhook)`: covers the owner-Application path, which the
existing tests never exercised (they all pass a nil owner): the app
class overriding the namespace class, the fallback when the field is
absent, empty or the spec is missing, and the label guard for an
over-long name.
5. `feat(tenant)`: the tenant chart gains `allowedSchedulingClasses`,
empty by default, written to the
`namespace.cozystack.io/allowed-scheduling-classes` namespace
annotation. A parent tenant with a class or a non-empty list passes its
list down unchanged, so a child tenant cannot widen it.
6. `fix(lineage-webhook)`: an application class applies only when the
namespace allows it and the SchedulingClass exists. Otherwise the pod
keeps the tenant class, where it previously got no scheduler at all when
the named class did not exist.
7. `feat(api)`: a ValidatingAdmissionPolicy on `apps.cozystack.io`
(tenants excluded) refuses a `spec.schedulingClass` that is neither the
tenant's own class nor in its allowed list. An update that keeps the
class is not refused, so an application whose class was later removed
from the list stays editable; the webhook keeps its pods on the tenant
class.
8. `docs(apps)`: the field description names the tenant setting that
decides which classes are accepted.

### Precedence

The tenant class is the administrator's placement constraint, so an
application may replace it only with a class the tenant allows. The
administrator lists those classes in the tenant's
`allowedSchedulingClasses`, which is empty by default: per-application
placement stays off until it is enabled, and every application runs
under the tenant class. Naming the tenant's own class is accepted
without an entry, since it is the same as leaving the field empty. Any
other value is refused at admission, and the webhook enforces the same
rule at pod admission, falling back to the tenant class rather than
dropping it.

### Use case

The tenant administrator allows the class (`allowedSchedulingClasses:
[co-region-prod]` on the Tenant). Combined with the
`scheduler.cozystack.io/scheduling-class` Pod label added in #2621, a
class name can double as a co-affinity group:

```yaml
apiVersion: cozystack.io/v1alpha1
kind: SchedulingClass
metadata: { name: co-region-prod }
spec:
  podAffinity:
    requiredDuringSchedulingIgnoredDuringExecution:
    - labelSelector:
        matchLabels:
          scheduler.cozystack.io/scheduling-class: co-region-prod
      topologyKey: topology.kubernetes.io/region
---
apiVersion: apps.cozystack.io/v1alpha1
kind: Postgres
metadata: { name: db, namespace: tenant-acme }
spec:
  schedulingClass: co-region-prod
---
apiVersion: apps.cozystack.io/v1alpha1
kind: VMInstance
metadata: { name: app, namespace: tenant-acme }
spec:
  schedulingClass: co-region-prod
```

The Postgres pods and the virtual machine land in the same region,
without pinning a specific one.

### Out of scope

Placement per replica role (primary or standby of a clustered database).
The role is assigned by the operator after election, while the webhook
acts at pod creation, so the future primary is unknown at that point.

### Verification

- `go test ./pkg/apis/... ./pkg/registry/... ./pkg/cmd/server/...
./internal/lineagecontrollerwebhook/...` passes. The behavioural webhook
tests were checked against the reverted code: without the label guard,
with `SchedulingClass()` returning `""`, and with the previous
resolution that skipped injection for an unknown application class, each
fails.
- The admission policy's decisions are evaluated against the chart
template with the apiserver's CEL compiler
(`pkg/registry/apps/application/scheduling_class_policy_test.go`), and
on a lab cluster through the aggregated cozystack-api: a class outside
the list is refused, a listed class or the tenant's own class is
accepted, and an update that keeps a class removed from the list is
accepted while one that changes it is refused
(https://github.com/cozystack/cozystack/pull/2622#issuecomment-7042784997).
- The tenant chart's inheritance of the list is covered by
`packages/apps/tenant/tests/namespace_allowed_scheduling_classes_test.yaml`,
which fails when a child tenant may widen its parent's list.
- `make generate` at the root and in every touched package
(cozyvalues-gen v1.7.0, the CI pin) leaves no diff.
- `make helm-unit-tests` passes; `hack/check-rd-presets.sh` and
`hack/check-commit-trailers.sh` 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. -->

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.

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

Two repositories are reached by this diff. Both follow-ups are issues
rather than PRs, because each one only applies once this PR is merged:
`terraform-provider-cozystack` needs the field on every application it
models and `allowedSchedulingClasses` on the tenant, and `website` needs
the hand-written SchedulingClass guide to cover the per-application
field, the tenant's allowed list that gates it, and the Pod label.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#749
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#69
- [ ]
[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(apps): managed applications (bucket, clickhouse, foundationdb, harbor, kafka, kubernetes, mariadb, mongodb, nats, openbao, opensearch, postgres, qdrant, rabbitmq, redis, tcp-balancer, valkey, vm-disk, vm-instance, vpn, plus the bootbox, etcd, external-dns, ingress, monitoring and seaweedfs extras) accept a top-level `spec.schedulingClass` field, capped at 63 characters, which applies the named SchedulingClass to that application's pods in place of the tenant-level class. Only the tenant's own class or one listed in the tenant's new `allowedSchedulingClasses` (empty by default) is accepted; any other value is refused. This lets applications in the same tenant be co-located through a SchedulingClass podAffinity on the `scheduler.cozystack.io/scheduling-class` Pod label. An application whose class does not exist now keeps the tenant class instead of losing it.
```



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

## Summary by CodeRabbit

* **New Features**
* Added `schedulingClass` configuration across applications to select an
eligible scheduling class for newly created pods. Empty settings inherit
the tenant’s class; existing pods keep their assigned class until
recreated.
* Added tenant-level controls for which scheduling classes applications
may select. Invalid selections are rejected, and new pods fall back to
the tenant’s class if permission is removed.
* Added scheduling-class settings to application configuration displays.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:15:08 +03:00
Aleksei Sviridkin f5ceed0e24 feat(linstor, platform): upgrade snapshot-controller to v8.7.0 and enable VolumeGroupSnapshots (#5239)
## What this PR does

Windows VMs with three or more disks cannot get an
application-consistent Velero backup on Cozystack today. Velero takes
one CSI snapshot per PVC, one after the other, while virt-freezer holds
the guest frozen, and on LINSTOR each snapshot takes 2 to 4 s. With
three disks or more the freeze runs past the 10 s that Windows VSS
allows, VSS aborts with `0x80042314`, and the backup fails. The only
workaround is `kubevirt.io/skip-backup-hooks=true` on the VM, which
gives up application consistency.

The fix is a VolumeGroupSnapshot: one snapshot request for all the PVCs
of a VM, taken inside the freeze. linstor-csi has implemented the CSI
GroupController since v1.11 (the package ships v1.11.2), and it creates
the whole group in a single LINSTOR `Resources.CreateSnapshots` call, so
every volume of the VM is captured at the same instant and the freeze
lasts one snapshot instead of N. Velero 1.18 drives VolumeGroupSnapshots
through `groupsnapshot.storage.k8s.io/v1beta2`. What is missing is on
the Cozystack side: snapshot-controller v8.0.1 serves the group snapshot
API only as v1alpha1 and runs without the `CSIVolumeGroupSnapshot` gate,
and piraeus-operator turns the gate off on the csi-snapshotter sidecar
when it does not find v1beta2.

This PR:

- Upgrades the vendored Piraeus `snapshot-controller` chart from 3.0.5
(v8.0.1) to 5.4.0 (v8.7.0) with the package's `make update`. The
`snapshot.storage.k8s.io` CRDs stay at v1. The
`groupsnapshot.storage.k8s.io` CRDs go from v1alpha1 only to v1beta1,
v1beta2 and v1, with v1beta2 as the storage version. The controller runs
with `--feature-gates=CSIVolumeGroupSnapshot=true`, the chart's default.
The validating webhook is gone upstream, replaced by CEL rules in the
CRDs. The new optional conversion webhook stays disabled, as upstream
ships it, since no cluster holds group snapshot objects to convert.
- Sets `keepCRDs: true`. The chart now renders its CRDs from a template
instead of `crds/`, so without it an uninstall of the release would
delete every VolumeSnapshot with the CRDs.
- Patches the vendored CRD template (`patches/skip-foreign-crds.diff`,
applied by `make update`) so a CRD is rendered only when it is absent or
already carries this release's `meta.helm.sh/release-name` and
`meta.helm.sh/release-namespace`. A CRD a distribution ships, or that
another release owns, stays out of the manifest, so helm-controller
neither takes it over nor rewrites it on upgrade. On a fresh install,
and for the CRDs migration 62 adopts, the output is unchanged.
- Adds migration 62 and bumps `migrations.targetVersion` to 63
(renumbered from 61 after upstream took migration 61 for the Strimzi v1
conversion). The CRDs `crds/` created carry no Helm ownership metadata,
and the patched chart renders only the CRDs that do, so the migration
annotates the three `snapshot.storage.k8s.io` CRDs the release installed
for adoption, which keeps them in its manifest. The three group snapshot
CRDs cannot be adopted: the apiserver rejects an update that drops
v1alpha1 while it is listed in `status.storedVersions`. The old
controller never ran with the gate, so no v1alpha1 object was ever acted
on, and the migration deletes each of these CRDs when it is empty and
creates it again straight away at v1beta2, from copies `make
image-migrations` renders out of the snapshot-controller chart with the
release's ownership metadata (as it already bakes the etcd-operator CRDs
for migration 50). Every HelmRelease waits for this pre-upgrade hook, so
the linstor release renders against the v1beta2 API even when it
upgrades before snapshot-controller. A CRD that still holds objects is
kept and recorded on the `cozystack-version` ConfigMap as
`cozystack.io/migration-62-needs-attention`, and the CRD stays out of
the release, which carries no Helm ownership on it, so
snapshot-controller still upgrades with that group snapshot API at
v1alpha1 and group snapshots off. Nothing re-renders either release once
the CRD is cleaned up, so the migration's warning gives the whole
recovery: delete the objects and the CRD, force a snapshot-controller
HelmRelease upgrade so the chart creates the CRD at v1beta2, restart the
snapshot-controller Deployment, which sets up its group snapshot watches
only when it starts, then force a linstor HelmRelease upgrade. The
migration only touches CRDs that helm-controller labelled as installed
by `cozy-snapshot-controller/snapshot-controller`, and the chart leaves
the others out of the release, so a distribution that ships its own
snapshot CRDs keeps them in both places. Whether the release is
installed is read from its HelmRelease rather than from those labels, so
a retry after a failed create still recreates the group CRDs it deleted
when only they carried the labels; without the HelmRelease the migration
changes nothing. The version is stamped only once every release-owned
v1beta2 group snapshot CRD is Established, whichever path brought it
there, so a retry after a timed-out wait waits again rather than letting
linstor render before the API is served.
- Sets `FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT=true` on the linstor-csi
`csi-snapshotter` sidecar through the LinstorCluster pod template.
piraeus-operator v2.10.2 probes for the v1beta2 API once, when it
starts, and adds a patch that sets the variable to `false` when the
probe fails. On a cluster upgraded from v1alpha1 the operator started
before the new CRDs existed, so the gate would stay off until the
operator next restarted. The pod template is merged after the operator's
own patch. The variable is always set, to `true` only when the apiserver
serves all three `groupsnapshot.storage.k8s.io/v1beta2` kinds and to
`false` otherwise: the operator's probe looks at VolumeGroupSnapshot
alone, and csi-snapshotter with the gate on and a group API missing
waits for its group snapshot caches before it starts the ordinary
snapshot workers. The class below renders under the same check.
- Adds a default `VolumeGroupSnapshotClass` `linstor-group-snapshots`
for `linstor.csi.linbit.com`, next to the existing `linstor-snapshots`
VolumeSnapshotClass, with the `velero.io/csi-volumegroupsnapshot-class:
"true"` label Velero selects a group snapshot class by. Only on a
cluster where migration 62 kept a populated v1alpha1 CRD do they wait
for the forced linstor upgrade at the end of that recovery.

Not in this PR: grouping a VM's PVCs for Velero. Velero builds a group
from the PVCs that share the value of the `velero.io/volume-group`
label, so the `vm-instance` and `vm-disk` charts would have to set it to
the VM name on every disk. That is a separate change, and an operator
can set the label by hand meanwhile.

Testing:

- Kubernetes v1.34.3, Velero 1.18.1, linstor-csi v1.11.2,
piraeus-operator v2.10.2. On that cluster the group snapshot CRDs are
v1alpha1 only, list `["v1alpha1"]` in `storedVersions`, hold no object,
and carry the helm-controller labels of
`cozy-snapshot-controller/snapshot-controller`. The csi-snapshotter
sidecar runs with `FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT=false`, set by
the operator's patch.
- `hack/migration-62-snapshot-crds.bats` (16 cases) runs migration 62 in
the migrations base image against a fake kubectl that keeps the CRDs in
a state file: adoption and deletion, a second run that changes nothing,
a CRD holding objects, CRDs another installer owns, CRDs that already
serve v1beta2, a cluster without the release, a release without the
group CRDs, a failing HelmRelease read, CRD read or delete that aborts
before the stamp, a failed diagnostic record that still stamps, a failed
create that aborts and is completed by the retry, release labels on the
group CRDs alone, with and without a failed first create, a timed-out
Established wait whose retry must wait again before stamping, and a
v1beta2 CRD that still stores v1alpha1, which is recorded rather than
adopted. With the delete removed from the migration, the first case
fails; with the release identity taken from the CRD labels instead of
the HelmRelease, the failed-create case with group-only labels stamps 63
without recreating the CRDs and fails. Without the wait on the adoption
path, the timed-out-wait case stamps 63 on the retry without waiting and
fails.
- New helm-unittest suites:
`packages/system/snapshot-controller/tests/crds_test.yaml` pins
`keepCRDs`, v1beta2 served and stored on the three group snapshot CRDs
and the controller gate;
`packages/system/snapshot-controller/tests/crd_ownership_test.yaml`
mocks the live CRDs and checks that one without Helm ownership and one
owned by another release are left out while an absent one and one this
release owns are rendered (it fails with the patch reverted);
`packages/system/linstor/tests/volume_group_snapshot_test.yaml` pins the
sidecar gate on with and without strict topology, off when only
VolumeGroupSnapshot or no group API is served, and the
VolumeGroupSnapshotClass rendered only when the v1beta2 API is served.
`csi-topology_test.yaml` now counts the `csi-snapshotter` entry in the
pod template.
- `helm unittest` passes for `packages/system/linstor` (30 tests),
`packages/system/snapshot-controller` (7) and `packages/core/platform`
(285). `hack/cozystack-version-stamp.bats` and
`hack/check-migrations-target.sh` pass.
- Not yet run end to end: the upgrade of a live cluster through
migration 62, and a Velero backup with a VolumeGroupSnapshot through
linstor-csi.

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

The only change to `packages/core/platform/values.yaml` is the value of
`migrations.targetVersion`. The website's `platform-package.md` lists
that key without a value, so it needs no change. No website page
mentions VolumeGroupSnapshots or documents the snapshot-controller
webhook. The rest of the diff is a vendored chart, two system packages,
a migration and its tests, none of which the trigger map reaches.

### Release note

```release-note
feat(platform): snapshot-controller is upgraded to v8.7.0 and serves VolumeGroupSnapshots as groupsnapshot.storage.k8s.io/v1beta2, and linstor-csi takes group snapshots with a default VolumeGroupSnapshotClass labelled for Velero. A platform migration hands the snapshot CRDs over to the release and removes the empty v1alpha1 group snapshot CRDs.
```


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

## Summary by CodeRabbit

* **New Features**
* Added LINSTOR volume group snapshot support when all required APIs are
available, including a default snapshot class.
* Updated the snapshot controller to support newer snapshot APIs and a
conversion webhook.
* Added safer CRD installation and upgrade handling, preserving CRDs
with existing objects and recording items that need attention.

* **Bug Fixes**
* Improved snapshot-controller upgrade reliability, including recovery
from certain CRD creation failures.

* **Documentation**
* Updated chart guidance for CRD management, conversion webhooks, and
snapshot class configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:12:46 +03:00
Aleksei Sviridkin f6bccbe23f feat(platform): make the Keycloak public host configurable (#5112)
<!-- 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

The Keycloak chart already accepts `ingress.host`, but every OIDC
consumer rebuilds the issuer as
`https://keycloak.<root-host>/realms/<realm>` on its own: the dashboard
and linstor-gui gatekeepers (`--oidc-issuer-url`, `--login-url`,
`--whitelist-domain`, external logout URL), Grafana SSO (`auth_url`,
`token_url`, `api_url`), the info kubeconfig (`--oidc-issuer-url`) and
tenant Kubernetes clusters in `oidc.mode: System`
(AuthenticationConfiguration issuer). Serving Keycloak on any other
hostname (for example `auth.example.org`) therefore changes the `iss` of
every token while those consumers keep expecting the old one, and SSO
breaks across the platform.

This adds `authentication.oidc.keycloakHost` to the platform values. The
platform resolves it once (empty means `keycloak.<root-host>`),
validates it as a bare lowercase hostname (no scheme, port or path,
since it is spliced into URLs and `--whitelist-domain`), and publishes
it as `_cluster.keycloak-host`. The Keycloak chart (Ingress, HTTPRoute,
`KC_HOSTNAME`) and the five consumers read that key, each falling back
to `keycloak.<root-host>` when it is absent so a chart rendered without
the platform Secret behaves as before. `ingress.host` on the Keycloak
chart keeps working and still wins, and its comment now points at the
platform value.

Existing clusters render unchanged: with `keycloakHost` empty, every URL
is byte-identical to today's. Changing the value on a live cluster is an
issuer change, so sessions and refresh tokens minted under the old host
stop being accepted and the management apiserver (configured out of band
via talm `oidcIssuerUrl`) must trust the new issuer first; the values
comment says so.

Tests: one new suite each for the platform wiring and validation and for
the Keycloak chart, plus a custom-host case in the dashboard,
linstor-gui, info, monitoring and kubernetes suites. Reverting the
templates makes every new case fail; `helm unittest` passes on all seven
touched charts.

### 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
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/issues/778 (issue rather
than PR: the table row should land once this PR 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:

### 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
feat(platform): add authentication.oidc.keycloakHost to serve Keycloak on a custom public hostname; the Keycloak Ingress, KC_HOSTNAME, the dashboard and linstor-gui gatekeepers, Grafana SSO, the info kubeconfig and tenant Kubernetes clusters in oidc.mode System all follow it. Empty keeps keycloak.<root-host>.
```


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

## Summary by CodeRabbit

* **New Features**
* Added an optional public Keycloak hostname, defaulting to
`keycloak.<cluster-root-domain>` when unset.
* The configured hostname is used for Keycloak access, OIDC issuer and
login URLs, and related browser-facing authentication settings across
supported services and kubeconfig.
* Existing Keycloak hostname overrides remain supported when compatible
with the platform hostname.
* **Bug Fixes**
* Invalid configured hostnames—including values with schemes, paths,
ports, or invalid DNS lengths—and conflicting explicit Keycloak and
platform hostnames now prevent rendering.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:09:00 +03:00
Aleksei Sviridkin 2acba8bf60 fix(linstor): roll affinity controller and scheduler on client cert rotation (#5160)
<!-- 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

`linstor-affinity-controller` and the `linstor-scheduler` extender read
their LINSTOR API client certificate from `secretKeyRef` env vars, which
kubelet resolves only when the container starts. cert-manager renews
these 90-day certificates every 60 days, but neither workload is
restarted on rotation, so a pod that outlives its certificate keeps
presenting the expired one. The controller refuses every new TLS
handshake and the Go client logs a bare `Get
"https://linstor-controller:3371/v1/resource-definitions?": EOF`, while
the CLI inside the controller pod keeps working, which makes it look
like an API problem.

Observed on a production cluster: an affinity controller pod running for
91 days failed every 15 s from 25 minutes after its certificate expired
(an existing keep-alive connection survived until then), so PV node
affinities stopped following replica moves. One of the two scheduler
replicas had been failing silently for 19 days for the same reason; it
was not the leader, so scheduling was not hit yet, but a lease failover
would have handed scheduling to an extender that cannot reach LINSTOR.

Changes:

- `packages/system/linstor/templates/cluster.yaml`: add the
`reloader.stakater.com/auto` patch for
`Deployment/linstor-affinity-controller`, like the existing ones for
`linstor-controller`, `linstor-csi-controller` and `linstor-csi-node`.
- `packages/system/linstor-scheduler`: annotate the scheduler
`Deployment` with `secret.reloader.stakater.com/reload:
<linstor.clientSecret>`, carried as a third edit in the existing
`patches/cozystack-scheduler-deployment.patch` so `make update` keeps
it. `podAnnotations` would have been enough for Reloader v1.3.0, which
falls back to pod-template annotations, but the vendored chart applies
`podAnnotations` to the admission `Deployment` too, which would roll on
a secret it does not use.
- Regression tests: `linstor/tests/reloader_test.yaml` and
`linstor-scheduler/tests/deployment_test.yaml`. Both fail with the fix
reverted and pass with it. The patch was checked to apply with `patch
-p4` on the pristine 0.3.1 chart and to reproduce the vendored template
byte for byte.

The existing `admission.reloadOnCertChange: false` comment is left as
is: it is about the webhook's serving certificate, which the extender
reloads on its own, not about the LINSTOR client certificate.

### Screenshots

No UI change.

<!-- 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
fix(linstor): linstor-affinity-controller and linstor-scheduler now restart when their LINSTOR client certificate is rotated, instead of failing every LINSTOR API call with EOF once the certificate they loaded at startup expires.
```


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

## Summary by CodeRabbit

* **New Features**
* LINSTOR controller, CSI, and affinity-controller deployments now
support automatic reloading.
* Scheduler deployments reload when their configured client Secret
changes, including when a custom Secret name is used.
* Scheduler deployments now identify their component and use a
Kubernetes-version-aware default image tag.
* **Bug Fixes**
* Scheduler Secret references and reload behavior remain aligned when
the client Secret name is overridden.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:07:29 +03:00
Aleksei Sviridkin 9ca20d00f7 feat(monitoring, kubernetes): add destinations to the monitoring agents without replacing the defaults (#5376)
<!-- 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

To send a copy of metrics or logs to a store of their own, a user today
has to override `vmagent.remoteWrite.urls` or
`fluent-bit.config.outputs`. Both are replaced wholesale on merge, so
the override must restate the platform's own destinations; one that does
not silently cuts the tenant's VictoriaMetrics and VictoriaLogs off,
with the application still `Ready`. A plain URL list cannot carry
credentials either.

This adds two keys to the monitoring-agents chart, appended after the
defaults instead of replacing them:

- `vmagent.extraRemoteWrite`: VMAgent `remoteWrite` entries passed as
is, so an entry can carry `basicAuth`, `bearerTokenSecret`, `headers` or
`tlsConfig`.
- `fluent-bit.config.extraOutputs`: `[OUTPUT]` sections appended by the
outputs template.

On a managed Kubernetes cluster both are set through
`addons.monitoringAgents.valuesOverride`, for example:

```yaml
addons:
  monitoringAgents:
    enabled: true
    valuesOverride:
      vmagent:
        extraRemoteWrite:
          - url: https://metrics.example.org/api/v1/write
            basicAuth:
              username: {name: remote-write-auth, key: username}
              password: {name: remote-write-auth, key: password}
      fluent-bit:
        config:
          extraOutputs: |
            [OUTPUT]
                Name http
                Match kube.*
                Host logs.example.org
                port 443
                tls On
```

`extraOutputs` is appended by a hook at the end of the default
`outputs`, because the vendored fluent-bit chart builds
`fluent-bit.conf` from `outputs` alone. Overriding `outputs` therefore
means keeping that hook (`{{- with .Values.config.extraOutputs }}` / `{{
. }}` / `{{- end }}`) or moving the extra destinations into `outputs`
itself. Setting `extraOutputs` together with an `outputs` override that
lacks the hook fails the render, in the system chart and in the tenant
HelmRelease template, instead of dropping the destinations in silence.

Depends on #5375, which makes the app apply `valuesOverride` at all; its
commit is the first one here and drops out once it merges. The commits
after it belong to this PR.

With neither key set, both the system chart render and the tenant render
(the app's HelmRelease values fed into the system chart) are
byte-identical to before. The example above was rendered end to end: the
tenant's VMAgent gets its own vminsert plus the extra entry with its
credentials, and `fluent-bit.conf` gets the tenant's vlinsert output
followed by the extra one.

Open point for reviewers: the tenant outputs carry the hook as escaped
template text, because the app chart renders that string before the
fluent-bit subchart renders it again. The alternative was appending at
app render time from `valuesOverride`, which would leave root and tenant
installs with two different mechanisms for the same key.

### 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
feat(monitoring): the monitoring agents accept `vmagent.extraRemoteWrite` and `fluent-bit.config.extraOutputs` to send metrics and logs to additional destinations without replacing the default ones; on managed Kubernetes clusters they are set through `addons.monitoringAgents.valuesOverride`.
```


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

## Summary by CodeRabbit

* **New Features**
* Monitoring agents can send metrics to additional remote-write
destinations, including destinations that use Basic Auth.
* Fluent Bit can include custom output sections alongside its default
outputs.
* Monitoring-agent value overrides can customize selected settings while
retaining other default configuration.
* **Bug Fixes**
* Rendering now reports an error when custom Fluent Bit outputs omit the
required hook while extra outputs are configured. Retaining the hook
allows default and custom destinations to be rendered.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 14:01:23 +03:00
Aleksei Sviridkin 4190aa82f5 fix(seaweedfs): point the Lance catalog consumers at the renamed s3 Service (#5356)
## What this PR does

Closes #4878

`s3-service-name.patch` renames the S3 Service to `<name>-s3`. The Lance
catalog came with chart 4.45, and its two consumers still build the name
with `seaweedfs.componentName`, which gives `<fullname>-s3`:

- the Lance ingress backend (`templates/s3/s3-lance-ingress.yaml`)
- the Lance namespace URL the worker gets
(`seaweedfs.worker.lanceNamespaceUrl` in
`templates/shared/_helpers.tpl`)

Changes:
- Both places now use the `<name>-s3` form that the S3, Iceberg and COSI
consumers already use. The ingress uses `{{ template "seaweedfs.name" .
}}-s3` like the Iceberg ingress, and the URL uses `printf "%s-s3"
(include "seaweedfs.name" .)`.
- The two hunks are appended to
`patches/s3-service-name-consumers.patch`, so `make update` keeps them.
- Two cases are added to `tests/s3_service_name_consumers_test.yaml`.
They set a non-zero `lancePort` and `fullnameOverride:
seaweedfs-system`, like the existing cases do.

Nothing changes with the shipped values. `lancePort: 0` keeps both
consumers from rendering, and `fullnameOverride: seaweedfs` makes both
names equal anyway.

### How I checked it

- `helm unittest .` in `packages/system/seaweedfs`: 23 suites and 135
tests pass. With the template changes reverted, the two new cases fail
and the rest still pass.
- `make test-guard-fail-closed` passes.
- I reversed the full patch chain from the `update` target on a copy of
`charts/`, newest first, then applied it forward again. Every patch
applied cleanly, and the result matched the committed `charts/` exactly.
- I couldn't run `make test-image-version` locally because `yq` isn't
installed here. This PR doesn't touch the Dockerfile or the chart
version.

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

This touches only a vendored chart patch and its tests under
`packages/system/seaweedfs`. Nothing in the trigger map of
`docs/agents/contributing.md` applies.

### Release note

```release-note
fix(seaweedfs): the Lance catalog ingress and the worker's Lance namespace URL now point at the renamed `<name>-s3` Service.
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* Corrected S3 service names used by ingress routes, worker namespace
URLs, and COSI endpoint URLs to consistently use the release name.
* COSI endpoint URLs now use the configured S3 port, including when
using the fallback S3 configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 13:59:37 +03:00
Aleksei Sviridkin 39f3f73fbc fix(postgres): keep users.app's password across pod restarts (#4984)
## What this PR does

A Postgres app that declares a user named `app` loses that user's
password every time its pod restarts. Clients keep the password
advertised in `<release>-credentials` and start failing with `password
authentication failed for user "app"`, with nothing changed on their
side.

`app` is the owner role CNPG bootstraps, with a generated password in
`<release>-app`, and a declared `users.app` adopts that role (the
init-script says so). The init-job sets the role's password from
`<release>-credentials`, but CNPG's instance manager re-applies the
owner's password from the bootstrap secret whenever it meets a secret
version it has not applied yet (`refreshCredentialsFromSecret` →
`reconcileUser` in
`internal/management/controller/instance_controller.go`). Its cache is
in memory, so every pod start re-applies `<release>-app` and silently
undoes the init-job. Only releases whose two secrets happen to differ
break, which is every release where `users.app` was declared at
creation.

This PR renders a `<release>-app-owner` basic-auth Secret from the same
password `<release>-credentials` holds, and sets
`spec.bootstrap.<method>.secret.name` to it, so both writers agree on
one value. CNPG resolves the owner secret through that field before
falling back to `<release>-app`, never rewrites the data of a secret it
does not own, and its webhook accepts a bootstrap change on an existing
Cluster. The secret goes on the method the live Cluster was bootstrapped
with, read through `lookup`, because CNPG rejects two methods and a
restored Cluster keeps `bootstrap.recovery` in its live spec. A release
with no `users.app` renders exactly what it rendered before, and a
restore in progress (`bootstrap.enabled`) is left alone, since the chart
flags its credentials as pending until the init-job runs.

We hit this in production: the cluster-wide pod restart of a platform
upgrade broke two of the four apps that declare `users.app`; the two
others survived only because their two secrets held the same value.

`tests/app_owner_secret_test.yaml` covers the shared password (preserved
and freshly generated), the initdb and recovery methods, a release
without `users.app`, and an in-progress restore. Without the template
change, 5 of its 8 tests fail. The full chart suite passes (217 tests).

### Screenshots

Not a UI change.

### Downstream repositories

Walked against the diff: two templates and one test file under
`packages/apps/postgres`. No package is added or renamed, `values.yaml`,
`values.schema.json` and `README.md` are untouched, and no output Secret
or Service is renamed (a new Secret is added; the Terraform provider
reads only `-credentials`, `-rw` and `-ro`).

- [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(postgres): a user named `app` no longer loses its password when the Postgres pod restarts. CNPG re-applied its own generated password to the `app` owner role on every pod start; the chart now hands CNPG the password stored in `<release>-credentials`.
```


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

## Summary by CodeRabbit

- **New Features**
  - Added owner credentials when the `app` user is configured.
- PostgreSQL clusters now use those credentials during initialization or
recovery, while preserving compatible recovery settings for restored and
actively recovering clusters.

- **Bug Fixes**
- Ensured generated or existing `app` passwords are reused for owner
credentials.

- **Tests**
- Added coverage for credential reuse, password generation, omitted-user
behavior, and cluster recovery scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 13:39:43 +03:00
Aleksei Sviridkin afa3dfa224 feat(virtual-machine): group a VM's claims for Velero volume group snapshots (#5240)
<!-- 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

An application-consistent Velero backup of a VM freezes the guest,
snapshots its PVCs one after another, then thaws it. Windows holds a VSS
freeze for 10 seconds at most, and on LINSTOR each CSI snapshot takes
about 4 seconds. So a Windows VM with three volumes (system disk, data
disk and the `persistent-state-for-*` claim KubeVirt keeps for TPM/EFI
state) overruns the window: `virt-freezer --unfreeze` fails with
`VSS_E_HOLD_WRITES_TIMEOUT` and the backup is only crash-consistent.
Velero 1.18 snapshots the PVCs that share a `velero.io/volume-group`
value as one VolumeGroupSnapshot, which linstor-csi takes as a single
atomic snapshot.

This adds a `post-install,post-upgrade` hook to `vm-instance` that
labels every claim of the VM with `velero.io/volume-group:
<VirtualMachine name>`. That covers the `vm-disk-<name>` claim of each
disk in `disks`, and the claims KubeVirt labels `persistent-state-for:
<VirtualMachine name>`. The hook also removes the label from claims
still carrying this VM's group once they no longer belong to it (a
detached disk, or a group that can no longer form). A claim grouped
under another VM is left alone.

A `vm-disk-<name>` claim belongs to the `vm-disk` release and outlives
the VM, and the hook leaves out a claim grouped under another VM's name,
so a disk reattached to a replacement VM would otherwise keep its old
group for good. A `pre-delete` hook therefore removes this VM's group
from every claim still carrying it when the release is uninstalled. Helm
runs uninstall hooks from the stored manifest, so that hook is rendered
unconditionally, and it selects the claims at run time with `-l
velero.io/volume-group=<VM>` rather than from a render-time list that
would be stale by then. Its Role needs `list` on the namespace's claims
for that; the removal is the same JSON `test`+`remove` patch, so a claim
another VM grouped in the meantime keeps its group.

Why a hook and not a label in the charts' own manifests:

- CDI copies DataVolume labels to the PVC only when it creates it
(`newPersistentVolumeClaim` in
`pkg/controller/datavolume/controller-base.go`, v1.66.1), so a label
added to an existing VMDisk's DataVolume never reaches its claim.
- A VMDisk is created, and its PVC with it, before any VMInstance names
it, so `vm-disk` cannot know the VM at that point; the disk-to-VM
mapping only exists in `vm-instance` values. `vm-disk` is therefore
unchanged.
- KubeVirt creates the persistent-state PVC with a fixed label set
(`createPVC` in `pkg/storage/backend-storage/backend-storage.go`,
v1.9.0); nothing on the VM or VMI spec adds labels to it.

Velero 1.18.1 has no fallback for a labelled claim it cannot group
(`getVolumeSnapshotReference` in
`pkg/backup/actions/csi/pvc_action.go`). Any of these fails the claim's
backup: an unbound member, two CSI drivers in the group, or anything
other than exactly one VolumeGroupSnapshotClass labelled
`velero.io/csi-volumegroupsnapshot-class: "true"` for the driver. The
hook therefore forms the group only when all of these hold, and removes
the label otherwise:

- the claims are bound and use a single CSI driver;
- at least two of them exist;
- `groupsnapshot.storage.k8s.io/v1beta2` is served;
- exactly one default class serves that driver.

On a cluster without group snapshot support the hook does not render.
That is every cluster on current `main`, which runs snapshot-controller
v8.0.1 with v1alpha1 CRDs. A companion change upgrades
snapshot-controller to v8.7.0, enables the `CSIVolumeGroupSnapshot` gate
on linstor-csi and adds a default VolumeGroupSnapshotClass. This PR does
nothing until something like it lands.

The hook is gated on render-time lookups like `vm-update-hook.yaml`, so
a converged VM renders no Job, and its Role is limited by
`resourceNames` to the claims it patches. Existing VMs are picked up on
their next Helm upgrade, which a Cozystack upgrade that bumps the chart
triggers.

Known limit: the hook labels only the claims the render saw. A
persistent-state claim created after it stays unlabelled until the next
upgrade. That happens on the first boot of a new VM, and on every live
migration, where KubeVirt creates a new RWO claim. Such a claim is
snapshotted on its own, next to one group snapshot of the disks: two
snapshot operations, which still fit the freeze window, as two-volume
VMs show today. Closing that gap needs something that sees every PVC
creation. The lineage webhook is a candidate: it already mutates PVCs on
create and walks the owner graph to the VMInstance. That is left for a
follow-up.

`tests/instancetype_resources_test.yaml` rendered every template, and
the fake client of helm-unittest refuses a list lookup for a kind it
does not register. That suite is therefore scoped to `vm.yaml` and
`vm-update-hook.yaml`, the two templates it covers.
`tests/volume_group_hook_test.yaml` covers labelling, convergence, label
removal, the Job's security context and each gate: API not served, no
default class, two default classes, two drivers, an unbound claim, a
single claim. Each gate was checked to fail its test when removed.

`tests/volume_group_release_hook_test.yaml` pins the uninstall hook's
manifest, and `hack/vm-volume-group-release-hook.bats` runs its script
against a fake kubectl: every claim the VM grouped is released, a
detached disk included, another VM's claim is untouched, a claim
regrouped or deleted between the list and the patch does not fail the
uninstall, and a failed list or a patch that leaves the label in place
does. `tests/volume_group_hook_test.yaml` also covers a differently
named VM grouping the released disks.


### 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
feat(virtual-machine): label every PVC of a VMInstance with velero.io/volume-group, so Velero snapshots them as one VolumeGroupSnapshot when the cluster serves groupsnapshot v1beta2 with a default VolumeGroupSnapshotClass for their CSI driver.
```


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

## Summary by CodeRabbit

* **New Features**
* VM disk and persistent-state volumes can now be grouped for snapshots
when the storage provider and snapshot configuration support it.
* Volume grouping is updated automatically as claims change; ineligible
volumes are excluded, and claims assigned to another VM are left
unchanged.
* Grouping is applied only when multiple bound volumes share a supported
storage driver and a matching default snapshot class is available.
* Volumes no longer eligible for the VM’s group are ungrouped, and
missing volumes are safely skipped.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 13:26:04 +03:00
Andrei Kvapil 9680ed64df feat(cluster-api)!: update Cluster API to v1.14.4 (#4902)
<!-- 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.
- Breaking changes: append `!` after type/scope or add a `BREAKING
CHANGE:` footer.
- If it is a work in progress, consider creating this PR as a draft.
- Ask for opinion and review in the community chats when needed.
- Fixes merged to main reach supported release lines through the
backport batch automatically. Do not open backport PRs by hand.
-->

## What this PR does

Updates the Cluster API stack with an automatic intermediate upgrade for
existing v1.10 providers.

The core chart upgrades them through v1.13.8 before Helm applies the
final manifests. The hook fails on API errors, conflicting changes or
timeouts. The hook image goes through cozy-lib. The core chart's
PackageSource declares that library, otherwise the packaged chart can't
render the hook. Fresh installations skip the intermediate providers.
Helm keeps the intermediate ConfigMaps, so they stay in the cluster
after the next change of the intermediate version, and that bump has to
remove them.

Each provider now selects exactly one repository. The bridge and final
ConfigMaps carry `provider.cluster.x-k8s.io/version` with the full
version, including the role suffix, and the core and kubeadm selectors
include it. The operator's finalize step hashes every ConfigMap the
selector matches and rejects more than one. During an upgrade it also
checks the selector of every other installed provider. So the bridge
ConfigMaps carry only the version label, and the v1.10 selectors, which
have no version, never match them. The hook switches the version and the
selector in one guarded patch and selects a bridge by that label alone.
It also narrows an existing bridge selector to that label. A provider
whose first installation never finished takes the fresh-install path.

Kamaji, CAPK, capmox and IPAM keep their existing pins and temporary
v1beta1 compatibility. The autoscaler keeps its explicit v1beta1
selection. An infrastructure provider's v1beta1 `failureReason` no
longer immediately fails a Machine or triggers remediation. The provider
conditions still show the cause.

The vendored operator chart gets six local patches, and `make update`
reapplies them. The core components get a startup probe patch. The
sync-period patch from main stays. I kept the one-minute resync setting
until restart recovery is tested.

CAPI Bats, the bootstrap and platform Helm suites and the rendering
checks pass locally. On envtest against cluster-api-operator v0.30.0,
legacy v1.10 core and kubeadm providers go through v1.13.8 to v1.14.4
with these ConfigMaps. With the old bridge labels core stayed on v1.10.
I have not run a live upgrade, restart or eviction test on this
revision. The [earlier Proxmox
report](https://github.com/cozystack/cozystack/pull/4902#pullrequestreview-5510737333)
covers the v1.13 candidate only.

### 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
automatically. Check the trigger map in docs/agents/contributing.md
against the diff. Keep every checkbox. Tick an affected repository only
after linking an existing or newly opened follow-up. Do not claim no
downstream impact when it is unknown. -->

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#751
- [ ]
[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 existing website follow-up needs the management-cluster minimum
updated to v1.33. No tenant API fields, version enums, installer values
or platform variants change.

### Release note

```release-note
feat(cluster-api)!: update Cluster API core and kubeadm bootstrap to v1.14.4, cluster-api-operator to v0.30.0 and Talos bootstrap to v0.6.13. Legacy core and kubeadm installations are upgraded through v1.13.8 before the final manifests are applied. The core and kubeadm bootstrap charts reject management Kubernetes older than v1.33. The upgrade is one-way: Cluster and Machine CRDs use v1beta2 storage and downgrades are not supported. The preferred Cluster API version becomes v1beta2. Clients relying on v1beta1 fields must select that version explicitly. The operator no longer serves operator.cluster.x-k8s.io/v1alpha1. The autoscaler stays on the v1beta1 Cluster API.
```
2026-11-23 11:00:48 +01:00
Timofei Larkin 5daa04ea6e feat(networking): cozyplane eBPF CNI + cozyplane-kpr networking variant (drops Cilium) (#3149)
## What this PR does

Adds an **opt-in** `bundles.system.networkingVariant: "cozyplane"` for
the `isp-full` (Talos) bundle: it replaces kube-ovn, Cilium and
kube-proxy with the [cozyplane](https://github.com/lllamnyp/cozyplane)
eBPF CNI, its aggregated `sdn.cozystack.io` API server, and the
`cozyplane-kpr` socket-LB kube-proxy replacement. The default
`kubeovn-cilium` path renders identically to main; the selector is
refused outright on every other bundle variant (slim variants included),
where it would half-apply.

Components: three wrapper charts around cozyplane's upstream charts —
the CNI (`packages/system/cozyplane`), the kube-proxy replacement
(`cozyplane-kpr`) and the aggregated apiserver with its
etcd-operator-managed, PVC-backed etcd (`cozyplane-apiserver`) — plus
the Cilium policy CRDs shipped inert so stock charts install
(`cozyplane-cilium-crds`), a `cozystackAPI.serveSDN` toggle in
cozystack-api, and the platform wiring. The wiring threads the
platform's `networking.podCIDR`/`serviceCIDR` (and `clusterDNS`, the
service network's address plus 10 when unset) into the cozyplane
component, drops the packages that assume the replaced stack
(kubeovn-webhook/-plunger, multus, securitygroup-controller, the
virtualprivatecloud app), refuses the default `cilium` gateway class and
`networking.encryption.enabled` on the variant, and turns off sdn
serving in cozystack-api.

Bootstrap ordering: the CNI installs first with the kube API as its only
dependency and ships only the LOCAL group's CRDs
(`local.sdn.cozystack.io`, underlay IPAM); the tenant kinds (VPC, Port,
SecurityGroup, …) have **no CRDs** and are served only by the aggregated
apiserver, which installs later behind cert-manager, etcd-operator and
storage. Until it lands, `sdn.cozystack.io` is simply not served; there
is no takeover. On Talos the agent and kpr bootstrap against KubePrism,
since with no kube-proxy the `kubernetes.default` ClusterIP is unserved
until kpr itself runs.

Each cozyplane package follows the umbrella pattern: the upstream chart
is vendored verbatim under `charts/<name>` by `make update` from a ref
pinned in the wrapper's Makefile, and everything Cozystack-specific
lives in the wrapper — the Talos overlays, the apiserver's etcd storage
class and replica count, and two ClusterRoles that carry cozyplane's own
tenant roles into the `cozy:tenant` tiers by aggregation, so the list of
tenant kinds stays upstream's to maintain. Image pins are the digests
upstream pins for that ref, with multi-arch legs verified there. The
wrappers carry helm-unittest suites pinning the platform contract, the
egress args the platform threads included, and the platform suite covers
the variant's package set, the guards and the CIDR threading.

The variant is experimental: it has no e2e lane yet and is not for
production clusters, which the operator-facing values comment says.
**CiliumNetworkPolicy objects apply but are not enforced on this
variant** — tenant network isolation on the default network, the Cilium
host firewall and the platform components' own Cilium policies (several
of them `ingressDeny` rules native NetworkPolicy cannot express) are not
in effect, as stated in the values comment, the networking source and
the threat model; rebuilding them on what cozyplane does enforce (native
NetworkPolicy, its operator-only HostFirewall) is a follow-up.
cozystack-api's SecurityGroup (a restricted interface over
CiliumNetworkPolicy) is not served on the variant; cozyplane's own
SecurityGroup is the first-class tenant instrument for traffic inside
and across VPCs. The tenant-facing VPC application lands in #4508,
stacked on this PR.

### Screenshots

Not a UI change.

### Downstream repositories

The trigger map fires for cozystack/website (a new platform variant and
new `platform.values` keys); cozystack/website#815 documents both. It
arguably fires for terraform-provider-cozystack too (the SecurityGroup
spec differs per variant); that box is left unticked so a human decides.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#815
- [ ]
[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(platform): opt-in networkingVariant "cozyplane" for the Talos bundle — replaces kube-ovn, Cilium and kube-proxy with the cozyplane eBPF CNI, its aggregated sdn.cozystack.io API server and a socket-LB kube-proxy replacement; CiliumNetworkPolicy objects are not enforced on this variant
```

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

## Summary by CodeRabbit

* **New Features**
* Added an opt-in Cozyplane networking variant with cluster DNS
configuration, CNI, and service routing.
* Added a Cozyplane API service for tenant networking resources, with
tenant edit and view permissions.
  * Added control over whether the existing SDN API is served.
* Gateway configurations using an unavailable class are now rejected
with guidance.
* **Important Limitations**
* Cozyplane does not enforce existing Cilium network policies or
platform Cilium rules. Tenant traffic isolation may require native
NetworkPolicies; some platform rules require operator-managed
HostFirewall policies.
* Cozyplane networking does not support encryption or the default Cilium
Gateway class, and requires pod and service CIDRs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 09:31:43 +00:00
Andrey KolkovandYan Bondarenko 4fb8ea40e2 test(clickhouse): delete the system-bucket Backup while its S3 host resolves
Deleting a system-bucket Backup now deletes its archive through the
clickhouse-backup sidecar, and the Backup is held until that delete is
answered. The delete reaches S3 at s3.example.org only through the
CoreDNS rewrite and the Ingress certificate the round-trip installs,
and the script's EXIT trap removes both. The round-trip therefore
deletes its Backup inside the script, before the trap runs, and waits
for the cleanup; the preconditions and the step's finally mark a
Backup they still find with skip-artifact-cleanup, since no S3 host is
mapped by then. The wait covers a cleanup Job that runs out its 600s
deadline, the 30s retry delay and a second Job, so the route is not
removed while a retried delete still needs it.

The test then checks the delete itself by listing the objects under
the archive's prefix in the system bucket, through the S3 Ingress with
the projected credentials and with folder entries left out: some before
the delete, none once the Backup is gone. clickhouse-backup's
list/remote is not used for this: it reports an archive for every
prefix at the top of the bucket, and SeaweedFS was seen to keep the
folders the delete emptied for minutes after all their objects were
gone.

Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-23 12:15:07 +03:00
Alexey Artamonov a2f7ea18ee fix(clickhouse): drop the predecessor wait once a run's own Job starts
A BackupJob or RestoreJob that waited for the Job of an earlier owner
of its name kept its Ready=False PredecessorJobPending condition after
that Job was gone and its own Job had started, so for the whole run it
still said it was waiting for the garbage collector.

The condition is now dropped when the run's own Job is running, the
way the credentials wait is.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:07 +03:00
Alexey Artamonov 8cf04bdd0f fix(clickhouse): make the example strategy use the archive its Backup records
The example strategy minted its own archive name from the clock and
restored the newest archive of the source application. The controller
then found no archive name in the backup Job and recorded none, so a
restore of an older Backup silently restored the latest archive and
deleting a Backup left its archive in the bucket.

The example now uploads under the name the controller chose and
restores the archive the Backup records, as the shipped strategy does;
the clock-made name and the newest archive remain the fallback for a
run the controller gave no name. The backup scenario no longer says the
archive is expired by the upstream tool's retention, which the chart
does not configure.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:06 +03:00
Alexey Artamonov 084fed9e2f fix(clickhouse): take no restore Job's result that this RestoreJob did not run
The restore path took any Job standing under a RestoreJob's Job name as
its own, so a RestoreJob re-created under a used name met the completed
Job of the earlier one before the garbage collector removed it and was
marked Succeeded although nothing was restored for it.

The restore path now refuses such a Job the way the backup path does:
the Job of an earlier RestoreJob of the same name is waited out, with
the Ready condition naming it, and any other Job holding the name
fails the RestoreJob.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:06 +03:00
Alexey Artamonov e199ef1d83 fix(clickhouse): take no backup Job's result that this BackupJob did not run
A Job standing under a BackupJob's Job name was taken as its own. A
BackupJob re-created under a used name, as a Plan does when the
BackupJob of a schedule slot is deleted within the slot's starting
deadline, met the completed Job of the earlier one before the garbage
collector removed it, was marked Succeeded without uploading anything,
and recorded a Backup for an archive nobody uploaded for it.

A Job controlled by an earlier BackupJob of the same name is now
waited out, with the Ready condition naming it; any other Job holding
the name fails the BackupJob, since nothing will remove it.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:05 +03:00
Alexey ArtamonovandYan Bondarenko 564bdd3a79 fix(clickhouse): delete the archive when its Backup is deleted
Deleting a Backup taken with the Altinity strategy released its
finalizer at once and left the archive in the bucket. On the system
bucket nothing else prunes it, so every ClickHouse backup stayed until
someone called the sidecar by hand.

Deleting such a Backup now runs a one-shot Job that asks the
application's sidecar to delete the archive the Backup records, and
holds the finalizer until the Job completes. The driver creates the
Backup with the finalizer already set, so a Backup deleted before the
reconciler first sees it still gets its archive deleted. An archive
that is already gone counts as deleted. The sidecar refuses a delete
while another operation runs, and cannot be reached while the
ClickHouse Pod restarts, so the Job waits both out within its
deadline; any other refusal fails the Job, which is reported as an
ArtifactCleanupFailed Warning Event carrying the reason it failed.

Each failure doubles the wait before the next cleanup Job, from 30
seconds up to 30 minutes, so a delete the sidecar refuses for good,
such as one made with a wrong password, does not cost a Job, its Pod
and a Warning Event every few seconds. The count of failures and the
time the next Job may start are kept on the Backup, because the Backup
controller does not watch Jobs; a start time further ahead than the
longest wait, from a skewed clock or a hand edit, is logged and
ignored. A Job the namespace's Job quota refuses is retried once a
slot frees up rather than released, since the Backup would be gone by
then and nothing would delete the archive.

The Job is built by the controller, not rendered from the strategy
template, because the shipped and the example templates run a restore
for every mode other than backup. Only the image, how to pull it, and
the node selector, tolerations, affinity and priority class come from
the template, rendered against the application and the Backup as for
the strategy's own Pods, so the cleanup Pod can be scheduled where
they are. The strategy is read only when a Job has to be created, so a
running delete outlives it. The Job also waits for the projected
credentials to reach the sidecar, as the backup and restore Jobs do: a
sidecar still serving the previous bucket answers "not found", and the
delete would count as done.

When the delete cannot run, the Backup is released with an
ArtifactNotDeleted Warning Event naming the archive left behind: the
namespace is terminating, the strategy, the application or its API
Secret is gone, the application has left the system bucket, the
platform's system bucket is no longer the one the Backup records (also
when it changes while the delete runs), another Job holds the cleanup
Job name, or the API server refuses the Job. An archive named without
its BackupJob's UID is released the same way: such a name comes from a
run that crossed the controller upgrade, and another run started in
the same second may share it. The
backups.cozystack.io/skip-artifact-cleanup annotation releases the
Backup without starting a delete. An application on its own bucket
keeps the archive's lifecycle, as with MongoDB.

The restore scenario and the chart comments told tenants to delete an
archive with DELETE /backup/<name>/remote, which clickhouse-backup 2.7
answers with 404; they now name POST /backup/delete/remote/<name>.

Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-23 12:15:05 +03:00
Alexey Artamonov b62f2f385f fix(clickhouse): record the bucket setting a ClickHouse backup was taken with
A ClickHouse application writes its archives either to the system
bucket, which nothing prunes, or to its own bucket, whose lifecycle is
the tenant's. A Backup did not say which applied, so nothing deciding
the fate of the archive when the Backup goes could tell them apart.

The application's useSystemBucket is read when the backup Job is
created, stamped on the Job and copied onto the Backup from there,
because the application may switch before the controller sees the Job
complete. It is the setting, not an observation of the bucket: the
sidecar uploads to the bucket it was last restarted with, so a switch
made just before the backup can be recorded while the sidecar still
writes to the previous bucket. A Job created before the stamp existed
falls back to the application as it reads then.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-11-23 12:15:04 +03:00
Aleksei Sviridkin 319c2c81f7 test(migrations): build each migration test image once per file (#5362)
## What this PR does

Closes #5299

In `hack/migration-{54,55,57,58,59,61}-*.bats`, every test calls
`prep()`, and `prep()` ran `docker build -q -t "$TESTIMG"` for one fixed
tag derived from the alpine pin. Under `bats -j N`, the tests in a file
run concurrently. On a cold cache, several uncached builds of that tag
therefore ran at the same time. The issue traces how a retag on the
containerd image store deletes the old image before creating the new
one, so a sibling's `docker run` can find the tag missing and fall back
to a pull.

This PR takes the first fix the issue suggests:
- `build_test_image()` holds the existing Dockerfile for each file,
unchanged (`jq`, plus `bash` for migration 61). Its exit status is
`docker build`'s, so a failed build still fails the caller.
- `setup_file()` builds the image once, before any test in the file
starts. If docker isn't available it does nothing, so `prep()` still
prints its existing "docker is required" message.
- `prep()` now runs `docker image inspect "$TESTIMG" ||
build_test_image`, so it only builds as a fallback when the tag is
missing (for example, a run without bats' `setup_file`). Under bats the
image already exists, so tests never build concurrently.

The issue lists 54, 55, 57, 58 and 59.
`migration-61-strimzi-v1-conversion.bats` has the same `prep()` pattern,
so it's included. Its separate `cozystack-migration61-test:ubuntu` build
stays where it is: only one test builds and uses it.

I chose this over `--no-parallelize-within-files` because it keeps these
files parallel and doesn't change the Makefile for every other bats
file.

### How I checked it

- I had no Docker daemon here, so I ran each file with a stub `docker`
on `PATH` that logs its calls and treats the tag as present once built:
- **On this branch:** one `docker build` per file (two for migration 61,
the second being the ubuntu image), with one `image inspect` per
`prep()` call.
  - **On main:** migration 54 ran four builds for its four tests.
- `bats --count` parses all six files.
- None of these files sources a `.sh` file, so they run only under real
bats (`bats-unit-tests`), not the `cozytest.sh` POSIX lane.
- Please rely on CI to run them against a real daemon.

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

These are repository-internal tests only.

### Release note

```release-note
NONE
```


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

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

## Summary by CodeRabbit

* **Tests**
* Improved migration test setup by building the required test image once
per test file and reusing it across tests.
* Preserved the existing Docker prerequisite checks and fallback
behavior.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 12:01:18 +03:00
Mattia Eleuteri 64fa40e255 feat(monitoring): add destinations to the agents without replacing the defaults
Sending a copy of metrics or logs to a store of one's own meant
overriding vmagent.remoteWrite.urls or fluent-bit.config.outputs. Both
are replaced wholesale on merge, a list and a single string, so the
override had to restate the platform's own destinations, and one that
did not silently cut the tenant's VictoriaMetrics and VictoriaLogs off.
A plain URL list could not carry credentials either.

vmagent.extraRemoteWrite takes VMAgent remoteWrite entries appended
after urls and passed as is, so an entry can carry basicAuth,
bearerTokenSecret, headers or tlsConfig. fluent-bit.config.extraOutputs
takes [OUTPUT] sections appended by the outputs template itself, which
the fluent-bit subchart renders with tpl, so .Values there is the
subchart's own. The managed Kubernetes app replaces outputs for tenant
clusters, so its outputs carry the same hook, escaped to survive the
app chart's render. On a tenant cluster both are set through
addons.monitoringAgents.valuesOverride.

With neither key set, the system chart render and the tenant render
(app HelmRelease values fed to the system chart) are byte-identical to
before. Unit tests cover both keys in the system chart and the hook in
the tenant HelmRelease; each fails without the change.

Both charts refuse to render when extraOutputs is set and the
effective outputs does not emit it, so an outputs override that drops
the hook fails loudly instead of losing the extra destinations.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 11:58:49 +03:00
Aleksei Sviridkin cac0bb9b28 test(hack): check hook scripts under files/ for --request-timeout (#5360)
## What this PR does

Closes #5304

`hack/check-hook-request-timeout.bats` built its candidate list with
`grep -rl 'kubectl' packages/*/*/templates/`. A chart that loads its
hook script with `.Files.Get "files/<name>.sh"` runs that script with
the same in-cluster credentials, but the guard never looked at it.
That's how the flag got through in the first revision of #4915. The
guard also matched only `--request-timeout=<value>`, while kubectl also
accepts `--request-timeout <value>`.

Changes:
- Candidates now include shell scripts under `packages/*/*/files/`,
recognised by a `.sh` suffix or a `sh`/`bash`/`dash` shebang, also
through `env` or `env -S`. Other files there (CAPI component manifests,
YAML defaults) are left out, as the issue suggests. Files that name
`KUBECONFIG` are still skipped.
- The pattern now catches the space form as well:
`--request-timeout(=["']?[^0[:space:]"']|[[:space:]]+["']?[1-9])`, which
also covers quoted values such as `--request-timeout "30s"`. The space
form only counts when a non-zero number follows. Several templates have
comments like "a non-zero --request-timeout on an in-cluster kubectl
call", and a looser pattern would flag them.
- The scan is split into small functions. Seven new cases run it on a
throwaway tree under `$BATS_TEST_TMPDIR`:
- a `files/hook.sh` with `--request-timeout=30s` is reported, which is
the case from the issue;
  - a script without the `.sh` suffix is picked up through its shebang;
  - `--request-timeout 30s` and `--request-timeout=5` are reported;
  - quoted `"30s"` and `'30s'` values are reported;
- an `#!/usr/bin/env -S bash -e` script is collected, and an `env -S
python3` script is not;
- `=0`, ` 0s`, prose in a comment, a script that sets `KUBECONFIG`, and
a non-script YAML under `files/` are not reported.

The existing repository-wide case still passes on main with the wider
scope. `cilium/files/ipam-migration.sh` and both seaweedfs hook scripts
are now checked, and none of them uses the flag.

### How I checked it

`bats hack/check-hook-request-timeout.bats` (bats 1.12.0): 8/8 pass.

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

This is a repository-internal test only.

### Release note

```release-note
NONE
```


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

## Summary by CodeRabbit

* **Tests**
* Expanded automated checks for request-timeout options in chart
templates and eligible shell scripts, covering both
`--request-timeout=value` and `--request-timeout value` formats,
including quoted values.
* Added coverage for zero-valued timeouts, prose mentions, files that
reference `KUBECONFIG`, and non-shell files.
* The check continues to require a minimum number of candidate files and
report files with non-zero timeout values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 11:58:30 +03:00
Aleksei Sviridkin dec14c736d docs(gateway): stop saying the route-hostname policy admits hostname-less routes (#5352)
## What this PR does

Refs #4938

The edge-termination section of `packages/extra/gateway/README.md` said
that on a class sharing one edge address the class controller has to
keep route hostnames inside the tenant apex, "since the platform's
route-hostname policy admits routes that declare no hostnames at all".

That stopped being true in 1.7.
`packages/system/cozystack-basics/templates/route-hostname-policy.yaml`
now requires `spec.hostnames` to be present and non-empty for
`HTTPRoute`, `TLSRoute` and `GRPCRoute` in `tenant-*` namespaces
(#3475), and it rejects any hostname outside the namespace's
`namespace.cozystack.io/host` apex. The policy doesn't depend on the
Gateway class. This PR replaces the sentence with one that says so and
links to the policy's entry under "Security model".

This fixes only the line the issue points at. I didn't audit the rest of
the README against the code, so I used `Refs` and not `Closes`. The
issue asks for that full review, and it should stay open for it.

`make generate` (cozyvalues-gen) only rewrites the parameter table, and
this change doesn't touch it.

### Screenshots

Not a UI change.

### Downstream repositories

I left every box below unticked on purpose. The only downstream copy of
this text is the Gateway reference page on cozystack/website. Per
`docs/agents/contributing.md`, the release bot regenerates that page
from this README on the next stable tag, so I don't think any manual
follow-up is needed. A maintainer should confirm that.

- [ ] 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
docs(gateway): the Gateway README no longer says the route-hostname policy admits routes without hostnames; since 1.7 it rejects them in tenant namespaces.
```


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

## Summary by CodeRabbit

* **Documentation**
* Clarified that the route-hostname policy applies to `HTTPRoute`,
`TLSRoute`, and `GRPCRoute` resources in `tenant-*` namespaces on
creation and update. It rejects routes with no hostnames or hostnames
outside their namespace’s apex. Routes stored before the policy is
installed are not rejected unless they are subsequently updated.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 11:56:48 +03:00
Mattia Eleuteri 62dee1d132 fix(postgres): keep users.app's password across pod restarts
CNPG bootstraps an "app" owner role with a generated password stored in
<release>-app, and a declared users.app adopts that role. The init-job
then sets the role's password from <release>-credentials, but CNPG's
instance manager re-applies the owner's password from the bootstrap
secret whenever it meets a secret version it has not applied, which
includes every pod start. Any restart therefore reverts users.app to
CNPG's generated password, and clients holding the advertised one get
"password authentication failed" with nothing changed on their side.

Render the owner's bootstrap secret from the same password the
credentials Secret holds, and point the live bootstrap method at it, so
both writers agree on one value.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 11:56:33 +03:00
Mattia Eleuteri 3a5ae23797 feat(virtual-machine): group a VM's claims for Velero volume group snapshots
Velero snapshots the PVCs of an application-consistent VM backup one
after another between the guest freeze and thaw. Windows holds a VSS
freeze for 10 seconds at most, and on LINSTOR a VM with three volumes
(two disks and the persistent TPM/EFI state) outlasts it, so the thaw
fails and the backup is only crash-consistent. Velero 1.18 snapshots
the PVCs sharing a velero.io/volume-group value as one
VolumeGroupSnapshot.

Neither chart can carry that label onto the claims. CDI copies
DataVolume labels to a PVC only when it creates it, and a VMDisk
exists, PVC included, before any VM names it; KubeVirt creates the
persistent-state PVC with a fixed label set. A post-install and
post-upgrade hook of vm-instance labels them instead, and removes the
label from claims of this VM that no longer belong to the group.

Velero has no fallback for a labelled claim it cannot group: an unbound
member, a second CSI driver, or no single default
VolumeGroupSnapshotClass for the driver fails it. The group is formed
only when all of that holds and groupsnapshot v1beta2 is served, so
clusters without group snapshot support render nothing new.

The instancetype suite rendered every template, and the hook's PVC list
lookup needs a scheme it does not mock, so it is scoped to the two
templates it covers.

A vm-disk claim outlives the VM that grouped it, so a pre-delete hook
releases this VM's group on uninstall. Helm runs uninstall hooks from
the stored manifest, so that hook is rendered unconditionally and
selects the claims by this VM's label value when it runs.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 11:55:31 +03:00
Aleksei Sviridkin 02b8a26738 fix(securitygroups): reject port ranges and malformed FQDNs on the SecurityGroup path (#5134)
<!-- 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

Fixes #5130.

`validatePortRules` sent any non-numeric port to `IsValidPortName`, so
`"80-90"` came back as "must contain at least one letter (a-z)". A
`first-last` value now gets "port ranges are not supported; list each
port as its own entry" on the same field. `PortProtocol` carries a
single port and Cilium's `endPort` is not exposed, so the limit itself
is unchanged.

`validateFQDNs` only checked that a selector was not empty. A malformed
`matchName` or `matchPattern` passed, and the backing write then failed
on the CiliumNetworkPolicy CRD, which surfaced as an error about a
`cilium.io` object. The validator now applies the CRD's own rules for
`spec.egress[].toFQDNs[]`, with a field error on the SecurityGroup path:
`^([-a-zA-Z0-9_]+[.]?)+$` for `matchName`, `^([-a-zA-Z0-9_*]+[.]?)+$`
for `matchPattern`, `maxLength: 255` for both, and the `oneOf` that
allows only one of the two per selector. These are copied from the CRD
served by Cilium 1.19.5 and match the agent's `FQDNSelector.sanitize`,
which also refuses a selector that sets both fields.

`TestCreateRejectsInvalidPortOrFQDN` lists each rejected value and
checks that the error carries a single cause, on the expected field,
with the expected reason. All 13 cases fail on `main`.
`TestCreateAcceptsValidPortOrFQDN` lists accepted values (named port
`http-8080`, trailing dot, underscore labels, `**.` prefix, infix and
lone `*` patterns, 255 characters) and checks they project 1:1. `go test
./pkg/registry/sdn/...` passes.

As a cross-check, every FQDN value in both tables was also sent to the
CiliumNetworkPolicy CRD of a lab running Cilium 1.19.5, with `kubectl
create --dry-run=server`. The CRD rejects exactly the values the
validator rejects and accepts exactly the ones it accepts.

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

The diff touches `pkg/registry/sdn/securitygroup/validate.go` and its
tests only: the SecurityGroup schema does not change, and no package,
chart, CRD, `hack/` or convention is touched. Neither the website nor
the Terraform provider documents or models SecurityGroup fields.

<!--
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(securitygroups): a port range now gets a clear "port ranges are not supported" error, and a malformed toFQDNs matchName or matchPattern is rejected on the SecurityGroup field instead of failing on the backing CiliumNetworkPolicy.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* Security group egress rules now reject port ranges with a clear
validation error; list each port separately.
* FQDN selectors are checked for supported name or pattern formats,
required selector fields, and a maximum length of 255 characters.
* Invalid egress settings are rejected without creating a policy, while
valid ports and FQDN selectors can be saved.
* **Documentation**
  * Updated guidance to reflect egress port and FQDN validation rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 11:51:46 +03:00
Aleksei Sviridkin 04fb5215a8 fix(kubernetes): apply addons.monitoringAgents.valuesOverride (#5375)
<!-- 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

`addons.monitoringAgents.valuesOverride` on a managed Kubernetes cluster
is accepted, stored and documented in the schema and README, but the
addon's HelmRelease template never reads it. The application stays
`Ready` and nothing reaches the agents, so a user who adds a second
vmagent remote-write URL or an extra Fluent Bit output to ship a copy of
metrics or logs to their own store gets no error and no effect. Every
other addon with a `valuesOverride` (coredns, cert-manager,
ingress-nginx, vertical-pod-autoscaler, cilium) already merges it.

The single commit moves the defaults into a
`cozystack.defaultMonitoringAgentsValues` helper and merges
`valuesOverride` over them with `mergeOverwrite`, the same pattern as
those addons. With no override the rendered HelmRelease is semantically
identical to the one on `main`; a new unit test sets an override and
fails on the previous template.

Note for reviewers: as with the other addons, lists and multi-line
strings are replaced rather than appended, so overriding
`vmagent.remoteWrite.urls` or `fluent-bit.config.outputs` means
restating the default tenant destination to keep it.

The `vmagent.remoteWrite.url` vs `.urls` mismatch from #5258 is already
fixed by #5024 and is on its way to the release lines in #5311 and
#5312; this PR covers the `valuesOverride` gap that #5258 also points
out.

Refs #5258

### 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
fix(kubernetes): `addons.monitoringAgents.valuesOverride` is now applied to the monitoring agents of managed Kubernetes clusters; it was previously accepted but ignored.
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* Monitoring agent overrides now retain default settings while applying
custom values. Configured remote-write URLs, cluster and tenant labels,
cluster-specific log filters, and log volumes remain intact when outputs
are overridden.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-23 11:51:37 +03:00
Yan Bondarenko 46c70422c4 fix(api): validate workload memory before storing an application
A memory quantity without a unit is measured in bytes. Reject new values
below 1Mi before storing them, while allowing unrelated API edits to
applications that already carry a smaller value. The check runs against
the live release right before the write, so a stale value read at the
start of Update cannot overwrite memory another writer has fixed since.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-23 11:33:10 +03:00
somazandYan Bondarenko 8382ed1a92 fix(gateway): skip a child apex the wildcard certificate already covers
In DNS-01 mode every inheriting child tenant's apex went into the
parent Gateway's wildcard Certificate. When a wildcard in the same
Certificate already covers that apex one label up, Let's Encrypt
refuses the whole order as redundant and the parent Gateway gets no
certificate at all. Skip such a SAN, matching the single-label check
Boulder runs in wildcardOverlap.

A child may also use a broader custom domain than the gateway. Its
wildcard then covers the gateway apex, so the same check drops the
gateway SAN too.

Closes: #5125
Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
Signed-off-by: somaz <genius5711@gmail.com>
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-11-23 10:59:26 +03:00
Mattia Eleuteri d89bce58e8 feat(linstor): enable VolumeGroupSnapshots for linstor-csi
linstor-csi implements the CSI GroupController since v1.11 and creates
the snapshots of a group in one LINSTOR call, so the volumes of a
multi-disk VM are captured at the same instant. Velero needs that for
application-consistent backups of Windows VMs with three or more
disks: taken one by one, the snapshots outlast the 10 s VSS allows a
freeze.

piraeus-operator decides the csi-snapshotter gate from an API probe it
runs only at startup, so on an upgraded cluster the gate would stay off
until the operator restarted. The gate is set in the LinstorCluster pod
template instead, and a default VolumeGroupSnapshotClass carries the
label Velero selects a group snapshot class by.

Both render only when the apiserver serves all three v1beta2 group
snapshot kinds. With the gate on and the API missing, csi-snapshotter
waits for its group snapshot caches before it starts the ordinary
snapshot workers, so every VolumeSnapshot would stall, and a v1beta2
VolumeGroupSnapshotClass would fail the upgrade. Otherwise the
operator's own probe decides the gate.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:08:50 +01:00
Mattia Eleuteri 892d9c9b34 feat(platform): upgrade snapshot-controller to v8.7.0
snapshot-controller v8.0.1 serves VolumeGroupSnapshots only as
v1alpha1 and runs without the CSIVolumeGroupSnapshot gate, so no CSI
driver on the platform can take a crash-consistent snapshot of several
volumes at once. Velero 1.18 and piraeus-operator both look for
groupsnapshot.storage.k8s.io/v1beta2, which v8.7.0 serves and which the
upstream chart enables by default.

The upstream chart renders its CRDs as ordinary templates instead of
shipping them in crds/, and helm-controller takes over existing objects
by default. A patch makes the chart render a CRD only when it is absent
or already carries this release's ownership, so a distribution that
ships its own snapshot CRDs keeps them as they are. keepCRDs is set
because an uninstall would otherwise delete every VolumeSnapshot along
with the CRDs.

Migration 62 hands the CRDs this release installed over to it, read
from its helm-controller labels, and checks the HelmRelease rather than
those labels to decide whether the release exists, so a retry after a
failed create still recreates what the first attempt deleted. The
apiserver refuses to drop v1alpha1 from a CRD that lists it in
storedVersions, so the empty v1alpha1 group snapshot CRDs are deleted
and created again at v1beta2 from copies the image build renders out of
the chart. Every HelmRelease waits for the pre-upgrade hook, so linstor
renders against the v1beta2 API even when it upgrades first; the version
is stamped only once every release-owned v1beta2 group snapshot CRD is
Established, which a retry after a timed-out wait must check again. A
CRD that still holds v1alpha1 objects is kept, recorded on the
cozystack-version ConfigMap, and its warning spells out the manual
recovery, since nothing renders either release again once it is gone.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:08:49 +01:00
Mattia Eleuteri fd885206e4 fix(kafka): link the node pools the hook creates to their HelmRelease
The broker and controller pools are applied by the pre-upgrade hook,
outside Flux, so they carry neither an ownerReference nor the
HelmRelease labels Flux puts on what it renders. The lineage walk from
a broker or controller pod therefore stopped at its pool: those pods
were never marked as managed by Cozystack, and the Kafka application's
schedulingClass never reached them.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:10 +01:00
Mattia Eleuteri addf7d1258 fix(lineage-webhook): leave a running Pod's scheduler alone on update
spec.schedulerName cannot change once a Pod exists, yet the webhook set
it on every Pod admission, updates included. A Pod created before its
tenant got a class, or before its application named one, then had
every later update refused by the apiserver, labels and annotations
written by controllers included. A class can only take effect when the
Pod is created.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:10 +01:00
Mattia Eleuteri d3804ebea9 feat(api): refuse an application scheduling class its tenant does not allow
The lineage webhook keeps a pod on the tenant class when the
application names a class the tenant does not allow, but it can only
log that, on a pod the user never looks at. Refusing the application
at admission puts the error where the field was set, with the list of
classes that would be accepted.

An update that keeps the class is not refused, so an application whose
class was removed from the list after admission stays editable; the
webhook already keeps its pods on the tenant class. Tenants are left
out, because their spec.schedulingClass is the child tenant's class,
which the tenant chart's inheritance governs.

Users read the field description in the dashboard form and the API
schema, so it names the tenant setting that decides which classes are
accepted, says that only setting another value is refused, and that a
pod gets its class when it is created, so running pods keep theirs. The
field sits in its own README section, since a reader looking for
placement would not look under the unrelated heading it was appended
to.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:09 +01:00
Mattia Eleuteri e67a514903 fix(lineage-webhook): keep the tenant class when an application's is refused
The webhook fell back to the tenant class only when an application
left spec.schedulingClass empty. A value naming a class that does not
exist, or one the tenant does not allow, left the pod with no
scheduler at all, so a typo, or a deliberate bogus name, in any
application lifted the placement constraint the tenant administrator
had set.

Admission sees the application only once, so a class removed from the
allowed list afterwards has to be caught here as well. Naming the
tenant's own class needs no entry in the list, being the same as
leaving the field empty.

The application class is looked up once, so a class deleted between
deciding and injecting cannot leave the pod with neither class. A
lookup error fails the admission instead of counting as absence:
otherwise a timeout or a 5xx from the apiserver would admit the Pod on
the default scheduler, outside the tenant's constraint, until it was
recreated. Under failurePolicy Fail its controller retries. Only an
absent class, or an absent SchedulingClass CRD, means there is nothing
to inject.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:08 +01:00
Mattia Eleuteri 4034f9eeb9 feat(tenant): let an administrator list the classes applications may pick
An application's spec.schedulingClass replaces the tenant class for
its pods, and the tenant class is the administrator's placement
constraint. Without a list of permitted alternatives, anyone who can
create an application in the tenant can move it onto any class the
cluster defines.

allowedSchedulingClasses names those alternatives and defaults to
empty, so per-application placement stays off until an administrator
opts in. The tenant chart writes it to a namespace annotation, the
place the admission policy and the lineage webhook can read it from.
A parent that constrains placement passes its list down unchanged, so
a child tenant cannot allow a class its parent does not, the same way
it cannot replace the parent's class.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:07 +01:00
Mattia Eleuteri aed71ed610 test(lineage-webhook): cover the per-application scheduling class
The applySchedulingClass tests only ever passed a nil owner, so the
path where an application's class takes over from the tenant's, and
the guard that keeps an over-long class name off the Pod labels, could
break unnoticed. The owner is built as unstructured, as the lineage
walk returns it, because its conversion into Application.Spec.Raw is
part of that path.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:07 +01:00
Mattia Eleuteri 0132457260 feat(apps): expose schedulingClass across all managed applications
Placement could only be set per tenant, so two applications of the
same tenant could not be kept together, or apart, unless each had a
tenant to itself. With a class per application and the scheduling-class
Pod label, a SchedulingClass name can serve as a co-affinity group: a
database and the virtual machine that uses it can be kept in the same
region without pinning which one.

The field is capped at 63 characters. A SchedulingClass name may be up
to 253, but the webhook writes the class into a Pod label, and this is
the first source of the class the apiserver has not already validated
as a label value; capping it is cheap while the field is new and a
breaking change once released. A class created with a longer name must
still not break Pod admission, so for it only the label is left out.

kubernetes-nodes gets no field: the ownership walk from a worker Pod
reaches the parent Kubernetes application, never the pool, so a class
set on a pool would be accepted and silently ignored.

Placement per replica role (primary or standby of a clustered
database) is out of scope: the operator assigns the role after
election, once the webhook has already seen the pod.

Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-23 08:05:06 +01:00