Commit Graph
3049 Commits
Author SHA1 Message Date
Andrey Kolkov f4330867ea feat(dashboard): let a login link pick the Keycloak identity provider (#5286)
## What this PR does

A login link into the dashboard can now name the Keycloak identity
provider, so a user who comes from a portal brokered into Keycloak skips
the realm login page:

```
https://dashboard.<host>/oauth2/start?kc_idp_hint=<idp-alias>&rd=/admin/tenants
```

The motivating case is a billing portal registered in the realm as an
OIDC identity provider. Its "Open dashboard" button today lands every
client on "Sign in to <realm>", where they must pick the portal's
provider by hand on every new browser or session. Keycloak skips that
page when the auth request carries `kc_idp_hint`. The gatekeeper,
however, builds the request from a fixed `--login-url`, and
oauth2-proxy's flags forward only `acr_values`, `prompt` and
`approval_prompt` from `/oauth2/start`. Putting the hint into
`--login-url` would force every dashboard login, administrators
included, through that one provider.

oauth2-proxy can forward an allowed parameter through
`providers[].loginURLParameters`, but only in its alpha configuration.
The OIDC gatekeeper therefore now runs from one:

- `templates/gatekeeper-config.yaml` (new, OIDC only) holds the
provider, upstream, listen address and injected headers. The values are
exactly what `oauth2-proxy --convert-config-to-alpha` (v7.12.0) produces
for the previous flags, both the in-cluster Keycloak branch and the
external-discovery branch. On top of those, `kc_idp_hint` is allowed
when it matches `^[A-Za-z0-9._-]+$`. That rule and `clientSecretFile` in
place of the inline `clientSecret` are the only hand-written lines;
everything else, `scope`, `approval_prompt`, `insecureSkipNonce`,
`flushInterval` and `timeout` included, is the converter output
unchanged.
- `templates/gatekeeper.yaml` keeps the flags the alpha configuration
does not own (redirect URL, whitelist domain, email domain, API routes,
cookie options, `--skip-provider-button`, `--ssl-insecure-skip-verify`).
It mounts the config and the `dashboard-client` secret as files
(`clientSecretFile`). A checksum annotation restarts the pod when the
config changes.
- The token-proxy branch (OIDC disabled) is unchanged.

A login without the parameter behaves as before. oauth2-proxy logs a
warning on start that the alpha configuration format may change between
releases.

Tests:
- **Chart suite.** The gatekeeper suite loads the config template as
well, because the deployment checksums it. The "no branding volume" test
now asserts the branding volume is absent, not that the pod has no
volumes. The five tests that read Keycloak URLs from the container args
are removed: those values now sit in the alpha configuration. `helm
unittest .` passes, 23 tests.
- **E2E.** After the gatekeeper rolls out with OIDC enabled, the in-tree
install suite requests `/oauth2/start` through a port-forward and checks
the redirect: `kc_idp_hint=e2e-idp` reaches the `cozy` realm's auth URL,
and a value outside the allow pattern (`e2e%26prompt%3Dnone`) is
dropped. This covers the realm path and the allow rule that the removed
chart tests no longer pin.
- **Gatekeeper login (`hack/dashboard-gatekeeper-login.bats`).** Renders
the chart for a realm other than `cozy`, starts the auth-proxy image
with the rendered args and alpha config, and checks the `/oauth2/start`
redirect: on the in-cluster Keycloak branch the hint reaches that
realm's auth URL, a value outside the allow pattern is dropped, and a
login without it carries none; on the external-discovery branch the
gatekeeper discovers that realm from a local Keycloak stub and passes
the hint. The image is read from the render, so an oauth2-proxy bump
re-checks the alpha configuration. Needs docker, like
`hack/etcd-grpc-alerts.bats`.
- **Real oauth2-proxy v7.12.0 on the rendered config.** Ran with the
rendered args and checked:
  - `/ping` answers OK;
- `/oauth2/start?kc_idp_hint=whmcs` puts `kc_idp_hint=whmcs` into the
Keycloak auth URL;
- `/oauth2/start` without the parameter, or with a value outside the
pattern, does not;
  - a protected path redirects without it;
  - `/apis/*` stays 401;
  - `--ssl-insecure-skip-verify` starts fine alongside `--alpha-config`.
- **Live cluster.** Swapped in the rendered gatekeeper with the
HelmRelease suspended, then reverted:
- a brokered user who was already signed in at the portal went from the
hinted link straight to the dashboard;
  - a plain visit still showed the realm login page;
- a hinted visit without a portal session went straight to the portal's
own login;
- API calls from the console worked, so the `Authorization` header
injection is intact.

### Screenshots

N/A — no console UI changes. The change removes the Keycloak login page
from the hinted flow.

### 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 touches only the dashboard gatekeeper templates and their
tests. It adds no value, schema, package or platform component. I walked
the trigger map against it, and no entry matches.

### Release note

```release-note
feat(dashboard): a dashboard login link can name the Keycloak identity provider with `/oauth2/start?kc_idp_hint=<alias>`, so users coming from a brokered portal skip the realm login page. The OIDC gatekeeper now runs oauth2-proxy from an alpha configuration kept in a ConfigMap; logins without the parameter are unchanged.
```


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

## Summary by CodeRabbit

* **New Features**
* OIDC-enabled clusters now use updated dashboard sign-in settings,
forwarding identity and token information to the dashboard.
* Authentication requests use Keycloak’s internal URL when configured;
otherwise, logout uses the public Keycloak URL.
  * Sign-in requests include the OpenID, email, and profile scopes.
* Supported identity-provider hints are preserved in sign-in redirects,
while invalid hints are excluded.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-20 17:05:43 +07:00
Andrei Kvapil e11ca91d81 fix(backups): stop leaking MariaDB dumps of stuck runs and torn-down namespaces (#5344)
## What this PR does

Closes #5291. Two paths left a MariaDB dump and its
`k8s.mariadb.com/Backup` behind after the dump cleanup from #5233.

**A run that never completes.** When the operator Backup stays short of
`Complete` past `mariadbDefaultBackupDeadline`, the BackupJob now
deletes it (background propagation, so its Job goes too) before it marks
itself `Failed`, and says so in the failure message. No Cozystack
`Backup` is ever made of such a run, so nothing else deleted it, and
while it stood its window had no end: `contestedMariaDBDump` counted it
as a possible writer of every later dump of the application, and every
later `Backup` was released with `ArtifactNotDeleted`. Deleting the Job
also stops a run that is still going from uploading a dump nobody
tracks. An operator Backup that is `Complete=True` on a reason the
driver does not know has a bounded window and is kept, as before.

The decision is made on the operator Backup read from the API server,
not the cache. A run the operator has just marked complete or failed
goes down the normal path and is not deleted. The delete carries the UID
and resourceVersion that were read, so a run that completes between the
read and the delete is not deleted either. Past the deadline no new run
is created, so a pass that deleted the run and then failed to persist
`Failed` does not start another one on retry. A delete the API server
keeps refusing shows as `Ready=False/OperatorBackupDeleteFailed` on the
BackupJob. The delete also removes the run's pod, so before it the
controller copies what held the pod up into the failure message: an
unschedulable pod, or a container that is waiting or has failed.

The MariaDB driver's other failure exits take the same path: the MariaDB
application was deleted, the MariaDB CR never came back, the strategy
disappeared past its deadline, the strategy no longer renders, the
applicationRef is rejected, or the run could not be created. Past the
deadline, the run is taken from the API server listing and
`ensureMariaDBBackup` is not called, so a cache that has not seen the
run cannot cause a second one to be created. mariadb-operator leaves the
run of a MariaDB that went away at `Complete=False` for good, so if the
application was later recreated under the same name, that run used to
contest every later dump.

The deadline is still 30 minutes from `StartedAt`, but a dump that is
still running at that point is now stopped instead of being left to
finish outside Cozystack.

**Namespace teardown.** mariadb-operator puts no finalizer on its
`Backup`, so during teardown it is usually gone before the Cozystack
`Backup` finalizer runs. When the operator Backup is not found, the
cleanup now:

- takes bucket, prefix and Secret references from the snapshot in
`status.underlyingResources`;
- goes on only for a recorded dump (`k8s.mariadb.com/dump-file`) on the
platform bucket written with the projected platform Secret, reached with
the platform credentials, which do not depend on the namespace;
- keeps the dump, with a `Warning ArtifactNotDeleted`, when another
operator Backup, finished or not, could have written it (the same
`contestedMariaDBDump` check as before);
- retries a failed delete through `retryMariaDBCleanup`, which releases
the `Backup` once the namespace is terminating.

The snapshot and the storage URI now record the storage the run was
created with, whatever its kind, rather than the strategy as rendered
when the run completed. A strategy edited during a run therefore cannot
send the cleanup to the wrong place. The BackupJob looks for its run on
the API server rather than in the cache, so a retry after a failed
status write never starts a second run. A `Running` BackupJob never
starts a run at all, and if its run is gone the job is failed.

A `Backup` with no recorded dump, no snapshot, a dump on another bucket
or written with the tenant's own Secret, or unreadable platform
credentials is released with a `Warning`, as before. A missing operator
CRD keeps the old release path.

The platform-bucket check that `mariadbCleanupConnection` used is now
`mariadbPlatformConnection`, shared by both paths. Its behaviour is
unchanged.

Not covered:
- Operator Backups left behind by BackupJobs that failed before this
change are still there, because terminal BackupJobs are not reconciled
again. Deleting them by hand releases the dumps they hold.
- Deleting a BackupJob that is still running leaves its operator Backup,
which has no ownerRef and no finalizer. This was already the case and is
not addressed here.
- The driver-independent terminal exits in `backupjob_controller.go`
(BackupClass resolution, credentials projection) still fail a BackupJob
without looking at a MariaDB run.
- A run that is stopped at the deadline after it has uploaded its dump
leaves that dump untracked. No `Backup` is ever made of such a run. The
other fail-safe cases listed in the issue (a `Restore` that never
completes, the single `Backup` worker, non-204 DELETE responses,
endpoint moves) are not addressed here.

Tests: `go test ./internal/backupcontroller/...`. The deadline outcome
table now also checks whether the operator Backup was deleted. New
cleanup tests cover a missing operator Backup: the dump deleted with the
platform credentials, already absent, contested by an unfinished run, a
failed delete held for retry, and each case it cannot reach (volume
storage, a recorded name that is not a dump, a snapshot of another
kind). Deadline tests cover a retry after a failed status write, a cache
that trails a completed run or misses a new one, a delete conditional on
the run that was read, a refused delete, and the application or MariaDB
going away mid-run.

### Screenshots

N/A, no UI changes.

### Downstream repositories

I checked the trigger map in `docs/agents/contributing.md` against the
diff. The diff touches `internal/backupcontroller/mariadbstrategy_*.go`
and their tests. It also adds a message helper in
`internal/backupcontroller/backupjob_controller.go` and changes comments
in `internal/backupcontroller/backup_controller.go` and
`packages/system/backupstrategy-controller/templates/rbac.yaml`. No
values, schemas, CRDs, RBAC rules, annotations or telemetry change.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(backups): MariaDB dumps are no longer left in the bucket when a backup run never completes or when a tenant namespace is deleted. A BackupJob that times out now deletes the operator Backup it gave up on, so that run no longer blocks the deletion of later dumps. A Backup whose operator Backup is already gone now deletes its recorded dump from the platform bucket using the platform credentials. A MariaDB backup run that has not completed 30 minutes after its BackupJob started is now stopped.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* MariaDB backup cleanup now removes a recorded dump from the platform
bucket when its operator Backup is already gone, while leaving contested
or insufficiently verified dumps untouched.
* Failed dump deletions are retried, and cleanup reports when a dump is
already absent.
* Backup jobs are less likely to start duplicate runs during retries,
and completed backups retain the storage configuration used by their
run.
* Failure handling preserves completed runs and includes operator-run
completion details when available.
* Backup jobs now recheck the operator Backup before failing on a
deadline, helping account for runs that completed or failed in the
meantime.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-20 04:59:41 -05:00
Andrey Kolkov 7f31011b99 fix(backups): delete the Velero backup of a failed BackupJob (#5364)
<!-- 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

<!-- Link the issues this PR addresses. For a complete fix targeting the
default branch, use Closes #N (Closes owner/repository#N for another
repository). Otherwise use a non-closing reference; release-branch PRs
need manual issue linking and closure when appropriate. -->

Closes #5355

A BackupJob whose Velero backup ends `Failed` or `PartiallyFailed`
leaves that `backup.velero.io` object and its data in the backup bucket
(partial resources, logs) until Velero's TTL expires it, 720h by
default. No `Backup` is created for a failed run, and the `Backup`
finalizer was the only code that asked Velero to delete backup data;
deleting the BackupJob does not remove it either, because the Velero
backup is only labelled for the job, not owned by it.

The first commit requests deletion of the failed Velero backup through a
`DeleteBackupRequest`, and turns the reconcile of a `Failed` BackupJob,
which returned at once, into a sweep over the Velero backups still
labelled for the job. That sweep also cleans up backups leaked by
earlier versions after an upgrade. The request creation is shared with
the `Backup` finalizer and named after the Velero backup, so repeated
reconciles converge on one request. The failure message is unchanged.

The second commit narrows that sweep and makes it converge:

- Only `Failed`, `PartiallyFailed` and `FailedValidation` Velero backups
are deleted. A `Completed` one is never touched from a job-level
failure: a job can fail after Velero completed (creating or recording
the `Backup` failed), and that Velero backup may be the only copy of
good data.
- Deletion is requested only after `Failed` is persisted. The strategy
no longer sends the request inline, so a failed status write cannot
leave a retried run without the backup it reports the failure from. The
BackupJob watch has no predicate, so the `Failed` status update itself
triggers the sweep.
- While a failed backup still exists, the job is requeued every 5
minutes. Nothing watches `DeleteBackupRequest`, so this is how a request
Velero processed with errors is noticed and replaced. A backup that is
still running is rechecked every minute.
- Backups that reference the Velero backup are read through the uncached
API reader before anything is deleted.
- The ClusterRole of `backupstrategy-controller` gains `delete` on
`deletebackuprequests`, needed to replace a processed-with-errors
request. The `Backup` finalizer shares the helper, and without the verb
that path would fail with 403.

The third commit makes a deletion that Velero could not finish converge,
and makes it visible:

- A Velero backup in `Deleting` goes through the same request path.
Velero sets that phase before it removes the data and leaves it there
when removal fails, so skipping it left the data in place until the TTL.
- Our own request that Velero processed while the backup still exists is
replaced, whether it carries errors or not. The second case is a backup
that the BSL sync brought back.
- Each replacement emits a `VeleroBackupDeletionFailed` Warning event on
the BackupJob with Velero's `status.errors`, and doubles the wait before
the next replacement, 5 minutes up to 1 hour (enforced from the recorded
attempt time since the fourth commit). The count is kept in the
`backups.cozystack.io/velero-deletion-retries` annotation on the
BackupJob. A missing, read-only or unavailable BSL therefore shows up in
`kubectl describe` instead of being retried silently every 5 minutes.

The fourth commit makes the backoff binding rather than advisory:

- Each request the sweep creates records its time in the
`backups.cozystack.io/velero-deletion-attempted-at` annotation, next to
the retry counter. A request Velero has processed is replaced only once
the backoff for the current retry count has passed since that time.
Writing the annotations triggers a reconcile at once, because the
BackupJob watch has no predicate; that reconcile now only computes the
remaining wait. Before, with a BSL that fails instantly, it could
replace the request again right away.
- A request Velero has not processed yet, and a Velero backup still in
`New` or with no phase, are checked again after as long as they have
already waited: between 5 minutes (1 minute for a running backup) and 1
hour. Waiting emits no event.
- If the job was deleted before the annotations are written, the sweep
stops quietly. Any other error writing them is logged, and the computed
requeue is kept, because the request already exists.

Points for the reviewer:

- The sweep matches on the BackupJob labels, not on the strategy kind,
because a `Failed` job's BackupClass may be gone. The Kubernetes
strategy labels its Velero backup the same way and has the same leak on
failure, so a failed Kubernetes strategy run is cleaned up by the sweep
as well.
- The Velero strategy still treats a `FailedValidation` Velero backup as
in progress and requeues the BackupJob indefinitely. That is unchanged
here; the sweep already treats `FailedValidation` as deletable.
- After the upgrade, the Velero backups of BackupJobs that already
failed are deleted. An operator who wants one of them for a manual
`velero restore` must copy it first.

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

N/A — no UI changes.

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

The diff touches Go code in `internal/backupcontroller/` and one chart
file, `packages/system/backupstrategy-controller/templates/rbac.yaml`,
which adds the `delete` verb on `deletebackuprequests` to the
controller's ClusterRole. Walked against the trigger map:

- website: no package, platform value, variant, component, release
asset, ApplicationDefinition, Talos or tooling change. The ClusterRole
is not documented there.
- terraform-provider-cozystack: no app, schema field, enum, default,
`kind`/`plural`, prefix, or `Package`/`Plan`/`RestoreJob` CRD change.
- ansible-cozystack, talm, examples: no installer value, namespace,
variant, platform value, node prerequisite, or object the role waits on.
- ccp, external-apps-example: nothing under `hack/`, no package layout,
`-rd` path, variant, `tags.yaml`, `ApplicationDefinition` CRD or
commit-convention change.
- cozyhr, cozy-proxy, cozystack-telemetry-server, community: none of
their annotations, labels, metrics, `hack/package.mk` targets, PR
template or commit convention change.

No 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

<!--  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(backups): a BackupJob whose Velero backup ends Failed, PartiallyFailed or FailedValidation now asks Velero to delete that backup and its data in the bucket, instead of leaving them until Velero's TTL expires. A Velero backup that completed is never deleted this way. If Velero cannot carry out the deletion (for example, the backup storage location is missing, read-only or unavailable), the BackupJob gets a `VeleroBackupDeletionFailed` Warning event with Velero's errors, and the deletion is retried at a growing interval of up to one hour. After upgrading, the Velero backups of BackupJobs that already failed are deleted as well; to keep one for a manual `velero restore`, copy it before the upgrade. The backupstrategy-controller ClusterRole gains `delete` on `deletebackuprequests`.
```
2026-11-20 01:07:55 +07:00
Aleksei Sviridkin c98a345aa1 docs(api): clarify health check parsing and evaluation (#4495)
## What this PR does

Clarifies the lifecycle of HelmRelease CEL health checks.

helm-controller parses and validates these expressions and creates a
status reader factory before choosing how to wait. The factory
constructs the concrete status reader when the selected wait path
creates its resource manager. Invalid configuration can therefore stall
the HelmRelease with reason InvalidCELExpression even when the
release.cozystack.io/helm-install-disable-wait annotation is set or the
legacy wait strategy is selected. Once setup succeeds, only
helm-controller's poller evaluates expressions: while a Helm action
waits under the poller strategy, and for Helm hooks, which are still
waited on when the annotation disables wait. Without the annotation, the
legacy strategy never evaluates them. With it, hooks are evaluated
whatever the strategy, because disabling wait takes precedence.

The monitoring template comment now also distinguishes an existing
status object without `updateStatus` from a completely absent top-level
`status` key. The former evaluates the predicates to false, while the
latter can produce an evaluation error and an Unknown result. The poller
continues waiting in both cases.

The CEL expressions and runtime behavior are unchanged. The generated
ApplicationDefinition CRD description was regenerated from the Go field
documentation.

Fixes #4388

### Screenshots

N/A — no UI changes.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
NONE
```

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

* **Documentation**
* Clarified when health-check expressions are validated and evaluated
across wait strategies and Helm hooks, including how invalid expressions
can affect Helm releases.
* Explained how missing status fields affect health-check results and
that polling continues until the resource is operational or times out.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-19 19:45:54 +03:00
Andrey Kolkov 887453c008 fix(backups): keep completed Velero backups of failed BackupJobs
The failed-job sweep treated a Completed Velero backup as deletable. A
BackupJob can fail after Velero completed, when creating or recording its
Backup fails transiently, and that Velero backup may be the only copy of a
good backup. The sweep now deletes only Failed, PartiallyFailed and
FailedValidation backups, also when several Velero backups reference one
job, and it reads the Backups that may reference them through the uncached
API reader, so a Backup the cache has not seen yet still protects its data.

The Velero strategy no longer requests the deletion before it records the
failure. If that status write failed, Velero removed the backup and the
retried run created a new one, so the failure was lost. The deletion now
comes only from the sweep, which runs on the reconcile that the persisted
Failed phase triggers; the BackupJob watch has no predicate that drops
status updates.

Replacing a request that Velero processed with errors deletes it, and the
backupstrategy-controller ClusterRole only allowed create, get, list and
watch on deletebackuprequests. That Delete failed with 403, and since the
Backup finalizer uses the same helper, a Backup deletion could get stuck
on it. The rule now includes delete.

Nothing watches DeleteBackupRequests, so the sweep did not run again after
Velero processed a request with errors. A Failed job now requeues every
5 minutes while a failed Velero backup of it remains, which replaces such a
request, and every minute while one is still running, instead of every 5
seconds.

Unit tests cover a rejected Failed status write, Completed, Deleting and
FailedValidation backups, a request processed with and without errors, the
UID precondition on the replacement, a Backup visible only to the uncached
reader, and API errors from the helper.

Refs: #5355
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-19 20:44:11 +07:00
Aleksei Sviridkin d88322197f chore(deps): roll up Renovate updates and raise dependencies to latest stable (#4869)
## What this PR does

One PR instead of separate Renovate PRs. Go modules, Dockerfile base
images and GitHub Actions move to newer versions that build and pass the
tests. Where a newer version is known to break something, it stays
behind, and `.github/renovate.json` holds it with the reason in the rule
description.

The tests come first, in their own commits:

- `make go-unit-tests` runs the Go tests under `pkg/` and `cmd/`, except
the backport-batch suite, which keeps its own target. The apiserver
serializer and fuzz tests, the generated OpenAPI and applyconfiguration
suites, the apis packages and the controller, operator and
observability-proxy commands did not run in CI before.
- The apps API surface that apiserver libraries shape is pinned:
server-side apply, content negotiation, Table output on watch, the
served OpenAPI v2 and v3 documents, and building the server without
etcd. Two answers look wrong and are pinned as they are today: applies
from different field managers never conflict (#4857), and protobuf is
refused with 406 even when the client offers JSON as a fallback (#5297).
- New tests cover the kubeovn webhook patch, the token proxy session
cookie and the mount-utils behaviour the kubevirt CSI node service
relies on.
- `hack/image-smoke.bats` checks the tools the CSI, LINSTOR, multus,
Harbor and redis-backup images take from their base images or build
stages, and that the kubevirt CSI node plugin and its sidecars need no
more than x86-64-v2. Each PR build job runs it against the images it
pushed; forks and the unit lane run no container.

The tests found two bugs:

- The kubeovn webhook dereferenced a nil pointer on an admission review
without a request, so the caller got a dropped connection instead of a
400.
- The token proxy cookie refresh never fired: securecookie decodes the
session times as int64 and the refresh looked for float64, so the
`--cookie-refresh=1h` the chart sets did nothing. A refreshed cookie
keeps the token's expiry. A session too large to encode now shows an
error at sign-in and leaves the current cookie alone on refresh.

What moved:

- GitHub Actions to their Node 24 majors. The flux action stays on the
tag of the Flux CLI it installs. The release job's checkout no longer
persists credentials, so its staging branch push uses the App token.
- Go 1.27.2 for the toolchain and builders. Builds that reproduce an
upstream release keep the Go upstream uses: Harbor, cilium-operator,
SeaweedFS and the chainsaw stage of the e2e sandbox.
- controller-runtime v0.25.2, gateway-api v1.6.3 on the minor of the
installed v1.6.1 CRDs, cel-go v0.30.0, grpc v1.84.0, etcd v3.7.2,
cert-manager v1.21.2, kubevirt csi-driver f10ae94 on Kubernetes v0.37.1.
- Node 24 for the dashboard console.

Held back, each with its reason in the Renovate rule:

- cel-go stays below v0.31: the old repository has no tags past v0.30.0,
and v0.32 moves to cel.dev/cel-go, which k8s.io/apiserver does not
import.
- kube-openapi stays on the commit its dependencies require, and
structured-merge-diff stays on v6, because k8s.io/apimachinery v0.37
does not compile against v7.
- The Flux API modules stay on the Flux v2.8 line the platform installs.
- gomodules.xyz/jsonpatch stays on v2, which controller-runtime's
admission.Patched takes.
- jwx stays on v3: v4 removes jwk.Cache, which the token proxy's JWKS
refresh is built on.
- kubevirt.io/api and the CDI API stay where upstream csi-driver builds.
- The kubevirt CSI driver image stays on AlmaLinux 9, because AlmaLinux
10 builds its amd64 userland for x86-64-v3.
- shadowbox stays on node 18, which outline-server declares in its
engines.
- The e2e sandbox stays on Ubuntu 24.04. 26.04 ships uutils coreutils,
whose `date` costs about 4x per call, and the test harness forks it per
traced line, which adds about ten minutes to the install phase.
- clastix/kubectl stays on v1.32 for the cleanup hooks, within kubectl's
one-minor skew.

The cert-manager Go module (v1.21.2) is one minor ahead of the installed
chart (v1.20.2). The Certificate objects the gateway controller writes
serialize the same either way.

`api/apps/v1alpha1` now requires Go 1.27.2, which applies to every
module that imports the published types.

The Linux run with Go 1.27.2 was done before the rebase onto current
main, and the rebased head has not been through it yet. There the five
modules built, vetted, tested and tidied cleanly, and the repository
unit, controller and envtest lane passed. `go test -race` passed in four
modules. In the root module it failed only on a pre-existing data race
in the workload monitor tests (#5296), which main has too. The image
smoke checks run in this PR's CI.

### Screenshots

No UI change.

### Downstream repositories

`api/apps/v1alpha1` moves to `go 1.27.2`, and
cozystack/terraform-provider-cozystack imports it, so that repository is
affected but needs no action. Its box stays empty for that reason, and
so does the "not affected" one.

- [ ] 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: none needed, because its Renovate raises the go directive
together with the pin bump and its CI takes Go from `go.mod`; the only
effect is that the provider's minimum Go becomes 1.27.2.
- [ ]
[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
chore(deps): move the toolchain and builder images to Go 1.27.2 and raise Go modules, base images and GitHub Actions to newer working releases; the dashboard token proxy now refreshes its session cookie, and the kube-ovn webhook rejects an admission review without a request instead of dropping the connection.
```
2026-11-18 14:42:34 +03:00
Aleksei Sviridkin 693ff070e5 chore(goldpinger): bump vendored chart to 1.2.0 (#4877)
## What this PR does

Update the vendored Goldpinger chart to include upstream Gateway API
support for the work tracked in #4788. HTTPRoute and UDP probing remain
disabled by default.

With the package's current values, the rendered resources differ only in
the image tag and version labels. The DaemonSet selector is unchanged.
The umbrella chart also declares the vendored dependency so Helm can
lint it.

### Screenshots

Not applicable. This PR updates the chart and package metadata; it does
not change the UI source.

### 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
chore(goldpinger): bump vendored chart to 1.2.0 (goldpinger 3.11.5); new HTTPRoute and UDP probe options are disabled by default
```
2026-11-18 14:42:27 +03:00
Aleksei Sviridkin 9813d13dcd fix(kamaji): drop kubelet config fields older tenants do not know (#4896)
## What this PR does

Older tenant Kubernetes versions receive kubelet config fields they do
not know. The pinned Kamaji 26.9.4-edge build uses the Kubernetes 1.37
libraries to render `kube-system/kubelet-config`:

| Field | Known since | Rendered for tenants |
| --- | --- | --- |
| `memoryReservationPolicy` | 1.36 | v1.31 to v1.35 |
| `mergeDefaultEvictionSettings` | 1.33 | v1.31 to v1.32 |
| `crashLoopBackOff` | 1.32 | v1.31, as `crashLoopBackOff: {}` |

On a v1.35 tenant, `kubeadm join` logs:

```text
configset.go:176 error unmarshaling configuration schema.GroupVersionKind{Group:"kubelet.config.k8s.io", Version:"v1beta1", Kind:"KubeletConfiguration"}: strict decoding error: unknown field "memoryReservationPolicy"
```

Nodes still join, because kubeadm only logs this and decodes leniently,
dropping the field. Anything that decodes this ConfigMap strictly fails.

The compatibility patch drops these fields when the tenant version
predates them, including fields added by a user JSON patch. Supported
fields are kept. The version checks conservatively treat a pre-release
as older than its minor; early alpha releases can lack that minor's
fields. A running tenant gets the cleaned ConfigMap the next time Kamaji
uploads it.

JSON removals cannot fully replace this on the current build: Kamaji
decodes patched JSON back into a Go struct, restoring a removed
`crashLoopBackOff` as `{}`. The kubernetes chart also does not render
`kubelet.configurationJSONPatches`.

Upstream fixed JSON patch removal in 26.10.4-edge (clastix/kamaji#1347).
With that bump, the chart can render version-dependent removals and
replace this compatibility patch. This PR keeps the fix for 26.9.4-edge.

The regression tests cover field presence for tenants v1.31 to v1.37,
selected pre-releases, user patches, invalid versions, defaults and
`UploadKubeletConfig` with a fake client. The image build runs the tests
of packages touched by its patches.

Tested on Linux:

- Against upstream Kamaji commit
`1c3d84ae94473e94945ad01b2540ec319478bce4`, the new tests fail with the
current main patch in the three compatibility tests. With this patch,
the Go tests in every package touched by the patches pass, and the
Kamaji build succeeds.
- The repository unit lane passes.

I did not run a strict-decoding matrix against each Kubernetes minor for
this 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:

### Release note

```release-note
fix(kamaji): stop writing kubelet config fields that older tenant Kubernetes versions do not know, such as memoryReservationPolicy on tenants before v1.36, so strict decoders of the kubelet-config ConfigMap no longer fail.
```
2026-11-18 14:42:20 +03:00
Aleksei Sviridkin 1d64d077e3 Merge branch 'main' into issue-4388
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-18 13:38:20 +03:00
Aleksei Sviridkin fd426c7e4b build(monitoring): respin the Alerta image on a patched base (#5334)
Supersedes #5244 and #5333: the same change from an in-tree branch, so
CI can build the new image. Includes main merged in and the test fixture
fix from #5333.

## What this PR does

Alerta 9.1.0 is the latest upstream release, and
`alerta/alerta-web:9.1.0` still ships the Debian packages of its build
day, the compiler toolchain and `-dev` headers it built wheels with, and
Python packages whose fixes landed after the release. The monitoring
chart ran that image by tag, without a digest.

This builds the Alerta image in-tree from the upstream one:

- `images/alerta/Containerfile` starts from `alerta/alerta-web:9.1.0`
pinned by its index digest, upgrades the OS packages, purges the
build-only packages and lifts the affected Python packages within the
ranges the installed packages declare (`pip check` gates the build).
`cryptography` stays below 47 because `pyOpenSSL` requires it; `lxml`
stays on 5.x.
- The result is copied into an empty image so the purged files are
really gone, and the upstream image config (env, user, ports,
entrypoint, command) is restated exactly; `docker-entrypoint.sh` renders
the nginx, uWSGI and Alerta configs from those variables. The image is
752 MB against 1.32 GB upstream; a purge layer on top would have made it
1.78 GB.
- `make image` builds it as `alerta:v9.1.0-cozystack.0` and writes the
digest into `alerta.image`, like the traces collector. Until then the
default is the digest-pinned upstream image.
- The Deployment takes the image from `alerta.image` through
`cozy-lib.image`, so mirrored-registry installs work for Alerta as they
do for Grafana.

Trade-off: `apt-get upgrade` takes whatever Debian has at build time, so
two builds of one revision can differ. That is what a respin is for;
bump `ALERTA_COZYSTACK_REV` to publish a fresh one.

Testing (podman, amd64):

- With `postgres:17-alpine` and the chart's env, Alertmanager v4
webhooks to `/api/webhooks/prometheus`: firing critical → 201 and the
alert open; `event=Heartbeat` → 202 and the heartbeat recorded; resolved
→ 201 and the alert closed. Admin login 200, UI 200, no ERROR in the
logs, and `alerta_telegram`, `alerta_slack`, `alerta_prometheus` import.
Upstream 9.1.0 gives the same results with the same script.
- `trivy rootfs`, CRITICAL and HIGH: 29/940 → 3/76. The three critical
left (sqlite CVE-2025-7458, libxml2 CVE-2026-6653, zlib CVE-2023-45853)
and every remaining Debian HIGH have no Debian 12 fix; the remaining
Python HIGH are cryptography and lxml, held back as above.
- `helm unittest .` (306 tests, including the new
`tests/alerta_image_test.yaml`) and `helm template`.
- arm64 was not built locally; aarch64 cp313 wheels exist for every
upgraded Python package, so the purged toolchain is not needed there.

### Screenshots

No UI changes.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

(Trigger map walked against the diff: only packages/system/monitoring —
an image build, a values key with no schema, a template line and a test.
No apps/extra package, schema, platform value, hack tooling or CRD
changes.)

### Release note

```release-note
build(monitoring): Alerta now runs a cozystack respin of 9.1.0 on an upgraded Debian base, without the build toolchain and with patched Python dependencies; its image is pinned by digest and follows the cluster images registry.
```


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

## Summary by CodeRabbit

* **Updates**
  * Alerta now runs from a pinned, refreshed container image.
* The Alerta image can be configured, and deployments respect the
configured image registry.
* The default image is replaced with the Cozystack-built image when
using the image build workflow.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-18 13:28:26 +03:00
Aleksei Sviridkin a3e60ec372 feat(kafka)!: run on Strimzi 1.2.0 and Kafka 4.x (#4900)
<!-- 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

This upgrades the Kafka operator to Strimzi 1.2.0. Kafka 4.3 is the
application default, with 4.2 also available. Upgrades must pass through
Cozystack v1.7 and finish the ZooKeeper-to-KRaft migration first.

The upgrade now stops while any Kafka lacks KRaft evidence. Every Kafka
must report a nonempty `kafkaMetadataVersion` and the `KRaft` metadata
state. The API conversion deletes that state, so without it a Kafka
needs `Ready=True` or the `cozystack.io/kraft-verified` annotation,
which migration 61 writes on every Kafka it accepts before it stops the
operators. Any other explicit state blocks, and the error gives the
reason for each Kafka. On every variant, the platform chart refuses to
switch package sources while Strimzi still serves `v1beta2` and a Kafka
fails that check. On variants without the migration hook, it also
refuses while any Strimzi CRD still stores `v1beta2`, so
`/migrations/61` has to run first. Migration 61 checks the same evidence
again, including on repeat runs, and blocks unfinished broker-pool
drains. A manual change that bypasses the managed package source is
outside this check.

Existing Kafka 3.x applications move to v4.3. Kafka 4 no longer accepts
clients older than Kafka 2.1. Kafka 4 also rejects the topic settings
`message.format.version`, `message.downconversion.enable` and
`message.timestamp.difference.max.ms`, and a `segment.bytes` below 1 MiB
(1048576), which Kafka 3.x accepted down to 14 bytes. A Kafka 4 broker
whose log holds such a topic does not start. The chart now refuses to
render a topic that sets any of these. The platform upgrade refuses to
start while a Kafka application sets one, and migration 61 also checks
KafkaTopic resources, so topics created outside the chart are caught
too. A topic created through the Kafka admin API without a KafkaTopic is
not visible to these checks. Restoring a topic-metadata backup taken on
Kafka 3.x skips the three removed settings and raises a smaller
`segment.bytes` to 1 MiB, with a warning for each. In-place downgrades
are unsupported. The default 10-minute Helm timeout can leave a long
broker roll Failed until its retry succeeds.

The migration does not run automatically on every platform variant. Only
the `isp-*` variants run it automatically. On other variants, run
`/migrations/61` from the matching migrations image before upgrading, as
the Kafka README describes. This includes clusters that run no Kafka but
have the kafka-operator package, from the `paas` bundle or
`bundles.enabledPackages`. Their Strimzi CRDs still store `v1beta2` even
with no objects. The migration converts Strimzi resources and stored
Helm references to `v1`. It stamps platform version 62. Running it
manually also skips earlier migrations on a later move to an `isp-*`
variant. Before it stops the operators, migration 61 refuses objects
that the Strimzi 0.51 conversion tool would reject and names each one,
for example a Kafka with `.spec.kafka.resources` or with OAuth, Keycloak
or OPA settings. A failed conversion can leave the old operators stopped
until the migration succeeds and the operator release upgrades. The
failed conversion Job stays for diagnosis, but its ClusterRole, binding
and ServiceAccount are removed. A Job that is still running when the
wait times out keeps them, because the retry waits for it.

Known limitations. Migration 61 converts with the old operator stopped,
while Strimzi's conversion guide expects a running operator of 0.49 or
later. I stop it because 0.45 keeps writing the Kafka status through
`v1beta2`, but I have not checked this on a live cluster. Objects
Strimzi created keep `ownerReferences` to `v1beta2` until Strimzi 1.2
reconciles them. Deleting a Kafka before that can leave dependents
behind, and the chart's pre-delete hook covers only StrimziPodSets. The
conversion image is pulled from quay.io by digest with no values
override, so an air-gapped cluster has to mirror it under the same name.

The full offline unit run passed on Linux on
`1171d63adfafb45be34214fb9a0f565723e255fd`: 2,576 cases, no failures,
errors or skipped tests. Later changes were checked on `69c704499fa4`
with the Bats tests for migration 61, the migration runner, the Kafka
hooks and the Kafka backup scripts (102), the platform Helm suite (310
tests) and the Kafka Helm suite (91 tests). After the rebase onto `main`
at `5a5d5cd3d85f`, `a48a2f259947` passes the same Bats tests (115) and
the platform and Kafka Helm suites (326 and 103 tests). It also passes
the new check against added `documentIndex` selectors. I have not
validated this revision on a live cluster.

Closes #4365

### Screenshots

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

Not a UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: https://github.com/cozystack/website/issues/805
- [ ]
[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 Terraform provider does not model the Kafka `version` field. The
website issue covers the upgrade notes the `default` variant needs.

### 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(kafka)!: upgrade to Strimzi 1.2.0 and Kafka 4.3 by default, with Kafka 4.2 also available. Platform migration 61 converts Strimzi resources to v1 and moves Kafka 3.x applications to v4.3. Every Kafka must have confirmed KRaft state before the upgrade, including on repeat runs. Upgrade through Cozystack v1.7 first. Kafka 4 drops clients older than Kafka 2.1 and the message.format.version, message.downconversion.enable and message.timestamp.difference.max.ms topic settings, and requires segment.bytes of at least 1 MiB; the chart and the upgrade refuse a topic that breaks either rule, and a topic-metadata backup taken on Kafka 3.x restores without the removed settings and with segment.bytes raised to 1 MiB. In-place downgrades are unsupported.
```
2026-11-18 13:26:31 +03:00
Andrey Kolkov 7145a67568 fix(backups): stop leaking MariaDB dumps of stuck runs and torn-down namespaces
A k8s.mariadb.com/Backup the BackupJob gave up on stayed for good: no
Backup is made of such a run, so nothing deleted it, and while it stood
short of Complete the dump cleanup counted its open window as a possible
writer of every later dump of the application and kept each of them.

Every failure exit of a started BackupJob in the MariaDB driver now goes
through failMariaDBBackupJob: the deadline, the application, MariaDB CR
or strategy going away, a run the operator failed at Complete=False, and
a run that could not be created. It lists the job's runs on the API
server, where the cache can trail a run created or completed a moment
ago, and deletes each one short of Complete under the UID and
resourceVersion it read, so a run that completes in between is handed
to the success path instead. Deleting the run takes its Job and pod, so
what held the pod up is first copied into the failure message. A
Running or expired job takes its run from that listing and never starts
another, so a retry after a failed status write cannot start a second.

During namespace teardown the operator Backup, which carries no
finalizer, is usually gone before the Backup finalizer runs, and the
cleanup, which read the storage from it, left the dump behind. A Backup
that recorded its dump on the platform bucket now has it deleted with
the platform credentials, which do not go with the namespace, reading
the storage from the snapshot in status.underlyingResources; the dump is
still kept when another run could have written it. The snapshot and the
storage URI now record the storage the run was created with rather than
the strategy as rendered at completion, which a strategy edited during
the run would otherwise send the cleanup away from.

Closes: #5291
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-18 14:08:00 +07:00
Aleksei Sviridkin 045f1a9bbc fix(seaweedfs): remove identities left behind by deleted BucketAccesses
Since SeaweedFS 4.08 the S3 gateways move every identity from
/etc/iam/identity.json into /etc/iam/identities/<name>.json, and the
COSI driver up to v0.3.1 revokes only from identity.json. Every
BucketAccess deleted on such a filer left its identity file behind,
with its keys still accepted (seaweedfs/seaweedfs-cosi-driver#11). A
driver that deletes the file on revoke does nothing for the files
already left.

A post-install/post-upgrade hook removes a ba-<uid>.json file when no
BucketAccess in any namespace names it, by uid or by
status.accountID. The uid covers a BucketAccess still being granted,
the accountID one restored with its status. The identity directory is
listed before the BucketAccesses: a BucketAccess exists before its
grant writes a file, so a file seen in the first listing whose
BucketAccess still exists is always named by the second. File ages are
not used, because grants and gateway migrations rewrite left-over
files as well. A failed or empty listing removes nothing. Each removal
is logged and recorded as an Event on the HelmRelease. The hook runs
before the Object Lock hook, so in delete mode a left-over identity is
removed before that hook grants it anything.

A filer published for Client-topology clusters holds identities whose
BucketAccesses live in those clusters, so cosi.orphanIdentities
defaults to auto: report there, delete otherwise. An operator can
force either.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 22:07:25 +03:00
Aleksei Sviridkin b7ec3f73a1 test(monitoring): keep a non-first-party ref in the Alerta image test
A ghcr.io/cozystack/cozystack ref in a helm-unittest fixture counts as
a first-party image ref, so the image-ref enumeration contracts in
hack/promote-rewrite-tags_test.bats require its file to be declared.
The test only needs some image string to pass through cozy-lib.image,
so a placeholder registry keeps it out of the release tooling.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 18:09:25 +01:00
Aleksei Sviridkin 33d0001991 Merge branch 'main' into feat/monitoring-alerta-respin
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 18:09:25 +01:00
Marian Koreniukandeuroprinter 75df8174df build(monitoring): respin the Alerta image on a patched base
Alerta 9.1.0 is the latest upstream release, and alerta/alerta-web:9.1.0
still carries the Debian packages of its build day, the compiler
toolchain and -dev headers it built its wheels with, and Python
packages whose fixes came out after the release. The monitoring stack
ran that image unpinned.

A purge in a layer on top of the upstream image would leave the files
in the lower layers, so the result is flattened into an empty image
and the upstream image config is restated. cryptography stays below 47
because pyOpenSSL requires it, and lxml stays on 5.x.

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua>
Co-authored-by: europrinter <yanshinjuku@gmail.com>
2026-11-17 18:09:25 +01:00
Aleksei Sviridkin c49f58c4a4 fix(seaweedfs): keep Object Lock working for COSI credentials on SeaweedFS 4.48 (#4893)
## What this PR does

Existing bucket credentials need additional Object Lock actions to work
with SeaweedFS 4.48. Since v0.4.0 (#5284), the upstream COSI driver
grants them to new credentials. It does not grant access again for a
ready BucketAccess, so older identities stay unchanged after the driver
update. The custom COSI driver build and its image repository are no
longer part of this PR.

This PR adds a post-install and post-upgrade hook that grants the
actions implied by each identity's Read and Write permissions. Bucket
restrictions and credentials stay unchanged, and Write does not grant
governance bypass. The `anonymous` identity that public-read buckets
share is skipped on purpose. The driver revokes public read by removing
only `Read:<bucket>`, so added Object Lock reads would stay open to
unsigned requests. The hook runs after the release update and does not
guarantee Object Lock access during a server rollout.

The wrapper chart also declares its local dependency so Helm lint can
check it. The chart remains on 4.45. #4879 is stacked on this PR for the
4.48 upgrade.

The hook's bats suite (22 cases), the chart tests and shellcheck pass
locally on 65708a81b8. The Linux unit lane and E2E are pending. Live
cluster validation has not been run.

Known hook limitations remain tracked in #4894. A pod that never starts
can still fail the Helm action. Deletion between the dry run and apply
can leave a keyless identity. Warning Events expire, and the Job stays
behind for its logs.

### 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(seaweedfs): grant existing bucket credentials the Object Lock actions required by SeaweedFS 4.48 on install and upgrade, preserving their bucket restrictions and credentials.
```
2026-11-17 18:05:41 +03:00
Aleksei Sviridkin 87f160d473 fix(vm-disk, kubernetes-nodes)!: refuse golden images whose import keeps failing (#4802)
## What this PR does

New clones can wait forever on a golden image whose import keeps
failing. CDI v1.66.1 retries ordinary HTTP failures without setting
phase `Failed`.

The guards now also refuse goldens with at least three importer restarts
unless they reached `Succeeded`. kubernetes-nodes and the picker require
`Running=False`; vm-disk refuses during running attempts too. Existing
vm-disks and already-cloned pools remain exempt. CDI never lowers the
restart count, so a healthy import with three early restarts stays
refusable until `Succeeded`, including while a recreated importer is
still starting.

An empty worker-pool StorageClass now resolves to the virtualization
default, then the GA Kubernetes default. Beta is a last fallback for the
class written explicitly onto a worker disk, not a CDI fallback. The
strict same-class policy stays.

This can refuse a previously accepted builtin pool on upgrade. The
affected pool has an empty StorageClass, no cloned disk yet, and a
golden on the Kubernetes default while another class is the
virtualization default. StorageClass is immutable: point
`osImage.builtin` at a catalog entry on the virtualization default or
switch to `osImage.factory`. Already-cloned pools keep their disk's
class.

A VMDisk's own HTTP import, golden-image health checks and imports that
hang without restarting remain outside this change.

Closes #4564

Refs #4059

### Screenshots

No UI changes.

### Downstream repositories

The platform values change only updates a comment. The application
schema change updates the StorageClass description without changing
fields, defaults or enums.

- [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(vm-disk, kubernetes-nodes)!: refuse new clones of golden images whose import has not succeeded after at least three importer restarts. kubernetes-nodes and the image picker require the importer to be not running; vm-disk refuses during running attempts too. kubernetes-nodes now resolves an empty storageClass to CDI's virtualization default before the Kubernetes default. A builtin pool with an empty storageClass, no cloned disk yet, and a golden on a different class can now be refused. Point it at a catalog entry on the virtualization default or switch to osImage.factory. Already-cloned pools are unaffected.
```
2026-11-17 18:05:01 +03:00
Aleksei Sviridkin 638f0ffbe7 feat(redis): add affinity configuration (#2665)
<!-- 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

Adds independent Kubernetes affinity configuration for Redis and
Sentinel pods through `RedisFailover.spec.redis.affinity` and
`spec.sentinel.affinity`. Empty or null rules preserve operator
defaults. Configured rules replace default soft pod anti-affinity;
include `podAntiAffinity` when replica spreading is required.

### Validation

- All 99 chart tests pass with helm-unittest v1.1.2; affected standalone
API package compiles.
- Package generation with cozyvalues-gen v1.7.0 is repeatable; embedded
ApplicationDefinition schema matches the generated values schema.
- Twenty-four offline render scenarios cover default/null/configured
affinity and TLS on/off; Redis checks also cover independent component
rules, single-replica Sentinel behavior, and preservation of upstream
cache configuration.
- Manifest generation, diff checks, and commit trailer checks pass. Each
branch contains one feature commit rebased onto upstream main.
- Root `make generate` remains blocked by the pinned code-generator
parser rejecting Go 1.27's `math/rand/v2` generic method. Affected API
deepcopy generation passes separately with controller-gen v0.16.4;
unchanged files deleted by the failed root generator were restored.
- cozyhr v1.6.1 is installed and checksum-verified. `make show` with
`--plain` still queries Kubernetes discovery, which this environment
cannot access; offline Helm rendering passes.

### Screenshots

Not applicable; no UI changes.

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

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
https://github.com/cozystack/terraform-provider-cozystack/issues/85.
Provider implementation is tracked separately from this application
change.
- [ ]
[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(redis): add affinity configuration for Redis and Sentinel pods.
```
2026-11-17 15:28:41 +03:00
Aleksei Sviridkin 6efc0a0dc9 feat(rabbitmq): add affinity configuration (#2664)
<!-- 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

Adds optional Kubernetes affinity configuration to RabbitMQ pods through
`RabbitmqCluster.spec.affinity`. Empty or null affinity keeps existing
scheduling behavior.

### Validation

- All 106 chart tests pass with helm-unittest v1.1.2; affected
standalone API package compiles.
- Package generation with cozyvalues-gen v1.7.0 is repeatable; embedded
ApplicationDefinition schema matches the generated values schema.
- Six offline render scenarios cover default/null/configured affinity
and TLS on/off.
- Manifest generation, diff checks, and commit trailer checks pass. Each
branch contains one feature commit rebased onto upstream main.
- Root `make generate` remains blocked by the pinned code-generator
parser rejecting Go 1.27's `math/rand/v2` generic method. Affected API
deepcopy generation passes separately with controller-gen v0.16.4;
unchanged files deleted by the failed root generator were restored.
- cozyhr v1.6.1 is installed and checksum-verified. `make show` with
`--plain` still queries Kubernetes discovery, which this environment
cannot access; offline Helm rendering passes.

### Screenshots

Not applicable; no UI changes.

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

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
https://github.com/cozystack/terraform-provider-cozystack/issues/84.
Provider implementation is tracked separately from this application
change.
- [ ]
[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(rabbitmq): add support for configuring RabbitMQ pod affinity rules.
```


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

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

## Summary by CodeRabbit

* **New Features**
* Added an optional affinity setting to control where RabbitMQ pods are
placed, including anti-affinity rules to spread pods across nodes.
* Configured affinity rules are applied to RabbitMQ pods. When affinity
is empty or unset, no affinity rules are added.
* **Documentation**
* Updated RabbitMQ configuration guidance to describe the affinity
setting, its empty default, and how to use anti-affinity to distribute
pods across nodes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-17 15:28:13 +03:00
Aleksei Sviridkin d99e960c00 feat(platform): package address-controller and its MetalLB driver (#3382)
## What this PR does

Adds IP addresses as a first-class resource
([cozystack/community#35](https://github.com/cozystack/community/pull/35))
as two optional system packages, off by default and enabled through
`bundles.enabledPackages`:

- **`cozystack.address-controller`** — the class-agnostic core
([cozystack/address-controller](https://github.com/cozystack/address-controller)):
`IPAddressClass` / `IPAddress` / `IPAddressClaim` in
`local.sdn.cozystack.io`, the PVC/PV-binding analog. It owns
claim–address binding, status and reclaim, and never allocates anything
itself.
- **`cozystack.metallb-iad`** — the per-class driver for addresses
announced by MetalLB
([cozystack/metallb-iad](https://github.com/cozystack/metallb-iad)). A
class names an existing `IPAddressPool` with `autoAssign: false` in
`cozy-metallb`, which the admin provisions together with its
advertisement. The driver holds reservations as placeholder Services in
its own namespace, and attaches an address to a Service that names a
claim with the `local.sdn.cozystack.io/ip-address-claim` annotation.

### Packaging

Both are ordinary wrapper packages under `packages/system/`, sourced
from the `cozystack-packages` artifact like every other package. The
upstream chart is vendored verbatim under `charts/` by `make update` at
a pinned commit, since neither project publishes a chart artifact: the
`v0.2.0` release-preparation commits of
[cozystack/address-controller#17](https://github.com/cozystack/address-controller/pull/17)
and
[cozystack/metallb-iad#11](https://github.com/cozystack/metallb-iad/pull/11).
Each controller image is pinned by digest to a `main-<sha>` build
carrying the same controller code: `address-controller:main-90e65ca`,
whose commit differs from #17 only in chart version and docs, and
`metallb-iad:main-1faf937`, whose commit differs from #11 only in chart
version and the address-controller module pin, a purely additive API
change the driver does not use. The pins move to the `v0.2.0` tags and
images once both are released. The images live under
`ghcr.io/cozystack/<name>`, outside the `ghcr.io/cozystack/cozystack/`
repositories the release tooling owns, so promotion and the nightly
mirror pass over them. The core installs its v1alpha1 CRDs with
`upgradeCRDs: CreateReplace`.

### What the wrappers add

- **Tenant access.** The upstream chart is Cozystack-agnostic and grants
only the controller itself. `cozy:addresses`, `cozy:addresses:view` and
`cozy:addresses:admin` aggregate into `cozy:tenant`, `cozy:tenant:view`
and `cozy:tenant:admin` respectively, so a tenant can manage
`IPAddressClaim`s in its own namespace, and the grant exists only while
the package is installed. The cluster-scoped `IPAddress` and
`IPAddressClass` are not granted: `cozy:tenant*` reaches a tenant
through a per-namespace RoleBinding, so a rule for either would never be
consulted. A tenant reads its address from the claim's
`status.addresses[]`.
- **The driver's admission policy, turned on for tenant namespaces.**
MetalLB honours a pin or pool selector from any writer of a Service: the
`metallb.io/` annotations, their `metallb.universe.tf/` predecessors and
`spec.loadBalancerIP`. A tenant cluster's cloud provider copies a guest
Service's annotations and `loadBalancerIP` onto the Service it creates
in the tenant namespace. The upstream `metallb-iad-service-pins` policy
reserves all of these, plus the sharing annotation, to the driver's
ServiceAccount and the cluster-admin groups. An admission policy binds
every principal regardless of RBAC, so the wrapper adds
`cozystack-cluster-admin`, the group Cozystack's OIDC administrators
authenticate as, to the chart's `system:masters` and
`kubeadm:cluster-admins`. The wrapper enables it in `Deny` mode for
namespaces carrying `namespace.cozystack.io/host`, which `tenant-root`
and every tenant namespace have and nothing in `cozy-*` does. Unchanged
values always pass, so the driver's pin on a tenant's own Service does
not lock the rest of that Service.
- **The driver's MetalLB namespace**, `cozy-metallb` instead of the
upstream default `metallb-system`.

### Variant scoping

`cozystack.metallb-iad` depends on `cozystack.address-controller`, which
is opt-in, and on `cozystack.metallb`, which is absent on `isp-hosted`,
on a slim variant that did not opt into it, and wherever
`disabledPackages` names it. The driver is emitted from the
`common-packages` helper only when the includes of MetalLB and of
`cozystack.address-controller` both rendered a Package, so it cannot be
enabled where it would sit in `DependenciesNotReady` forever, and it
follows either dependency automatically if its rules change. The core
carries no MetalLB dependency and remains available everywhere.

### Validation

`helm unittest` covers the aggregation labels and rules on the tenant
roles and the driver's emission, which requires both MetalLB and the
address core. `hack/select-install.sh --validate` passes, and the
selective-install fixture is regenerated from `hack/select-install.sh
--disabled postgres`. The admission policy is upstream's and carries no
render test here.

### Screenshots

Not a UI change.

### Downstream repositories

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
[cozystack/website#810](https://github.com/cozystack/website/pull/810)
(component cards),
[cozystack/website#811](https://github.com/cozystack/website/pull/811)
(operator guide)
- [ ]
[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 website is the one repository this change reaches:
[cozystack/website#810](https://github.com/cozystack/website/pull/810)
adds the two new platform components to
`guides/platform-stack/_index.md` and
`operations/configuration/licenses.md`, and
[cozystack/website#811](https://github.com/cozystack/website/pull/811)
adds an operator guide under `networking/`. The guide restates both
image refs, so a repin here needs the same edit there.

### Release note

```release-note
feat(platform): add IP addresses as a first-class resource as two optional system packages, `cozystack.address-controller` (IPAddressClass / IPAddress / IPAddressClaim) and its MetalLB driver `cozystack.metallb-iad`. Tenants can reserve an address with an IPAddressClaim. A LoadBalancer Service a tenant Kubernetes cluster creates can name that claim with the `local.sdn.cozystack.io/ip-address-claim` annotation, or draw one through auto-claim once an admin marks an auto-claim class. An admission policy reserves MetalLB's pool, pin and sharing inputs on tenant Services to the driver. The driver is only emitted where MetalLB and the address core are.
```




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

## Summary by CodeRabbit

* **New Features**
* Added address management for requesting and tracking IPv4, IPv6, or
dual-stack addresses, with configurable address classes and lifecycle
status.
* Added the MetalLB IAD driver for address provisioning through MetalLB.
It is included only when the required MetalLB and address-management
components are enabled.
* Added optional admission controls for address claims and protected
MetalLB service settings.
* Added optional address-controller metrics, monitoring, and alerting
resources.
  * Added tenant access roles for viewing and managing address claims.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-17 15:15:03 +03:00
Aleksei Sviridkin a48a2f2599 fix(backups): restore Kafka 3.x topic configs that Kafka 4 rejects
Every Kafka now runs 4.x, and a topic-metadata backup taken on Kafka
3.8 or 3.9 can record message.format.version,
message.downconversion.enable or message.timestamp.difference.max.ms,
which Kafka 4 removed, or a segment.bytes below 1 MiB, the minimum
Kafka 4 raised it to from 14 bytes. A 4.x broker rejects each of them,
so the restore stopped at the first one, leaving that topic
half-configured and every later topic unrestored, and a rerun failed
on the same line.

The restore now skips the removed keys and raises a smaller
segment.bytes to the minimum, each with a warning, and applies the
rest. segment.bytes is read the way Kafka reads it: trimmed, with an
optional sign, leading zeros decimal.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:56 +03:00
Aleksei Sviridkin 4c71273ca8 chore(kafka): declare bundled chart dependencies
Helm requires bundled subcharts to be declared for chart validation.
Keep their source local so validation uses the vendored versions.
The application icon remains supplied by the generated dashboard metadata.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:55 +03:00
Aleksei Sviridkin a909b733ea chore(kafka, kafka-operator): drop the JVM sizing workaround
The workaround passed MaxRAM and ActiveProcessorCount to every Strimzi
JVM because the JDK 17 in the 0.45 images could not see the container
limits on kernels without CONFIG_MEMCG_V1 (JDK-8347811). The Strimzi
1.2.0 images ship JDK 21.0.12, which carries the fix. On such a kernel,
with a 1Gi limit, Strimzi's heap probe in the Kafka image now
estimates a 495M maximum heap, where the 0.45.1-rc1 image estimated
13.9G.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:54 +03:00
Aleksei Sviridkin 641faa7fde build(kafka-operator): vendor Strimzi 1.2.0
Strimzi 0.45 is out of upstream support. Strimzi 1.x serves only the
v1 API, so the release now replaces the CRDs on upgrade;
helm-controller's default of skipping CRD upgrades would leave the
v1beta2-only CRDs from the first install in place. Strimzi 1.x runs no
ZooKeeper, so the ZooKeeper alert group goes too.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:54 +03:00
Aleksei Sviridkin 3b65cebea3 feat(kafka)!: run on the Strimzi v1 API and Kafka 4.x
Strimzi 1.2 serves only the v1 API and runs Kafka 4.2 and 4.3. The
node-pool hook no longer drives the ZooKeeper to KRaft migration or
the drain that freed the shared "kafka" pool name: Strimzi 1.x has no
ZooKeeper support, and the platform migration refuses to upgrade while
a ZooKeeper cluster is left. A cluster migrated earlier keeps its
"kafka" broker pool. Without the drain the hook takes seconds, so the
seven-hour install timeout goes too.

Kafka 4 rejects the topic configs it removed and a segment.bytes below
1 MiB, which Kafka 3.x accepted. A KafkaTopic that sets one stays
NotReady while the release reports Ready, so the chart refuses to
render such a topic. It reads segment.bytes the way Kafka does:
trimmed, with an optional sign, leading zeros decimal.

BREAKING CHANGE: the Kafka application accepts version v4.3 (default)
and v4.2; v3.8 and v3.9 are gone, and the platform migration moves
existing applications to v4.3.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:54 +03:00
Aleksei Sviridkin b6ef231d44 docs(kubernetes-nodes): state why a pool must share its golden's class
The worker image guard, its error message and the storageClass docs
said CDI cannot clone across StorageClasses and always falls back to a
host-assisted copy. CDI falls back only when the two claims have
different CSI drivers or volume modes; with one driver it asks that
driver for a clone into the other class. The guard stays, the reason it
gives is corrected, and the docs name the virtualization default class
an empty storageClass now resolves to.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:20 +03:00
Aleksei Sviridkin 263407a73f fix(api): leave golden images whose importer keeps failing out of the image options
CDI moves an import to Failed only on a fatal error such as a checksum
mismatch, so the picker still offered a golden whose URL is unreachable:
its importer restarts with back-off while the DataVolume stays in
progress. Drop a golden whose importer restarted at least three times
and is not running, the test the kubernetes-nodes chart applies before
cloning.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:18 +03:00
Aleksei Sviridkin 513d250a68 fix(kubernetes-nodes): refuse a golden whose importer keeps failing
The worker image guard refused only a golden in phase Failed, which CDI
reaches on a fatal error such as a checksum mismatch. An unreachable URL
restarts the importer with back-off while the DataVolume stays in
progress, so a pool pinned to such a golden waited forever for its first
disk. Refuse an importer that restarted at least three times and is not
running, under the same already-cloned exemption as Failed.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:17 +03:00
Aleksei Sviridkin 0d239fab81 Merge branch 'main' into feat/kubernetes-nodes-talos-sysctls
The generated cozyrds file is regenerated from the merged values.yaml.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 17:17:33 +03:00
kastakhov 977963dda2 feat(redis): add affinity configuration
Signed-off-by: kastakhov <16296930+kastakhov@users.noreply.github.com>
Assisted-by: LLM
2026-11-16 13:16:29 +00:00
kastakhov a0f85886f2 feat(rabbitmq): add affinity configuration
Signed-off-by: kastakhov <16296930+kastakhov@users.noreply.github.com>
Assisted-by: LLM
2026-11-16 13:14:09 +00:00
Aleksei Sviridkin 416abfd8e2 fix(etcd): scope tenant alerts to their scrape job (#5183)
## What this PR does

scopes every tenant etcd alert to its release scrape job. previously
each release evaluated every tenant, so one failing peer could produce
alerts from unrelated releases. tenant peer RTT is evaluated by the
tenant rules, while the remaining global etcd checks stay in place.

validation: both affected chart test runs pass, 46 tests in 17 suites.
both charts render. an expression-only simulated leader-loss check
against existing metrics selected 18 members across six namespaces
before scoping and only the three intended members afterwards.
thresholds are unchanged.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

no API fields, metric names, package interfaces or documented
workarounds change.

### Release note

```release-note
fix(etcd): scope tenant etcd alerts to their release and avoid duplicate tenant peer RTT alerts from the global rules
```


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

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

## Summary by CodeRabbit

* **Bug Fixes**
* Etcd alerts now match metrics from the exact etcd scrape job,
including slow HTTP requests, reducing the chance of unrelated metrics
triggering alerts.
* The peer communication latency alert excludes tenant etcd scrape jobs,
which are covered by tenant-specific rules.
* **Tests**
* Added checks to validate etcd alert job matching and tenant-job
exclusions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-16 15:15:35 +03:00
Aleksei Sviridkin 65708a81b8 fix(seaweedfs): declare the vendored chart dependency
Helm lint rejects the wrapper chart while its bundled seaweedfs chart is
undeclared. Reference the local chart without constraining its version
so vendoring remains the source of the dependency.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 13:28:42 +03:00
Aleksei Sviridkin ca0fcb1c05 Merge branch 'main' into fix/etcd-alert-scope-20261102
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 13:28:42 +03:00
Aleksei Sviridkin 78e21fefcc fix(seaweedfs): grant Object Lock actions to existing S3 identities
SeaweedFS 4.48 requires dedicated Object Lock actions, but upgrading the
COSI driver does not re-grant access for ready BucketAccesses. Add the
actions implied by existing Read and Write grants after install and
upgrade, without changing credentials or granting governance bypass.

The anonymous identity that public-read buckets share is skipped: the
COSI driver revokes public read by removing only Read:<bucket>, so
derived Object Lock reads would stay open to unsigned callers.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 13:28:42 +03:00
Aleksei Sviridkin 1e5e532737 Merge branch 'main' into feat/monitoring-email-template
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 13:24:49 +03:00
Timofei Larkin 39918b7a72 feat(platform): package the address-controller and its MetalLB driver
Two optional system packages bring in IP addresses as a first-class resource
(cozystack/community#35): cozystack.address-controller, the class-agnostic
core (IPAddressClass / IPAddress / IPAddressClaim, local.sdn.cozystack.io),
and cozystack.metallb-iad, the driver implementing the contract for addresses
announced by MetalLB.

Both follow the umbrella shape: the upstream chart is vendored under charts/
from cozystack/address-controller and cozystack/metallb-iad, and what belongs
to Cozystack rather than to a generic Kubernetes controller lives in the
wrapper. Neither project publishes a chart artifact, so each `update` target
clones at a pinned commit, and the wrapper pins the image built from the
same controller code by digest; the charts' own floating :main defaults
would otherwise leave the controllers free to move underneath a cluster.

The wrapper carries the tenant grant. The upstream chart is Cozystack-
agnostic and grants only the controller, so nothing there lets a tenant use
the API it serves; cozy:addresses, cozy:addresses:view and cozy:addresses:admin
aggregate into the platform's base tenant roles, which resolve by label, so
the grant is present exactly while the package is. Only IPAddressClaim is
granted: the other two kinds are cluster-scoped and cozy:tenant* reaches a
tenant through a per-namespace RoleBinding, so a rule for either could never
be consulted.

The wrapper also turns on the driver's admission policy for tenant
namespaces. MetalLB honours a pin or pool selector from any writer of a
Service, through its current annotations, their metallb.universe.tf
predecessors and spec.loadBalancerIP alike, and a tenant cluster's cloud
provider copies a guest Service's annotations and loadBalancerIP onto the
Service it creates in the tenant namespace. Without the policy, a tenant
could steer MetalLB at an address reserved for someone else. Tenant
namespaces are the ones carrying namespace.cozystack.io/host, which
tenant-root and the tenant chart set and nothing in cozy-* does. An
admission policy binds every principal regardless of RBAC, so the
allowlist names Cozystack's OIDC administrators, cozystack-cluster-admin,
beside the chart's own two admin groups.

The driver points at cozy-metallb instead of the upstream default
metallb-system. Its PackageSource declares dependsOn on the core, whose CRDs
it needs, and on cozystack.metallb. The core installs with upgradeCRDs:
CreateReplace since its CRDs are v1alpha1 and still evolving. Neither package
is in the postgres E2E install closure, so both join the selective-install
fixture's disable list.

Assisted-by: LLM
Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
2026-11-16 06:49:47 +01:00
Aleksei Sviridkin 6edd4a0d72 chore(deps): update container base images
Refresh the base image digests and move each tag to a newer release
that builds: node 24 for the dashboard console and its UI test job,
nginx-unprivileged 1.31, the dockerfile 1.28 frontend and alpine 3.24
for the cilium patch stage.

The kubevirt CSI driver stays on AlmaLinux 9: AlmaLinux 10 builds its
amd64 userland for x86-64-v3, and on a tenant vCPU without it every
mkfs, blkid and mount the node service runs would fail. shadowbox stays
on node 18 because outline-server declares engines node 18.x. The e2e
sandbox stays on Ubuntu 24.04: 26.04 ships uutils coreutils, whose
`date` costs about 4x per call, and the test harness forks it per
traced line, which adds about ten minutes to the install phase. Bases
whose version is the upstream component itself, or that upstream's
build pins, are not touched.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:39 +03:00
Aleksei Sviridkin ee0071dd1b chore(deps): update Go modules and move them to go 1.27.2
The five Go modules move to go 1.27.2. The root module moves to
controller-runtime v0.25.2, gateway-api v1.6.3 on the minor of the
installed v1.6.1 CRDs, grpc v1.84.0, etcd v3.7.2, cert-manager v1.21.2
and newer golang.org/x modules; prometheus/client_golang v1.25.0 raises
klauspost/compress to v1.20.1 by minimal version selection.
kubevirt-csi-driver builds upstream csi-driver f10ae94 against
Kubernetes v0.37.1, with its require and replace now naming the same
commit, kubeovn-webhook moves to client-go v0.37.1, and token-proxy to
newer releases of its dependencies.

Several stay behind, each for a stated reason. cel-go stops at v0.30.0:
its old repository has no tag past it, and v0.32 declares a module path
k8s.io/apiserver does not import. kube-openapi past the pinned commit
needs structured-merge-diff v7, which k8s.io/apimachinery v0.37 does not
compile against. The Flux API modules stay on the Flux v2.8 line the
platform installs. kubevirt.io/api and the CDI API stay on the releases
upstream csi-driver builds against, and jwx stays on v3 because v4
removes the jwk.Cache the proxy's JWKS refresh uses.

cert-manager v1.21 drops the deprecated ObjectReference alias, so the
gateway controller names IssuerReference directly; the Certificate
objects serialize the same for the installed v1.20 chart. gateway-api
marks SchemeGroupVersion deprecated, so a gateway test builds its
GroupKind from GroupName.

api/apps/v1alpha1 moves to go 1.27.2 with the rest, so a module that
imports the published types needs Go 1.27.2 or later.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:38 +03:00
Aleksei Sviridkin 2a04bfd0db build(go): move the builder images to Go 1.27.2
The golang builder images move to the 1.27.2 digests of their 1.27
tags, and the one image pinned to golang:1.27.1 moves to
golang:1.27.2. Builds that reproduce an upstream release keep the Go
that upstream uses.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:37 +03:00
Aleksei Sviridkin 29fb27461e fix(dashboard): refresh the token proxy session cookie
securecookie encodes sessions with gob, so the issued and expires times
come back as int64. The refresh looked for a float64, found none and
never fired, so --cookie-refresh=1h, which the chart sets, did nothing.
The times are now read in either form.

A refreshed cookie keeps the token's expiry: it gets a new issued time
and a fresh securecookie timestamp, never a longer life than the token
inside it.

Encoding a session fails when it outgrows securecookie's maximum
length, which a large token can reach. Sign-in set an empty cookie in
that case, and the refresh, now that it runs, would have replaced a
working cookie with an empty one. Sign-in now shows an error instead,
and a refresh that cannot encode leaves the current cookie in place.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:35 +03:00
Aleksei Sviridkin 3cd2778ac0 fix(kubeovn-webhook): reject an admission review that carries no request
A body without a request field dereferenced a nil pointer. net/http
recovers the panic, so the caller saw a dropped connection instead of
a 400, and every such call logged a stack trace.

The namespace lookup becomes a package variable so the tests can stand
in for the cluster.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:35 +03:00
Aleksei Sviridkin c1740e7631 test(tests): select resources in absence-only Helm checks (#5174)
## What this PR does

Select the intended resource by kind or name in 23 absence-only Helm
tests: the 21 cases catalogued in #4665, a newer MariaDB backup-script
case, and Kafka's JVM-options case. The requested
kubernetes-nodes/nodegroup and OpenSearch TLS audit found no remaining
unanchored negative-only cases.

Add a diff-based CI guard against new positional selectors in
first-party suites on templates with multiple literal resource blocks.
It preserves single-document uses and unchanged indices, including pure
suite renames; renamed suites are still checked for added index lines.
It follows Helm's template and index precedence, and its fixtures use
portable file writes. The guard runs after the test steps so a guard
failure cannot suppress their results.

The guard is intentionally static: it counts `---`-separated blocks with
a top-level `kind`, not resources produced by helpers or ranges, and
does not evaluate whether whole-document branches are mutually
exclusive. It does not audit vendored suites or existing indices when a
template later gains documents.

Validation:
- `make helm-unit-tests` passes: 106 package test targets, 556 Helm
suite executions, and 4,067 Helm tests, including the dashboard
package’s additional Go checks.
- All 51 focused BATS checks pass. The full BATS sweep initially passed
2,435 of 2,500 cases; six graph-selection failures were then resolved by
using the repository-pinned yq v4.53.3 (127/127 targeted rerun cases
pass). The remaining 56 Docker-dependent and three envsubst-dependent
cases are blocked by missing host prerequisites; no full BATS pass is
claimed. The six yq-related failures also reproduce on the unchanged
base with the older tool and pass with the pinned version.
- All 17 guard regression tests pass, including first-party scope,
inherited index precedence, pure/edited renames, template overrides,
nested default templates, conditional kinds, and multiline index values.
- Missing-target mutations cover all 23 selector changes: original cases
pass against unrelated resources; updated cases fail with `document not
found`.
- Reordered violating-target mutations cover all 22 formerly positional
cases: originals pass against leading unrelated resources; updated cases
find the intended target and fail their content assertion. Kafka's
updated case also passes when the reordered Job remains valid.
- Empty-render mutation confirms that the newer MariaDB backup-script
case previously passed without a document and now fails. Existing
positional cases already fail on an entirely empty render.
- The changed workflow passes the repository-pinned zizmor v1.26.1
offline audit; `git diff --check` is clean.

Closes #4665

### Screenshots

Not applicable (tests and CI only).

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


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

## Summary by CodeRabbit

* **Chores**
* Pull request checks now flag positional document selections in Helm
tests when they target multi-document templates.
* **Bug Fixes**
* Updated chart tests to select Kubernetes resources by kind or name
rather than document position, keeping assertions focused on the
intended resources.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-15 05:59:52 +03:00
Aleksei Sviridkin da17254bbc fix(kubernetes): bring up a replacement worker before draining the old one (#5153)
<!-- 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

Worker pool MachineDeployments roll out with `maxUnavailable: 1`. CAPI
therefore drains and deletes an old Machine as soon as its replacement
Machine has been created, not once the replacement has joined. Observed
on a one-node pool changing instance type (`s1.large` to `s1.medium`):
the new Machine was created at 13:07:19, the old node was drained and
deleted 17 s later, and the new node was Ready around 13:11, so the pool
had no node for about four minutes. Larger pools lose one node of
capacity at every step of the rollout for the same reason.

This sets `maxUnavailable: 0`, so a node is drained only once its
replacement is up. `maxSurge` stays at the pool ceiling (`maxReplicas`),
with a floor of 1: CAPI rejects a RollingUpdate where both values are 0,
and `maxReplicas: 0` is accepted by the schema.

Exception: a pool with `gpus` keeps `maxUnavailable: 1`. Its replacement
VM may need the very passed-through GPU the old node holds, and with
`maxUnavailable: 0` it would stay Pending and the rollout would never
finish. A Proxmox pool that passes GPUs through its template carries no
`gpus` value, so the chart cannot recognise it: the new optional
`maxUnavailable` value lets such a pool (or any pool) set the strategy
explicitly, and set to 1 restores the drain-first behaviour.

The value is bounded to 0..2147483647, since CAPI decodes it as an
int32. ComputePlane pools render through the same chart, so
`packages/extra/computeplane` exposes `nodeGroups.<pool>.maxUnavailable`
and its allowlist forwards it.

Trade-off: a rollout now needs room for at least one extra VM. A tenant
at its quota stalls the rollout (the new Machine stays Pending) instead
of temporarily shrinking the pool, which is the safer failure.

Tests: `tests/rollout_strategy_test.yaml` (7 cases: the default, the
ceiling, a zero ceiling, a GPU pool, and the explicit override) fails on
`main` without the template change; the render snapshot is updated. Two
more cases cover the int32 maximum, accepted at 2147483647 and refused
one above. `helm unittest packages/apps/kubernetes-nodes`: 252 passed.
`packages/extra/computeplane/tests/cluster_test.yaml` checks that the
wrapper forwards `maxUnavailable` (it fails without the allowlist entry)
and refuses a value above the int32 range: 15 passed.

Backport: on `release-1.6` the same strategy is also rendered by
`packages/apps/kubernetes/templates/cluster.yaml` (the in-chart
`nodeGroups`), and the snapshot file does not exist there, so the
automatic backport cannot apply. A manual backport PR to `release-1.6`
covering both charts follows. `release-1.7` keeps `kind/backport`.


### Screenshots

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

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: cozystack/terraform-provider-cozystack#79 (tracking issue:
the provider change is out of scope here). `cozystack_kubernetes_nodes`
has no attribute for the new `maxUnavailable`, so a Terraform-managed
pool cannot drain first; the provider has no ComputePlane resource yet.
- [ ]
[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): worker pool rollouts (instance type, image or version changes) now bring each replacement node up before draining the old one, instead of removing a node first. A rollout needs room for one extra VM. Pools with GPUs keep the previous behaviour.
```


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

## Summary by CodeRabbit

* **New Features**
* Added a pool-level `maxUnavailable` setting to control how many
workers may be removed before replacements are ready. It defaults to 0
for non-GPU pools and 1 for GPU pools; configured values override these
defaults.
* Proxmox pools passing through GPUs can set `maxUnavailable` to 1 to
help prevent rollouts from waiting indefinitely.
* **Bug Fixes**
* Rolling updates now use at least one surge node, even when the replica
limit is zero.
* **Documentation**
  * Documented rollout settings, defaults, and capacity considerations.
* **Tests**
* Added coverage for defaults, overrides, surge limits, and invalid
values.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-15 02:48:13 +03:00
Aleksei Sviridkin 46cb99df5b fix(controller, platform): give unbounded pool members the root's LimitRange (#5265)
## What this PR does

Since tenant quotas became hierarchical (#3086), an unbounded sub-tenant
(no `resourceQuotas` of its own) shares its parent's pool and receives a
controller-owned `tenant-quota-allocated` ResourceQuota. The tenant
chart, however, renders the `tenant-range-limits` LimitRange only next
to the `tenant-quota` of a tenant that declares `resourceQuotas`, so
these namespaces end up with a quota on `limits.cpu`/`limits.memory` and
no container defaults. Admission then rejects every container that omits
one of those limits.

Pods that predate the quota keep running and fail as soon as they are
recreated. In production this took down CNPG postgres instances with
backups enabled: the `plugin-barman-cloud` sidecar injected by the
barman-cloud plugin sets CPU and memory requests and a memory limit but
no CPU limit, so the instance pod is refused on its next restart. The
same happened to the tenant `kubernetes` app: the `wait-for-kubeconfig`
init container of `cluster-autoscaler`, `kcsi-controller` and the
`bootstrap-token` jobs has no resources, so their ReplicaSets and Jobs
were refused with `failed quota: tenant-quota-allocated: must specify
limits.cpu` in every unbounded sub-tenant hosting a tenant cluster. On a
production cluster, 131 tenant pods currently get their CPU or memory
from the tenant LimitRange (VictoriaMetrics
`config-init`/`config-reloader`, Harbor exporter, MariaDB agent, Strimzi
entity operator, among others), so the defect is not specific to one
chart: any of them breaks once it lands in such a namespace. Workloads
that set every limit explicitly are unaffected.

The controller already decides which namespaces it clamps, so it now
copies the pool root's chart LimitRange into each unbounded member whose
allocated quota bounds `limits.cpu` or `limits.memory` as
`tenant-range-limits-allocated`, keeps it in step with the root, and
deletes it once the namespace leaves the pool (for instance when the
sub-tenant declares its own quota and the chart renders its own
LimitRange). The chart renders its LimitRange under any non-empty
`resourceQuotas`, including one that bounds no compute (#4930), so the
copy is limited to members whose quota bounds a compute limit: elsewhere
it would impose a 128Mi default memory limit the quota never asked for
and refuse pods, virt-launcher among them, that are admitted today. This
keeps the change independent of #4954. The copy has its own name so that
Helm can still create the chart-owned object in that case without an
ownership conflict. The root is the single source of truth for the
defaults, so the values stay defined in
`packages/apps/tenant/templates/quota.yaml` only. The controller gains
`limitranges` RBAC and watches the two LimitRange names so a change
propagates without waiting for the 60 s resync.

Tests: five reconciler cases cover a member under a non-compute quota
(no copy, and a stale one removed), the copy into an unbounded member
(and not into the root), propagation of a change on the root, garbage
collection once the member is bounded (the chart-owned object is left
alone), and a root without a LimitRange. Disabling the copy makes the
first two fail.

### Screenshots

Not a UI change.

### Downstream repositories

Walked the trigger map against the diff. The code touches only
`internal/controller/tenantquota/` and the `cozystack-controller` RBAC
template, but the website's `system-memory-limits.md` states that tenant
namespaces get defaults only from the chart's `tenant-range-limits`,
which this change makes untrue; the follow-up is an issue, since the
page should change once this is merged.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#806
- [ ]
[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(controller, platform): sub-tenants without their own resourceQuotas now receive their parent pool's container defaults (LimitRange) alongside the allocated quota, when that quota bounds a CPU or memory limit, so pods that omit such a limit, such as the postgres barman-cloud backup sidecar, are no longer rejected at admission.
```


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

## Summary by CodeRabbit

* **New Features**
* Unbounded pool members now receive their pool’s CPU and memory limit
settings when their allocated quota sets those limits. Pool setting
updates are reflected in members during reconciliation.
* When a member has its own quota, inherited limit settings are removed
while settings configured directly for that member remain unchanged.
* No inherited settings are created when the pool has no limit settings
or the allocated quota does not set CPU or memory limits.
* Existing inherited settings are retained if an update temporarily
fails.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-15 02:33:34 +03:00
Aleksei Sviridkin eafe1adde5 Merge branch 'main' into feat/kubernetes-nodes-talos-sysctls
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-14 03:55:52 +03:00
Aleksei Sviridkin f8217be501 Merge branch 'main' into chore/cilium-drop-unread-values
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-14 03:55:46 +03:00
Aleksei Sviridkin 3ede7c4d33 feat(observability-proxy): include platform exporter series in the namespace root (#5277)
<!-- 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 #5219 and #5220, both merged.

The namespace metrics root
`/apis/cozystack.io/v1alpha1/namespaces/<ns>/metrics/...` now also
returns series that a platform exporter attributes to `<ns>`. Example:
the ClickHouse operator's exporter runs in `cozy-clickhouse-operator`.
vmagent scrapes it without `honorLabels`, so its series carry
`namespace="cozy-clickhouse-operator"`, and the tenant namespace the
exporter reported moves to `exported_namespace="<ns>"`. Until now, any
client of the namespace root (kubectl, automation, the console) never
saw those series.

### Behavior changes

- Namespace root, every endpoint (`query`, `query_range`, `series`,
`labels`, `label/<name>/values`):
  - was: one proxy-set `extra_filters[]={namespace="<ns>"}`;
- now: two values, `{namespace="<ns>"}` and
`{namespace=~"cozy-.*",exported_namespace="<ns>"}`. vmselect ORs them.
- Label APIs without a client `match[]`: the proxy already repeats the
scope in `match[]` for `-search.ignoreExtraFiltersAtLabelsAPI`; it now
repeats both values. vmselect ANDs every `match[]` with every
`extra_filters[]`. Each cross pair is narrower than one of its halves,
so the result is still exactly the union.
- Client `extra_filters`, `extra_filters[]` and `extra_label` are still
dropped.
- New flag `--metrics-platform-namespace-prefix` (default `cozy-`) and
chart value `observabilityProxy.metrics.platformNamespacePrefix`. An
empty value turns the second branch off and restores the single-value
scope. The proxy quotes the prefix and anchors it, so the value is
matched literally and cannot become a wider regex. The flag accepts only
namespace name characters, because any other value would match no
namespace and silently drop the exporter series.
- Exporter series keep `namespace="cozy-..."`. A query that also selects
`namespace="<ns>"` excludes them; select them by `exported_namespace` or
by the exporter's own labels (for ClickHouse, `chi`).
- The branch is not specific to ClickHouse. For example,
kube-state-metrics in the platform monitoring namespace sets
`exported_namespace` from `metadata.namespace` on the Flux
`gotk_resource_info` series
(`packages/system/monitoring-agents/values.yaml`), so a namespace root
now also returns the state of that namespace's own HelmReleases and
Kustomizations. This is the namespace's own data, but it is a visible
change with the default prefix.
- Queries grouped `by (namespace)` can now return an extra group
labelled with the exporter's platform namespace. The exporter's series
also carry its own target labels (`pod`, `instance`, `job`) into the
tenant's results.
- An empty scope is refused with 500 instead of forwarding a request
without `extra_filters[]`.
- The application roots of #5220 are not affected: they replace the
scope with their own selectors.

### Threat model

1. **Scrape path.** vmagent sets `namespace` from service discovery,
while `exported_namespace` is whatever the exporter wrote. Any tenant
pod can write a `namespace` label, which arrives as
`exported_namespace`, so the extra branch only trusts it on series
scraped from platform namespaces. Tenant roles
(`packages/system/cozystack-basics/templates/clusterroles.yaml`) grant
no access to `operator.victoriametrics.com` and no verbs on `Namespace`.
A tenant can therefore neither run a target in `cozy-*` nor point a
scrape object at one.
2. **Remote-write writers.** A tenant's nested Kubernetes cluster runs
its own vmagent, which remote-writes into the same store when the tenant
has no monitoring of its own, and the labels it writes are not enforced.
Inside that cluster the tenant can create `cozy-*` namespaces or any
other, so it can already write `namespace="<any ns>"` and pass the
existing single filter. This is an existing limitation that this PR
neither introduces nor widens: anything that can write
`namespace="cozy-x",exported_namespace="<ns>"` can write
`namespace="<ns>"` directly. Closing it needs enforcement on the write
path and is out of scope here.
3. **Impact of a forged series.** The scope only adds series to a
namespace's results; it never lets a caller read another namespace. A
forged series can spoil or flood another namespace's graphs, up to the
series limits that answer 422.

### Rejected alternatives

- **Bare `{exported_namespace="<ns>"}`.** Every namespace is scraped by
default, so any tenant pod could inject series into another namespace's
root.
- **Relabeling the ClickHouse operator's scrape so that `namespace`
carries the tenant namespace.** It fixes one exporter at a time, each in
its own chart, and it changes the label set of every existing series,
which splits their history at the change and breaks any query that
selects them by the operator's namespace. The proxy-side branch covers
every platform exporter and leaves stored series as they are.
- **Scraping the ClickHouse pods directly.** The metric names differ
from the operator's exporter, so the shipped ClickHouse dashboard
(`dashboards/clickhouse/altinity-clickhouse-operator-dashboard.json`),
which reads the exporter's `chi_clickhouse_*` series, would have to be
rewritten.
- **A free regex flag instead of a prefix.** One typo (`.*`) would trust
`exported_namespace` from every namespace.

### Tests

- Table of namespace-root requests: exactly two `extra_filters[]` values
in order with the default prefix, one value with an empty prefix, on all
five endpoints. Client `extra_filters[]` still dropped.
- A model of vmselect's selection (OR over `extra_filters[]`, AND with
each `match[]`) shows that `namespace=cozy-x, exported_namespace=<ns>`
is visible, and that `namespace=tenant-y, exported_namespace=<ns>` and
`namespace=xcozy-a, ...` are not.
- Escaping of `<ns>` in `exported_namespace`, literal prefix quoting,
empty scope refused, flag validation, and a chart test that an empty
value reaches the binary as an explicit empty flag.

### Screenshots

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

Not a UI change.

### Downstream repositories

<!--
Cozystack is upstream for repositories that are NOT kept in sync with it
automatically, and nothing in CI compares the two sides, so a change
here can break them silently.

Which change forces what, and which file to touch, is the trigger map in
docs/agents/contributing.md under "Downstream Repositories". Walk it
before you tick anything.

IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM
TO FILL IN:

1. Walk the trigger map against the actual diff of this PR, file by
file. Do not decide from the PR title or from your memory of what you
changed.
2. For every repository you tick, open the follow-up PR there and link
it on the same line. A ticked box with no link claims work that does not
exist, which is worse than an empty box. Search that repository for an
open PR or issue covering it first, and link that instead of filing a
duplicate.
3. When the follow-up is out of scope, or needs a decision that is not
yours to make, open an issue in that repository instead, link that, and
say so in the PR body. Do not push a speculative PR into another
repository just to fill a line here.
4. Do not tick "No downstream repository is affected" to make the
checklist go away. If you are unsure, leave every box empty and say so
in the PR body, so a human decides.
-->

- [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 touches only `cmd/observability-proxy`,
`internal/observabilityproxy` and the system package
`packages/system/observability-proxy` (a new value and flag, no app,
platform values, CRD, `hack/` or naming change). None of the triggers in
`docs/agents/contributing.md` under "Downstream Repositories" apply.

### 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(observability-proxy): the namespace metrics root also returns series that exporters in platform (`cozy-*`) namespaces attribute to the namespace through `exported_namespace`, such as the ClickHouse operator's. The prefix is set by `--metrics-platform-namespace-prefix` / `observabilityProxy.metrics.platformNamespacePrefix`; an empty value disables it.
```


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

## Summary by CodeRabbit

* **New Features**
* Metrics queries now include series attributed to a tenant namespace by
exporters in platform namespaces with the configured prefix. The default
prefix is `cozy-`; setting it to an empty value disables this behavior.
* Namespace scoping is applied across supported metrics endpoints,
including label lookups.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-14 02:44:48 +03:00
Ahmed Kamal b1e067f6e1 chore(tests): merge upstream main into resource selector branch
Preserve the Helm selector guard alongside main's independently gated
backport tests when refreshing the branch's upstream base.

Validated with actionlint and 31 focused Bats tests.

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Assisted-by: LLM
2026-11-14 00:58:47 +02:00