Commit Graph
1683 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
Marian Koreniuk cfb5119c0b feat(build): attach a provenance attestation beside the SBOM (#5043)
## What this PR does

Follow-up to #4997 (merged as d32092ac9), rebased onto `main` at that
merge: one commit `57db352ed`. The second half of what was agreed there:
beside the SBOM, each release image gets a SLSA provenance statement
from BuildKit, in the same attestation manifest.

Refs #4759, #3278

`SBOM=1` in `hack/common-envs.mk` now passes `--attest
type=provenance,mode=min` with the SBOM attest, in place of
`--provenance=false`; a build without `SBOM=1` keeps
`--provenance=false` as before. BuildKit writes both predicates into the
one attestation manifest per platform, so the index shape
`hack/stitch-multiarch.sh` and `hack/verify-multiarch.sh` read after
#4997 is unchanged, and a signature over the index covers the provenance
as it covers the SBOM. `mode=min` records the build times, the build
platform, the frontend and the BuildKit version and leaves out the build
arguments and the secrets, which `mode=max` would write in, so it can
ride every release image. `docker buildx imagetools inspect
<image>@<digest> --format '{{ json .Provenance }}'` prints it;
`docs/release.md` says so.

### How it was checked

- `hack/common-envs_test.bats`: the `SBOM=1` test now also holds that
`--attest type=provenance,mode=min` is passed, that `--provenance=false`
is not, that neither `mode=max` nor `--provenance=true` appears, and
that the default build still passes `--provenance=false` and no
`--attest`. `make -n` of `packages/system/cozystack-controller` shows
exactly that in both modes. `hack/stitch-multiarch_test.bats` is green:
the attestation manifest count per platform does not change.
- A real build, by @myasnikovdaniil on a local registry: amd64 and arm64
built with the flags from `common-envs.mk`, stitched,
`verify-multiarch.sh` passes, the index has four manifests (two images,
two attestation manifests with SBOM and provenance each), `.Provenance`
reads for both platforms, and a `--build-arg` value is in `mode=max` and
not in `mode=min`.
- Rebased on `main` at d32092ac9: `hack/common-envs_test.bats` and
`hack/stitch-multiarch_test.bats` 34/34.
- Not checked: the provenance predicate on a release runner. The first
alpha after the merge shows it.

### Decisions for the release owners

- `mode=min` rather than `mode=max`: the Dockerfiles take `--build-arg`
values a reader of a public attestation should not see by default. If a
package's arguments are all public, `max` is one word away.
- `docs/security/self-assessment.md` still says build provenance is
disabled (`--provenance=false`). It stays until the first alpha shows
provenance on a release image, as #4997 holds its SBOM row.
- PR, main and nightly builds stay without provenance, as they stay
without an SBOM: nothing reads it there, and the default docker driver
cannot attach it.

### Screenshots

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

### Downstream repositories

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

I walked the trigger map against the diff. `hack/common-envs.mk` changes
the flags one variable expands to and no target, variable name or file
that ccp's skills anchor on; nothing else is touched.

### Release note

```release-note
feat(build): every release image built with `SBOM=1` also carries a SLSA provenance statement (BuildKit `mode=min`: build times, platform, frontend and BuildKit version, no build arguments or secrets) in the same attestation manifest as its SBOM, readable with `docker buildx imagetools inspect <image>@<digest> --format '{{ json .Provenance }}'`.
```



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

## Summary by CodeRabbit

* **New Features**
* Container builds with SBOM generation enabled now include both an SPDX
software bill of materials and a minimal SLSA provenance attestation.
  * Provenance attestations remain disabled when SBOM generation is off.

* **Documentation**
* Updated the container image security guide with details on provenance
contents and how to inspect the attestation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-20 10:32:33 +01:00
Andrey Kolkov 421dc2a0a7 test(dashboard): require the exact hint in the e2e redirect check
The case pattern *kc_idp_hint=e2e-idp* also accepted e2e-idp-other
and xkc_idp_hint=e2e-idp. Match the parameter as a whole: preceded by
&, followed by & or the end of the URL.

Assisted-By: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-19 20:44:54 +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 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
Aleksei Sviridkin 5a92f1fc4e Merge branch 'main' into feat/build-provenance-attestation
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-18 11:55:28 +03: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 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 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 f293d64e84 fix(kafka): delete the release's StrimziPodSets on uninstall
On a cluster upgraded from Strimzi 0.x, deleting a Kafka application
leaves its brokers running. kube-controller-manager's garbage collector
first saw the StrimziPodSets under v1beta2 and never updates that
record, so once v1beta2 is no longer served it retries them forever
instead of deleting them, until kube-controller-manager restarts
(kubernetes/kubernetes#102641).

The pre-delete hook now deletes the release's StrimziPodSets after its
node pools, so uninstall no longer depends on garbage collection for
the brokers. An absent CRD is not a failure; any other error fails the
hook like the pool delete does, because Helm never runs it for the
release again.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:22:55 +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 af0db99c71 feat(platform): move Strimzi resources to the v1 API before Strimzi 1.x
Strimzi 1.0 removed v1beta2 from its CRDs, and the API server refuses
a CRD that drops a version its status still lists as stored. Every
stored object has to be rewritten as v1 before the new operator
arrives, which needs the CRDs of Strimzi 0.49 to 0.51 that serve both
versions and Strimzi's own conversion tool. The 0.45 operator is
stopped first: Strimzi supports the conversion only under an operator
that knows v1, and 0.45 keeps rewriting the Kafka status through
v1beta2. The conversion Job's ClusterRole can patch CRDs and write
ConfigMaps in every namespace, so it goes with its binding and
ServiceAccount once the Job has finished, successfully or not; a
failed Job stays for diagnosis, and a Job still running when the wait
times out keeps them, because the retry waits for that Job.

Two references to v1beta2 outlive the stored objects. Helm builds the
objects of a release before it upgrades or uninstalls it, so every
stored revision of every Kafka application is rewritten to v1. And the
API server refuses server-side apply to an object whose managedFields
still name a version the CRD no longer serves; when helm-controller
recovers by wiping them, a field a later chart drops is never removed.
Those entries move to v1 as well. A Helm action already running stores
the releases it read when it finishes, v1beta2 included, so the version
is not stamped while any Kafka release revision is still pending.

Strimzi 1.x also runs neither ZooKeeper nor Kafka 3.x. A ZooKeeper
cluster, or a shared broker pool still being drained, left by a
platform that moved past v1.7 before its ZooKeeper to KRaft migration
finished cannot be finished afterwards, so the migration stops
instead; Kafka applications on v3.8 or v3.9 move to v4.3. The
migration also stops, before it changes anything, while a Kafka
application topic or a KafkaTopic sets a config Kafka 4 removed or a
segment.bytes below the 1 MiB minimum of Kafka 4: the new kafka chart
refuses to render such a topic, and a Kafka 4 broker whose log holds
the small segment.bytes does not start. segment.bytes is read the way
Kafka reads it: trimmed, with an optional sign, leading zeros decimal.

Strimzi's conversion tool refuses some v1beta2 objects outright, and
convert-resource stops at the first one, with the operators already
stopped. While v1beta2 is served the migration lists every Strimzi
kind first and refuses, naming each object and the reason, before it
stops anything. The list follows the 0.51.0 tool the conversion Job
runs, and a test fails when that image changes.

The conversion deletes the Kafka's KRaft metadata state, and KRaft is
the state Strimzi never leaves. Before it stops the operators, the
migration records an annotation on every Kafka it accepts, so a retry
after the conversion still accepts a NotReady Kafka that passed on
its KRaft state.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 12:02:45 +03:00
Aleksei Sviridkin 76d68a919f test(e2e): pin the importer restarts an unreachable VMDisk reports
The kubernetes-nodes guard and the image option list call an import
failing once its importer has restarted three times and is not running,
and the vm-disk guard once it has restarted three times, because CDI
keeps an unreachable URL in progress instead of moving it to Failed.
Assert that CDI reports both on the DataVolume of the unreachable
VMDisk, so a CDI change that stops doing so turns this suite red rather
than leaving the guards blind.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-17 11:20:21 +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 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
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 a7e0a6e187 ci(workflows): move GitHub Actions to their Node 24 majors
Most of the official actions move one or more majors, onto the Node 24
runtime. The inputs these workflows pass are still accepted, and the
contract tests that pin the checkout and App token commits follow.

Since checkout v6 the persisted token lives in a separate config file,
so unsetting the extra header in .git/config no longer removes it. The
release job's checkout stops persisting credentials, so its staging
branch push goes out with the App token, and a contract test guards
that setting.

The flux action stays on v2.8.6, whose tag has to equal the Flux CLI
version it installs. A self-hosted runner needs v2.327.1 or newer for
the Node 24 checkout, which the Proxmox workflow now states next to its
runs-on.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-16 01:07:37 +03:00
Aleksei Sviridkin 9cd2d3ac0f test(ci): smoke-test the tools that built images take from their base
The CSI, LINSTOR, multus, Harbor and redis-backup images call tools at
runtime that their base images or build stages install: mkfs and
mount.nfs, drbd, lvm and zfs, the CNI plugins, nginx and trivy under a
fixed uid, redis 8. A base or tool bump that drops one still builds,
and only fails once the image runs in a cluster.

The kubevirt CSI node plugin and its sidecars run inside tenant VMs on
whatever vCPU they are given, so their filesystem tools, libc and Go
entrypoints must not require more than x86-64-v2. C objects declare
that level in a GNU property note and Go binaries in their GOAMD64
build setting; a file that records neither fails the check.

Each PR build job runs the checks against the images it pushed, found
by diffing the tree's image references before and after the build.
Fork PRs are skipped because their images are not in a registry yet,
and the unit lane runs no container. A change to kubevirt-csi-node
alone, where the node sidecar tags live, now runs the kubevirt CSI
build too, and the check fails when either sidecar is missing or the
reference file cannot be read.

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

## What this PR does

Fixes #3700.

Negative file assertions must not pass when the matcher fails or an
artifact is missing. Share `assert_file_lacks_pattern` through the
existing Bats helper, preserving all call sites while removing the 12
divergent copies. The shared implementation accepts absence only when
awk evaluates successfully and explicitly reports no match. It reports
read/evaluation failures regardless of their exit status and validates
the regex even when the artifact is empty.

Regression tests run the assertion under `bash -eu` and cover matching
and non-matching patterns, empty files, invalid regexes, missing paths,
directories, and unreadable files. The tests reproduce false positives
against the previous helper implementations, including a matcher that
prints a no-match result but exits with an error. The test suite
resolves its helper relative to its own directory and also runs outside
the repository root.

### Validation

- Bats 1.14.0: all 471 tests in the regression file and 12 affected
consumer suites pass, with no skips.
- All 462 tests in the 12 affected consumer suites pass under the dash
POSIX compatibility runner.
- All nine helper tests pass from both the repository root and `/tmp`;
independent verification also passes all nine with BusyBox awk v1.35.0.
The previous helper falsely accepts invalid patterns and unreadable
files with that implementation.
- `bash -n hack/test_helper.bash` and `git diff --check` pass.
- An earlier full Bats run executed all 2,491 tests: 2,426 passed and 65
failed. Of these, 56 require Docker and three require `envsubst`,
neither of which is installed in this environment. The remaining six
selector failures also reproduce on the unchanged baseline with the
older local yq; rerunning both selector suites with the CI-pinned,
checksum-verified yq v4.53.3 passes all 110 tests. The full-tree suite
has not been rerun for this corrective revision; its focused checks are
listed above.

### Screenshots

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

### Downstream repositories

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

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

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

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

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

### Release note

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

```release-note
fix(tests): fail negative file assertions on invalid patterns or unreadable artifacts and share the helper across Bats suites.
```


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

## Summary by CodeRabbit

* **Tests**
* Consolidated checks for verifying that files do not contain specified
patterns.
* Expanded coverage to verify behavior for matching and non-matching
patterns, invalid patterns, missing paths, directories, inaccessible
files, and pattern-checking errors.
* Checks now succeed only when the target is a regular file and pattern
evaluation completes successfully without finding a match.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-15 06:00:02 +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
Maxim Belyy 1597bb6098 fix(ci): keep the drift annotation true when bare refs took main's images
Assisted-by: LLM
Signed-off-by: Maxim Belyy <maximbel2003@gmail.com>
2026-11-14 20:02:29 +07:00
Maxim Belyy 2468b309ee fix(ci): count a failed bare-ref rewrite and word the drift log by result
A rewrite that cannot replace the file now counts as failed and leaves
no temporary file behind, instead of reporting lines as replaced. A
drifted file whose bare refs took main's images no longer logs that it
kept its committed ref.

Assisted-by: LLM
Signed-off-by: Maxim Belyy <maximbel2003@gmail.com>
2026-11-14 19:58:33 +07:00
Maxim Belyy 854a3f40e4 fix(ci): limit the drifted-file bare-ref overlay to first-party images
Main can bump a third-party image together with its config, so a PR
behind it must keep the committed pair rather than take main's image
alone. Only ghcr.io/cozystack/cozystack refs, matched against an
artifact line for the same first-party image, are replaced now.

State the trade-off for first-party refs that do exist, and name the
packages that took main's images in their own annotation.

Assisted-by: LLM
Signed-off-by: Maxim Belyy <maximbel2003@gmail.com>
2026-11-14 19:54:31 +07:00
Maxim Belyy fd15ad282e fix(ci): take the main ref for a bare image ref in a drifted file
A file whose configuration drifted from the cozystack-packages:main
artifact keeps its committed refs. For a digest-pinned ref that runs an
older image; for the bare <repo>:<tag> a new image is first committed
with, it names a tag that was never pushed, so the component cannot
pull. The merge commit CI tests is fixed when the run starts, so a PR
whose merge commit predates a config change to observability-proxy's
values.yaml installed observability-proxy:v0.0.0 and failed E2E.

In a drifted values file, a bare ref under an image key now takes the
artifact line with the same key, the same image name and a digest, when
exactly one exists. The rest of the file stays as the PR has it.

Assisted-by: LLM
Signed-off-by: Maxim Belyy <maximbel2003@gmail.com>
2026-11-14 19:51:20 +07:00
Ahmed Kamal 694943af7f chore(tests): merge main to refresh observability image baseline
Keep unbuilt package configuration aligned with current-main images so
the fork E2E overlay can replace the observability-proxy placeholder.

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Assisted-by: LLM
2026-11-14 03:43:56 +02: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
Aleksei Sviridkin 7e069356b9 Merge branch 'main' into feat/kubernetes-nodes-talos-sysctls
Generated files (types, README, schema, cozyrds) are regenerated from
the merged values.yaml.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-14 00:43:22 +03:00
Mattia Eleuteri 2568db67b1 Merge branch 'main' into fix/kubernetes-nodes-surge-before-drain
Assisted-by: LLM
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
2026-11-13 22:40:18 +01:00
myasnikovdaniil a427ceb582 ci: run only the backport-batch tests for a backport-batch change (#5287)
## What this PR does

Stacked on #5288, merge that one first.

PR touching only `cmd/backport-batch` was treated as code change, so it
rebuilt every image, installed platform in e2e sandbox and ran full
chainsaw suite plus whole unit lane. #5283 (one-line test fix) spent 3.5
hours in that e2e and hit job timeout. And backport-batch go tests were
running on every code PR, whatever it touched.

- plan job `code` output is now false when every changed path is under
`docs/`, `cmd/backport-batch/` or `cmd/api-gate/` (CI-only tools, no
image builds them). Builds, finalize and e2e are skipped and `E2E Tests`
posted green, same as for docs-only PRs. `e2e-fork.yaml` skips on same
prefixes, `hack/gate-concurrency-contract.bats` fails if two lists
diverge.
- `hack/build-matrix.sh` and `hack/select-e2e.sh` don't escalate to full
rebuild or full suite because of these two dirs, so mixed PR is scoped
by its other paths. Other `cmd/` dirs still escalate.
- `test-backport-batch` removed from `make unit-tests`. Checks job runs
it only when diff touches path from `cmd/backport-batch/test-inputs.txt`
(tool itself, in-repo packages it imports, docs pages its tests read,
`go.mod`, `go.sum`). `TestInputsListed` compares this list with `go list
-deps -test` and fails when import is missing there.
- new `docs` output keeps bats lane for docs changes and drops it for
tool-only ones.
- includes test fix from #5283 (pin run attempt in
`TestReportDedupAndTrust`), this PR replaces it.

### Screenshots

### 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
ci: changes only in docs/, cmd/backport-batch/ or cmd/api-gate/ don't build images and don't run e2e anymore, backport-batch tests run only when their inputs change.
```

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

## Summary by CodeRabbit

* **Bug Fixes**
* CI now skips builds, E2E tests, and full-pipeline checks for changes
limited to documentation and designated CI-only tools.
* Backport-batch tests run when relevant files change, without being
included in the general unit-test target.
* Changes to other command-line tools continue to trigger the
appropriate build and E2E checks.

* **Documentation**
* Clarified how documentation, dashboard, and backport-batch changes
affect test selection.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 23:40:56 +03:00
myasnikovdaniil aa36d3fad6 fix(kubernetes)!: remove the talos block and other leftovers of the worker pool split (#5191)
## What this PR does

Cleanup after the Kubernetes app was split into `Kubernetes` (control
plane and addons) and `KubernetesNodes` (one release per worker pool):
what the split left behind in values, docs, templates and tests.

### Kubernetes

The `Kubernetes` application has no `talos` field any more. Worker pools
are `KubernetesNodes` resources and take their Talos release, image,
installer and registry mirrors from their own `talos` and `osImage`, so
the cluster's copies did nothing. The last one, `talos.version`, fed a
duplicate of the Talos to Kubernetes support-matrix check. The pool
chart already runs that check against the Talos release each pool
actually boots, including one picked through an `osImage` override; the
cluster's copy compared the Kubernetes version against a release no node
runs. A stored spec that still carries `talos.*` keeps rendering,
because the values schema does not close the object and the API does not
validate `spec` against it, and a unit test pins that.

The pool's check now has render coverage. Its own suite pins the
pairings it must accept, and a bats test renders the refusals through
`talos.version`, `osImage.factory.version` and `osImage.builtin.version`
with schema validation skipped, since the schema offers no Kubernetes
version the matrix refuses.

I fixed the README and field descriptions that described behavior the
chart no longer has, or never had: a dedicated etcd cluster, a
`blockSize.matchVolume` setting that does not exist, a default `md0`
pool, the host default, the substrate mismatch behavior, and rollout
phase names. The README's Breaking Changes section becomes a pointer to
the per-release upgrade notes on cozystack.io. Unused helpers and stale
comments are removed; the chart renders the same bytes.

### KubernetesNodes

Five field descriptions and the `talos` block told users to keep them in
sync with parent fields that do not exist. NOTES warned about colliding
with a parent-managed `md0` pool, although the parent renders no pools
and `md0` is the normal name of a pool. The installer image was credited
to an upgrade Job that never runs one. The values descriptions, README
intro and NOTES now say what the chart renders today, including which
fields have no effect on `substrate: proxmox`: `storageClass`,
`diskSize`, `instanceType`, `talos.imageFactoryURL` (beyond its format
check) and `talos.imageFactoryCA`.

The render error for a pool whose MachineDeployment belongs to another
release told users to remove the pool from the parent's `nodeGroups`,
which cannot clear the conflict. It now names a remedy that works.
Split-era history is gone from Helm and test comments, along with two
`storageClass` fallbacks that can only return the value they fall back
from, a constant variable, and two `.helmignore` rules that match
nothing.

The tenant pod and service CIDRs are literals in both charts, and
nothing checked that they agree. A new bats test renders both charts and
fails when they differ.

No rendered manifest of the pool chart changes. I rendered it for the
snapshot values, GPU, kubelet-override, factory/CA, storageClass
variants and three Proxmox variants on main and on every commit, and the
output is byte-identical. The snapshot and TalosConfigTemplate hash
tests pass unchanged, so no worker rolls. YAML comments inside the
hashed machine config and machine template are left as they are for that
reason.

### The rule

`docs/agents/overview.md` gains a rule so this does not come back with
the next change: app READMEs and field descriptions describe current
behavior, a change users must act on goes to the website's upgrade page,
and a description does not ask the reader to keep it in sync with
another chart.

```release-note
[kubernetes] The Kubernetes application no longer has a `talos` field. Talos settings for workers, and the Talos to Kubernetes compatibility check, live on each KubernetesNodes pool. Existing clusters that still store `talos` values keep working; the values are ignored. KubernetesNodes field descriptions, README and install notes now describe the worker pool as it works today, including which fields have no effect on Proxmox pools.
```

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

## Summary by CodeRabbit

* **Configuration**
* Worker OS image, installer, and registry-mirror settings are
configured per worker pool; these settings are no longer available at
the cluster level.
* Kubernetes and Talos version compatibility is checked for each worker
pool. A worker Kubernetes version cannot be ahead of its parent cluster.
* Worker pools support KubeVirt and Proxmox, with pool-specific sizing
and disk settings.
* Rendering is refused when a pool uses a different substrate from its
cluster or conflicts with an existing worker pool owned by another
release.
  * The default cluster hostname now includes the `kubernetes-` prefix.
* Existing cluster configurations that still include Talos settings
receive a warning; those settings are no longer used.

* **Documentation**
* Updated guidance for cluster and worker-pool settings, storage,
upgrades, and version compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-14 00:34:44 +05:00
Aleksei Sviridkin 8d29097e34 Merge branch 'main' into ci/skip-tooling-paths
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 19:16:34 +03:00
Aleksei Sviridkin 29e8522f4b fix(cozystack-basics): refuse a direct delete of a tenant namespace (#5011)
## What this PR does

Fixes #5002. A DELETE of a tenant namespace is refused unless it comes
from the identities that remove it on the normal path, and the denial
says to delete the Tenant instead.

The new ValidatingAdmissionPolicy in cozystack-basics matches DELETE of
core namespaces, and its binding selects namespaces labelled
`tenant.cozystack.io/tenant-root`. The tenant chart puts that label on
every tenant namespace below tenant-root (`tenant.ancestorTenantLabels`,
and migration 49 backfilled older ones). tenant-root itself has no such
label and stays with `cozystack-no-delete-guardrail`. The `tenant-*`
probe namespaces of the e2e suites carry only
`namespace.cozystack.io/host` and are not selected either.

Two groups pass. `system:serviceaccounts:cozy-fluxcd`, because
helm-controller and its shards run as `flux` there, and a Tenant
uninstall is helm-controller deleting the namespace after the pre-delete
hook. `system:serviceaccounts:kube-system`, for the garbage collector
following the ownerReference of a child namespace once its parent is
gone. The namespace controller never sends a DELETE for a namespace, it
updates `finalize`, so it is not affected
(`pkg/controller/namespace/deletion` and
`pkg/registry/core/namespace/storage` at v1.33.12 and v1.34.1).
`system:masters` is not exempt, the same as with the no-delete
guardrail.

This is the denial kube-apiserver 1.35 returns.

```
namespaces "tenant-foo" is forbidden: ValidatingAdmissionPolicy 'cozystack-tenant-namespace-delete-policy' with binding 'cozystack-tenant-namespace-delete-policy' denied request: Namespace tenant-foo belongs to the Tenant foo in tenant-root. Delete the Tenant instead with kubectl delete tenants.apps.cozystack.io foo --namespace tenant-root. Deleting the namespace directly can remove the tenant etcd before the Kubernetes clusters that use it and leave the namespace stuck in Terminating. If the Tenant is already gone, remove the label first with kubectl label namespace tenant-foo tenant.cozystack.io/tenant-root-
```

There are a few limits.

- The bypass is removing the label, like with the guardrail. That also
takes the namespace out of the tenant-root egress policy and the
dashboard tree, which only matters for a namespace that is about to go.
- Migration 49 labelled every `tenant-*` namespace that existed when it
ran, so a non-tenant namespace with such a name is refused too and needs
the same label removal.
- Because the garbage collector is exempt, a parent namespace whose
label was removed and that is deleted with foreground propagation still
cascades into its children directly.
- A DELETE of a namespace that is already Terminating is answered before
admission, so the policy does not see it. It changes nothing either.
- A cluster that made helm-controller impersonate another account
(`--default-service-account`, or `spec.serviceAccountName` on Tenant
HelmReleases) would need that account allowed. Cozystack sets neither.
- It does not change how Kamaji cleans up once the order is broken,
which is the second idea in #5002.

The helper rename in `external_tls_policy_test.go` (`loadPolicy(t,
path)` and `compilePolicy`) is byte for byte the one in #2622, so the
two merge in either order.

Checked locally.

- `go test ./pkg/registry/apps/application/ -run
'TestTenantNamespaceDeletePolicy|TestDatabaseExternalTLSPolicy' -count=1
-v` passes 4 tests, the new `TestTenantNamespaceDeletePolicy_Decisions`
with 11 cases. `go test ./pkg/registry/... ./pkg/config/...
./pkg/cmd/server/...` passes in all 11 packages that have tests.
- `helm unittest` in `packages/system/cozystack-basics` with
helm-unittest 1.1.2 in docker passes 12 suites and 70 tests, against 11
and 66 on main. The new tests on main without the template fail, both Go
tests and 4 helm tests in 2 suites.
- 12 mutations of the template each fail a test. They exempt
`system:masters`, drop either exempt group, select on the no-delete
label, add UPDATE, always name tenant-root as the parent, drop the
capability gate, label tenant-root, switch to Warn, switch failurePolicy
to Ignore, drop the bypass from the message and drop the objectSelector.
- The rendered policy, the guardrail and namespaces rendered from the
tenant chart were applied to kube-apiserver v1.33.0, v1.35.0 and v1.36.2
from setup-envtest, 16 checks on each. Real and dry-run deletes by a
cluster admin, by an OIDC user bound to cluster-admin and by a
cozy-system and a tenant ServiceAccount are refused with 403. The flux
and garbage collector identities get their delete accepted. tenant-root
gets the guardrail's denial, and with the guardrail binding removed a
dry-run delete of it goes through, so this policy does not select it. A
`tenant-*` namespace without the label and a tenant namespace after its
label is removed are accepted for deletion. With this binding removed, a
dry-run delete by the cluster admin goes through. That harness is not
part of the PR.
- `hack/bats-no-negated-assert.bats`, `hack/bats-no-exit-trap.bats`,
`hack/bats-runner-coverage.bats`, `hack/helmrelease-readiness.bats` and
`hack/route-hostname-policy-version-coverage.bats` pass under
`hack/cozytest.sh`.

The new e2e case in `hack/e2e-install-cozystack.bats` creates an empty
Tenant, checks that a server dry-run delete of its namespace is refused
with the message, deletes the Tenant and waits for the namespace to go.
It was not run here, there is no Cozystack cluster at hand. Its kubectl
steps were run against the envtest apiserver 1.35, the selector and
field selector read, the refused dry-run with the exact strings it greps
for, and `kubectl wait --for=delete` on a namespace that is gone. The
Chainsaw suites that delete Tenants, the gateway inheritance ones among
them, go through the uninstall path as well.

The release-1.6 backport is #5012.

### Screenshots

Not a UI change.

### Downstream repositories

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

The trigger map was walked against the diff. It adds a policy and tests
to cozystack-basics and an e2e case, and no entry covers that. The
website docs do not tell users to delete a tenant namespace directly,
and terraform-provider-cozystack deletes Tenants through the apps API.

### Release note

```release-note
fix(cozystack-basics): refuse a direct DELETE of a tenant namespace unless it comes from helm-controller or the garbage collector, and point to deleting the Tenant instead, so a tenant namespace deleted by hand no longer gets stuck Terminating on Kamaji finalizers
```
2026-11-13 18:25:04 +03:00
Aleksei Sviridkin 51282a1243 fix(piraeus-operator): keep the LINSTOR error-report alerts quiet when the controller pod moves (#4963)
## What this PR does

`linstorSatelliteErrorRate` fires for every node that has any old
LINSTOR error report whenever the LINSTOR controller pod moves to
another node, and it keeps firing for 15 minutes.
`linstor_error_reports_count` is exported by the controller, so its
series carry the controller pod's `instance` and `controller_node`, and
a moved pod starts new series that hold the existing counts.
VictoriaMetrics'
[`increase()`](https://docs.victoriametrics.com/victoriametrics/metricsql/#increase)
starts from the last sample before the window, and when a series has
none,
[`rollupDelta`](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/v1.136.0/app/vmselect/promql/rollup.go#L1859-L1901)
counts it from zero whenever its first value is below ten times the next
change plus one. That is the case the docs describe as `increase`
ignoring "the first value in a series if it is too big" under
[`increase_pure`](https://docs.victoriametrics.com/victoriametrics/metricsql/#increase_pure),
and report counts are never that big, so every new series counts all of
its reports as new. The `up` guard from #2265 matches `on(instance,
job)`, and the new controller is up, so it lets them through.

Seen on a v1.6.5 cluster with VictoriaMetrics v1.136.0. During the
upgrade the controller pod moved to another node, and the alert fired
for all three nodes with values 1, 1 and 2 for 15 minutes, while
`linstor error-reports list --since 1h` was empty and the four reports
that exist were weeks old. The day before, it fired the same way for
about 15 minutes when only the `cluster` external label of vmagent
changed.

A satellite coming back to the metric does the same. In LINSTOR v1.33.3
the controller asks every satellite for its reports on each scrape and
leaves out any satellite that is not connected
([`prepareErrRequestApi`](https://github.com/LINBIT/linstor-server/blob/v1.33.3/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlErrorListApiCallHandler.java#L240-L259)),
so after a node reboot or any other disconnect longer than five minutes
the satellite's old count is counted again.

Both rules now take the count per `hostname`, hold the last value for an
hour with `last_over_time`, and run `increase()` over that as a
one-minute
[subquery](https://docs.victoriametrics.com/victoriametrics/metricsql/#subqueries),
whose inner points VictoriaMetrics aligns to that step. Keyed on
`hostname`, a moved controller or a changed label continues the same
series, and the hold bridges a disconnect or a slow controller start of
up to an hour. The `up` guard matches `on()`, since the aggregated
result has no `instance` any more. A new report still fires with the
same value and stays for 15 minutes, at most a minute later than before
because of the one-minute step. The alerts now carry `hostname` and
`severity`, and no longer the controller's `instance`, `job` and
`controller_node`, the `module`, or the external labels of the scrape.

`linstorControllerErrorRate` gets the same form. Its `hostname` is the
controller pod name and the piraeus controller keeps its reports in an
[`emptyDir`](https://github.com/piraeusdatastore/piraeus-operator/blob/v2.10.2/pkg/resources/cluster/controller/controller-deployment.yaml#L111-L112),
so a new pod starts with no reports and a move alone does not trip it,
but a label change does whenever the controller has reports.

A gap longer than the hour is not covered. After it the series starts
over, and as before the `up` guard holds the alert back only if the
controller target recorded failed scrapes during the gap.

I checked it against the stored metrics of the cluster above with
read-only queries to vmselect. Over the upgrade the current expression
returns the three nodes from 15:45:30 to 16:00:00 UTC at a 30-second
step, the same interval as vmalert's `ALERTS` series, and over the label
change from 20:27:30 to 20:42:00. The new expression returns nothing
over both windows, and without `> 0` it returns each of the three nodes
with 0 at every step, 88 and 121 points. The same storage has six gaps
of 8 to 113 minutes over one night with no failed scrape recorded in
them. Replaying vmalert's instant query of the `increase()` part every
30 seconds in the 154 evaluations after those gaps, the current
expression returns at least one node in 99, the `hostname` key without
the hold in 84, and the new expression in 30, all of them after the
113-minute gap. Retention there does not reach back to a real new
report, so the firing side is covered by the tests.

`hack/linstor-error-report-alerts.bats` replays both rules through
`vmalert-tool` v1.136.0, pinned by digest, which is the VictoriaMetrics
release victoria-metrics-operator v0.68.4 [deploys by
default](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L38),
with 30-second samples and 15-second evaluations like the platform's
vmagent and vmalert. The suite needs docker, like the migration suites,
and only the image pull touches the network.
`hack/testdata/linstor-error-report-alerts/unittest.yaml` has 20 cases
in five groups, which cover a controller move followed by a new report,
a changed external label for both rules, one satellite away for 40
minutes and one that comes back with a new report, a new report and a
first report on a node for both rules, and a controller that cannot be
scraped for 70 minutes. Against the rule on main 13 cases fail, 9 of
them because old reports fire again after the move, the label change or
the disconnect, and the other 4 on the label set alone, since the
current alerts carry the controller's labels. Each of seven mutations of
the new expressions turns at least one case red, namely no hold, a
15-minute hold, the guard on `instance`, no guard, the key on `hostname`
and `instance`, the key on `hostname` and `cluster`, and the controller
rule as on main. With Bats 1.14.0 at the commit CI pins, the new suite
with `alert-severity-contract`, `bats-strict-setup`,
`bats-no-negated-assert`, `bats-no-exit-trap`, `bats-runner-coverage`
and `image-pin-consistency` passes 74 of 74, and `helm template` renders
the same 15 rules as main. I have not run the new rules in vmalert on a
live cluster.

The commit cherry-picks onto release-1.7 as is, and the suite passes
there. On release-1.6 it applies without conflicts, but that branch runs
`hack/*.bats` through `hack/cozytest.sh` and has no
`hack/test_helper.bash`, so the suite there has to drop its `load
test_helper` line.

### Screenshots

Not a UI change.

### Downstream repositories

A rule file under `packages/system/piraeus-operator/alerts/`, a new Bats
suite under `hack/` and its test data. No values, schema, README, image,
make target or `ApplicationDefinition` change, and the website does not
mention these rules or the metric, so no trigger map entry applies.

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

### Release note

```release-note
fix(piraeus-operator): the LINSTOR error-report alerts no longer fire on old reports when the LINSTOR controller pod moves to another node, when an external label of the scrape changes, or when a satellite reconnects within an hour. They now count reports per node, and their alerts carry the node's hostname instead of the controller pod's instance, job and controller_node labels.
```


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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved LINSTOR controller and satellite error alerts to account for
recent error reports over a 15-minute window, even when metrics are
intermittent or scrape labels change.
* Updated alert matching to better handle controller moves between nodes
and satellites that disappear from metrics while disconnected.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 18:18:47 +03:00
Aleksei Sviridkin 4fa6bfe30b feat(monitoring): alert when pods of one workload share a node (#4993)
## What this PR does

On three 3-node clusters running v1.6.4 and v1.6.5 we found a tenant
etcd with two of its three members on one node, a tenant Redis with two
of its three Sentinels on the node that also ran the master, and several
VictoriaMetrics and VictoriaLogs pairs (vmstorage, vmselect,
vmalertmanager, vlstorage) sharing a node. Nothing alerted. Losing one
of those nodes would have cost the etcd or Sentinel quorum, or both
copies of a storage tier. Spread constraints keep new pods apart once
they are in place (#4986 for etcd, #4989 for monitoring, #4990 for
Redis), but a placement that already exists, or that comes from a soft
rule or a drain, stays as it is, because the scheduler does not move
running pods.

This adds `PodReplicasColocated`, a warning in a new
`workload-placement` group under
`packages/system/monitoring-agents/alerts/`. It fires when two or more
running pods of one StatefulSet, ReplicaSet, CNPG `Cluster` or
`StrimziPodSet` have been on one node for an hour while the cluster has
at least as many schedulable nodes as the workload has running pods, so
five replicas on three nodes stay quiet. The alert carries `cluster`,
`namespace`, `owner_kind`, `owner_name` and `node`, plus the `severity`,
`exported_instance` and `service` labels the other platform alerts set,
and its value is the number of pods on that node. DaemonSets, Jobs and
every other owner kind are not in the list, so a DaemonSet surge pod
next to its predecessor does not count.

etcd-operator gives every member pod its own `EtcdMember` as controller
owner
([etcdmember_controller.go#L546](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L546)),
so grouping by owner would see one pod per group. Members get their
names from `GenerateName: <cluster>-`
([etcdcluster_controller.go#L434](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L434),
[#L839](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L839)),
and members adopted from the old StatefulSet keep names like `etcd-0`
([adopt.go#L103](https://github.com/cozystack/etcd-operator/blob/v0.5.6/internal/migrate/adopt.go#L103)).
The rule drops the last dash-separated part of the member name and
reports the group as `EtcdCluster <name>`. With the etcd package that is
one group per tenant namespace, and two etcd clusters in one namespace
would still be told apart. CNPG instance pods carry a controller
reference to their `Cluster`
([cluster_create.go#L1580](https://github.com/cloudnative-pg/cloudnative-pg/blob/v1.30.0/internal/controller/cluster_create.go#L1580)),
and Strimzi pods one to their `StrimziPodSet`
([StrimziPodSetController.java#L369](https://github.com/strimzi/strimzi-kafka-operator/blob/0.45.1-rc1/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/StrimziPodSetController.java#L369)).

Owner and node both come from `kube_pod_info`. kube-state-metrics fills
`created_by_kind` and `created_by_name` from the controller owner
reference and `node` from `spec.nodeName`
([pod.go#L638-L653](https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/internal/store/pod.go#L638-L653)).
`kube_pod_owner` and `kube_pod_status_phase` have no node label of their
own, and the kube-state-metrics scrape adds `node` from
`__meta_kubernetes_pod_node_name` with `honorLabels: true`
(`templates/kube-state-metrics-scrape.yaml`), so on those series `node`
is the node of the kube-state-metrics pod. The test data keeps that
label on the phase series. A pod counts while
`kube_pod_status_phase{phase="Running"}` is 1, so a Failed or Pending
pod on the same node does not. `kube_pod_labels` does carry every pod
label here (`--metric-labels-allowlist=pods=[*]`), but the rule does not
depend on it.

A node counts as schedulable unless it has a `NoSchedule` or `NoExecute`
taint. A cordon shows up as the
`node.kubernetes.io/unschedulable:NoSchedule` taint
([node_lifecycle_controller.go#L549-L555](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/nodelifecycle/node_lifecycle_controller.go#L549-L555)),
and not ready and unreachable nodes get theirs from their conditions
([#L87-L99](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/nodelifecycle/node_lifecycle_controller.go#L87-L99)),
so one clause covers all three, and a tainted control plane does not
count either. Pods that a drain had to put together on the remaining
nodes therefore stay quiet while the node is out, and the hour starts
once it is back.

The alert waits an hour. A replacement pod runs next to its terminating
predecessor only for the predecessor's grace period, and node
maintenance takes the drained node out of the count, while a placement
that has held for an hour does not fix itself. The alert is about a risk
rather than an outage, so the wait costs nothing. The VMAlert sets both
`remoteWrite` and `remoteRead`, so the pending state survives a vmalert
restart ([vmalert
docs](https://docs.victoriametrics.com/victoriametrics/vmalert/#alerts-state-on-restarts)).

Not covered are workloads that run one pod per owner, such as ClickHouse
with one StatefulSet per replica
([patterns.go#L45-L53](https://github.com/Altinity/clickhouse-operator/blob/release-0.25.2/pkg/model/chi/namer/patterns.go#L45-L53))
and the KubeVirt VMs behind a tenant Kubernetes node group. They would
need grouping by pod labels, which this rule avoids. The node count is
cluster-wide, so a workload that a node selector or affinity restricts
to fewer nodes than it has pods fires too.

`hack/workload-placement-alerts.bats` takes `.spec` of the VMRule and
replays it through `vmalert-tool` v1.136.0 pinned by digest, the release
vm-operator v0.68.4 deploys by default
([config.go#L38](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L38))
and the same image #4963 and #4985 use.
`hack/testdata/workload-placement-alerts/unittest.yaml` has 13 cases
with 24 checks. Two of three StatefulSet pods on one node fire at 61
minutes and not at 59, with labels and annotations pinned. Spread pods,
five ReplicaSet pods on three nodes, a DaemonSet surge pod, two pods of
one Job, a Failed pod next to a running one, and one pod each in two
clusters that share workload and node names stay quiet. etcd members
fire as one `EtcdCluster` per namespace, for generated and adopted
member names. A replacement pod next to its terminating predecessor for
twenty minutes stays quiet, and the same overlap held past the hour
fires and resolves when it ends. A cordoned node keeps the alert quiet
until it is uncordoned, and a node with unreachable taints keeps it
quiet throughout. ReplicaSet, CNPG `Cluster` and `StrimziPodSet` pods
fire with their owner kind.

```console
$ bats hack/workload-placement-alerts.bats
1..1
ok 1 workload placement alerts pass their vmalert-tool cases
```

With the expression replaced by one that never fires, the suite prints
`not ok 1` and vmalert-tool reports 5 of the 24 checks, which are all
the checks that expect an alert. On main, where the rule file does not
exist, the suite fails as well. Each of these changes to the rule fails
at least one check, with the number of failing checks in brackets. `for:
15m` (5), no phase filter (1), no node count (6), no `cluster` label
(6), DaemonSet and Job in the kind list (3), no taint clause (4), `<`
instead of `<=` (5), etcd members grouped per member (1).

With Bats 1.14.0 at the commit CI pins, the suite passes together with
`alert-severity-contract`, `bats-strict-setup`,
`bats-no-negated-assert`, `bats-no-exit-trap`, `bats-runner-coverage`,
`bats-runner-contract`, `image-pin-consistency` and
`check-commit-trailers`, 109 of 109, and the severity contract lists the
new alert as `warning`. helm-unittest 1.1.2, the version CI pins, passes
the monitoring-agents chart with 19 of 19 tests in 6 suites, and `helm
template` with Helm 3.17.3 renders the VMRule the same as the file. Like
the migration suites the new suite needs docker, and only the image pull
touches the network. I have not run the rule in vmalert on a live
cluster.

On release-1.6 kube-state-metrics 2.15.0, its scrape config, the alerts
template, the VMAlert and vm-operator v0.68.4 are the same, and
etcd-operator v0.5.5 and CNPG 1.28.2 set the same owners and member
names. The new files apply there without changes. That backport is a
separate PR with one more commit that drops the `load test_helper` line,
because release-1.6 runs `hack/*.bats` through `hack/cozytest.sh`.

### Screenshots

Not a UI change.

### Downstream repositories

A new alert file under `packages/system/monitoring-agents/alerts/`, a
Bats suite under `hack/` and its test data. No values, schema, README,
image or `ApplicationDefinition` change, and the website does not list
platform alerts by name, so no trigger map entry applies.

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

### Release note

```release-note
feat(monitoring): new warning alert PodReplicasColocated fires when two or more running pods of one StatefulSet, ReplicaSet, CNPG Cluster, StrimziPodSet or etcd cluster have shared a node for an hour while the cluster has a schedulable node for each of them.
```


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

## Summary by CodeRabbit

* **New Features**
* Added monitoring for workloads whose running pod replicas are
colocated on the same node.
* Alerts include workload, node, cluster, and severity details, along
with quorum-loss guidance.
* Coverage includes StatefulSets, ReplicaSets, Clusters, StrimziPodSets,
and EtcdMembers.

* **Tests**
* Added validation for workload-placement alerts across scheduling,
availability, cluster-isolation, and pod-replacement scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 17:38:58 +03:00
Ahmed Kamal 36082b280f chore(tests): merge upstream main with LINSTOR bootstrap fix
Keep the fork test environment aligned with the platform images so
LINSTOR database migration and controller versions agree during setup.

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Assisted-by: LLM
2026-11-13 16:08:20 +02:00
Ahmed Kamal 865874e99b chore(tests): merge upstream main into assertion helper branch
Refresh the base so fork CI builds and applies artifacts against the
current upstream code.

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Assisted-by: LLM
2026-11-13 13:42:51 +02:00
Ahmed Kamal 2df5727997 chore(tests): merge upstream main into resource selector branch
Refresh the base so fork CI builds and applies artifacts against the
current upstream code.

Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com>
Assisted-by: LLM
2026-11-13 13:42:43 +02:00
Aleksei Sviridkin d089decab9 Merge branch 'main' into fix/tenant-namespace-direct-delete-guard
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 14:20:44 +03:00
Aleksei Sviridkin 054852cfce Merge branch 'main' into feat/pod-replicas-colocated-alert
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 14:20:35 +03:00
Aleksei Sviridkin f1067fdd64 Merge branch 'main' into fix/linstor-error-report-alerts-controller-move
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 14:20:23 +03:00
Aleksei Sviridkin e8475963ee Merge branch 'main' into fix/monitoring-infoinhibitor
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-11-13 14:07:04 +03:00
Myasnikov Daniil 48eae9ad36 ci: run only the backport-batch tests for a backport-batch change
A pull request that changed only cmd/backport-batch built every image,
installed the platform for e2e and ran the whole unit lane, so a
one-line test fix waited hours on suites that cannot exercise it. The
backport-batch tests themselves ran on every code pull request,
although only a change to the tool, to what it imports or to the pages
its tests read can break them.

Their inputs are listed beside the tool and checked against its import
graph, because a hand-kept list that fell behind would switch the
tests off without anyone noticing.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-13 13:11:46 +05:00
Myasnikov Daniil 1619cb4eb9 ci: keep the CI-only Go tools from escalating builds and e2e
cmd/backport-batch and cmd/api-gate are built into no image and run
nowhere in the e2e sandbox, yet a change to either rebuilt every image
and ran the full Chainsaw suite, and widened a package change made in
the same pull request to everything. Every other directory under cmd/
is a shipped binary and keeps escalating.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-11-13 13:11:46 +05:00
myasnikovdaniil f061739ce2 ci(e2e): raise the E2E job limit from 215 to 265 minutes (#5288)
## What this PR does

Full chainsaw run doesn't fit in 215 minutes anymore. Last four nightly
runs were cancelled at the limit, and PRs that select full suite end
same way while every suite that got to run passed (#5283 for example).

This raises limit for all four jobs that run the suite (pull-requests,
e2e-fork, e2e-tag, nightly) from 215 to 265, so they stay on one figure.
Comments that state the cap follow it. Making e2e itself shorter is
separate work.

Part of #5261, `Collect report` ceiling in fork workflow from there is
not covered here.

### Screenshots

### 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
ci(e2e): E2E job limit raised from 215 to 265 minutes.
```

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

## Summary by CodeRabbit

* **Chores**
* Increased the time limit for end-to-end test runs from 215 to 265
minutes across applicable workflows. This allows longer test runs to
complete before the overall job is stopped.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 09:16:13 +03:00
Aleksei Sviridkin 2cf80c02a4 fix(clickhouse): keep failed backup attempts out of the bucket (#5229)
<!-- 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

A ClickHouse BackupJob attempt that fails during upload leaves its local
backup on the data volume, and with the upstream defaults the
clickhouse-backup sidecar never prunes local backups and resumes every
unfinished upload when it starts. On the next sidecar restart the failed
attempt is uploaded to the bucket as an archive no Backup refers to, and
while that resumed upload runs the sidecar answers new operations with
423, which burns the strategy Job's retries in seconds. The strategy
itself only waited for the sidecar API to respond and then started its
operation regardless.

The sidecar now runs with `API_COMPLETE_RESUMABLE_AFTER_RESTART=false`,
so a failed attempt is never published, and `BACKUPS_TO_KEEP_LOCAL=-1`,
so at most the newest local backup is kept and it is removed once its
upload succeeds. Backups already left on existing volumes are cleaned up
by the first backup after the upgrade. The Altinity strategy now waits
until the sidecar has no operation in progress before it starts a backup
or a restore, and fails the attempt with a clear message instead of
proceeding when the sidecar stays busy or unreachable.

Waiting for an idle sidecar changes what a retried strategy Pod does.
The Job retries a failed Pod up to twice, and a Pod can die after its
operation was accepted (a dropped poll under errexit, an eviction, a
node drain) while the sidecar keeps running it. Before, the retry hit
423 and failed; with the idle gate it would wait for the running
operation to finish and start it again. For a restore that is
destructive, because `restore_remote` drops every table it restores
before recreating it, so the second run discards whatever was written
after the first one finished. A retried restore therefore takes over a
`restore_remote` of the same archive that is still running and waits for
its result instead of starting another. Once an operation is accepted,
polls tolerate up to six failures in a row before the attempt fails, and
the sidecar losing the operation from its in-memory action log, or
ending it cancelled, fails the Pod instead of leaving it polling.

A retried backup works from the archive name the controller records for
its BackupJob. That name is now `<application>-<YYYYMMDDHHMMSS>-<first
12 hex digits of the BackupJob UID>`, so two runs of one application
started in the same second, as two Plans on one schedule are, never
share an archive. It is exactly as long as the previous
`clickhouse-<application>-<YYYYMMDDTHHMMSSZ>`, so an `s3PathOverride`
prefix that fit before still keeps every object key within the 1024-byte
limit. A retry takes over a `create_remote --resume` of its archive that
is still running, counts an upload of its archive whose latest run ended
in `success` as its own result instead of uploading the archive again,
and otherwise resumes the upload. Restoring a Backup that records no
archive still picks an archive by timestamp, and that path accepts only
`clickhouse-<application>-<timestamp>` names, so it never picks a
per-run archive.

One limit remains. A finished `restore_remote` row is not taken over:
the sidecar never trims its action log, so a `success` row of the same
archive may be left by an earlier RestoreJob, and counting it as this
one would report a restore that never ran. A retry that arrives after
the restore it replaces had already finished, but before that Pod saw
the result, therefore still runs the restore a second time.

Upgrading changes the ClickHouseInstallation pod template, so ClickHouse
pods with `backup.enabled` are rolled once. A backup Job started before
the upgrade by a controller that named archives the previous way is not
re-rendered and keeps writing that name, so the controller records the
previous name when the new one is not on the Job. The local copy of the
latest failed attempt stays on the volume until the next backup. Objects
partially written to the bucket by an upload that fails midway are not
removed by clickhouse-backup and are left for a follow-up.


### Screenshots

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

### Downstream repositories

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

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

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

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

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

### Release note

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

```release-note
fix(clickhouse): failed ClickHouse backup attempts are no longer uploaded to the bucket when the backup sidecar restarts, local backups no longer accumulate on the data volume, the backup strategy waits for the sidecar to be idle instead of failing with HTTP 423, a retried ClickHouse restore takes over the restore that is still running instead of starting it a second time, and a retried ClickHouse backup takes over or reuses its own upload instead of starting a new one. Every ClickHouse backup run now writes an archive of its own, even when two runs start in the same second, under a name no longer than before. ClickHouse pods with backups enabled are restarted once on upgrade.
```


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

## Summary by CodeRabbit

* **New Features**
* Backup and restore operations wait for the backup service to become
idle and join a matching operation already in progress rather than
starting a duplicate.
* Restore operations use the archive the Backup records and fail when it
is not in remote storage; only a Backup that records no archive falls
back to the newest eligible archive by timestamp.
* New backups use distinct archive names, including for runs started in
the same second.
* Local backup copies are discarded after upload, and completed uploads
are not resumed after a service restart.
* **Bug Fixes**
* Operations now fail when the service cannot be queried, an operation
disappears from its activity log, or it ends with an error or
cancellation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 08:58:33 +03:00
Aleksei Sviridkin bc268ce759 fix(monitoring-agents): let the release uninstall when the VictoriaMetrics operator is gone first (#5152)
<!-- Thank you for making a contribution! Here are some tips for you:
- Use Conventional Commits for the PR title: `type(scope): description`
- Add the label `kind/backport` if it's a bugfix that needs to be
backported to a previous version.
-->

## What this PR does

Disabling the Monitoring Agents addon of a tenant Kubernetes cluster
leaves `<cluster>-monitoring-agents` (release `cozy-monitoring-agents`,
installed into the tenant cluster) in `UninstallFailed` for good. Seen
in production on 1.6.5 and still reproducible from `main`.

`monitoring-agents`, `victoria-metrics-operator` and
`vertical-pod-autoscaler-crds` in
`packages/apps/kubernetes/templates/helmreleases/` are all gated on
`addons.monitoringAgents.enabled`, so they disappear together and Flux
uninstalls them in parallel: `dependsOn` is not honoured on deletion.
Two things then break the uninstall of `monitoring-agents`:

1. The VictoriaMetrics operator is often gone first. The operator's
`apps.victoriametrics.com/finalizer` stays on the `VMAgent`, nobody
removes it, and the deletion hangs. The manual workaround was to strip
the finalizer, after which GC removes the VMAgent's Deployment, Service,
Secrets and ServiceAccount through their owner references.
2. The VPA CRD was deleted with its own release while the stored
manifest still contains `VerticalPodAutoscaler vpa-vmagent`, so Helm
cannot build the manifest to uninstall. That root cause is fixed by
#3586 (`helm.sh/resource-policy: keep` on the tenant addon CRDs), which
this PR does not redo.

This PR:

- adds a `pre-delete` hook (`templates/vm-cleanup-hook.yaml`) that
deletes every VictoriaMetrics object the release owns, waits up to 60s
for a live operator to finalize them properly, and clears their
finalizers by hand when it has not. Objects are selected through Helm's
`meta.helm.sh/release-name` / `release-namespace` annotations rather
than by name, so the 34 `VMRule`s rendered from `alerts/` and the
`VMServiceScrape` in `cozy-victoria-metrics-operator` are covered along
with the VMAgent. The kinds handled are every VictoriaMetrics kind the
chart renders: `VMAgent`, `VMRule`, `VMServiceScrape`, `VMPodScrape`,
`VMNodeScrape`. Operator v0.68.4 only finalizes the VMAgent; the other
kinds are covered in case another operator version finalizes them, and
for them the patch is a no-op. A kind whose CRD is already gone is
skipped, and the script always exits 0, since a failing pre-delete hook
would itself block the uninstall. The Job is bounded by
`activeDeadlineSeconds: 180` and `backoffLimit: 0`; its kubectl calls
carry no `--request-timeout`, which would make kubectl skip the
in-cluster credentials (`hack/check-hook-request-timeout.bats`) and
reuses the digest-pinned `docker.io/clastix/kubectl:v1.32` image the
etcd-operator hook uses, via a new `kubectlImage` value. The shape
follows
`packages/system/forklift/templates/forklift-cr-cleanup-hook.yaml`.
- guards `templates/vpa.yaml` on `.Capabilities.APIVersions.Has
"autoscaling.k8s.io/v1/VerticalPodAutoscaler"`, so a cluster that does
not serve the CRD never records a VPA in the release manifest. Cheap
defence in depth next to #3586.

Points for review:

- The hook's RBAC is a ClusterRole/ClusterRoleBinding, limited to `get,
list, delete, patch` on the five `operator.victoriametrics.com`
resources, rather than Roles. The objects span two namespaces, and a
Role in `cozy-victoria-metrics-operator` could not be created if that
namespace were already gone or terminating, which would fail the hook
and the uninstall with it. All hook objects carry
`hook-succeeded,hook-failed,before-hook-creation` except the Job, which
keeps a failed pod for its logs (`ttlSecondsAfterFinished: 600`), as in
the forklift hook.
- When the operator is already gone, clearing the finalizer skips
whatever the operator does on finalize, notably the cluster-scoped RBAC
it creates for the VMAgent, which has no owner reference. That residue
is the same the manual workaround left, and it is no worse than today's
stuck release; removing it would mean hard-coding the operator's naming
scheme for those objects, which I preferred not to do.
- When the operator is alive, the hook only brings forward deletions
Helm was about to make, so the operator's normal finalization still
runs.

Tests: `tests/uninstall_test.yaml` asserts that the hook is a
`pre-delete` Job in the release namespace with a bounded runtime, that
its RBAC is hook-scoped and grants exactly the verbs needed on every
VictoriaMetrics kind the chart renders, that the binding targets the
hook's ServiceAccount, that the script selects by release ownership,
deletes, clears finalizers and exits 0, and that the VPA renders only
when the capability is present (using `capabilities.apiVersions`). With
the hook removed and `vpa.yaml` reverted, 6 of the 7 tests fail; with
the fix, `helm unittest packages/system/monitoring-agents` passes 26/26.

`hack/monitoring-agents-vm-cleanup-hook.bats` runs the rendered script
against a fake `kubectl` that keeps the objects in a state file, with
fake `date` and `sleep`. It checks that only objects annotated for this
release are deleted and patched, that with the operator gone the hook
polls through the grace period and then clears the finalizers, that a
live operator's objects are never patched, that a missing CRD still
exits 0 and cleans the other kinds, and that a release with nothing left
exits 0 without deleting anything. Removing the ownership condition,
making the patch a no-op, or inverting the polling condition each turns
this file red. The hook has not yet been run on a live tenant cluster.

Backport: labelled `kind/backport` (release-1.7). The release-1.6
backport is done by hand in #5158. The commit cherry-picks onto
`release-1.6` with a single trivial conflict in `values.yaml` (context
only: 1.6 lacks the `prometheus-node-exporter` resources block the new
`kubectlImage` block sits after on `main`). Resolved locally, the
chart's tests pass on 1.6 (9/9); 1.6's chart renders the same
VictoriaMetrics kinds. Note that `release-1.6`'s monitoring-agents
`Makefile` has no `test:` target, so CI does not run this chart's unit
tests on that branch.

### Screenshots

Not a UI change.

### Downstream repositories

I walked the trigger map against the diff (a system chart's templates,
`values.yaml` and tests): no package added or renamed, no platform
values, no app schema, no CRD, no tooling or convention change. I also
searched cozystack/website for a documented VMAgent finalizer workaround
that this would make obsolete and found none.

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

### Release note

```release-note
fix(monitoring-agents): disabling the Monitoring Agents addon of a tenant Kubernetes cluster no longer leaves the monitoring-agents release stuck in UninstallFailed when the VictoriaMetrics operator is removed first; a pre-delete hook now releases the VictoriaMetrics objects' finalizers, and the VPA is only rendered when its CRD is served.
```



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

## Summary by CodeRabbit

* **Bug Fixes**
* VictoriaMetrics resources belonging to a release are cleaned up during
uninstall, including resources that remain because of finalizers.
Cleanup is limited to resources owned by that release.
* Vertical Pod Autoscaler resources are rendered only when the cluster
supports the required API.
* **Configuration**
* Added an image setting for the uninstall cleanup job, including a
pinned image version and pull policy.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-11-13 08:58:10 +03:00
Andrey Kolkov cbdcd4a572 test(dashboard): run the gatekeeper login redirect against oauth2-proxy
The realm and Keycloak URL branches moved into the gatekeeper's alpha
configuration, and nothing checked them for a realm other than cozy or
for the OIDC discovery branch: the e2e runs the default realm with the
in-cluster Keycloak URL. A unit test renders the chart for another
realm, starts the auth-proxy image with the rendered args and config,
and checks the /oauth2/start redirect on both branches, the discovery
one against a local Keycloak stub. The image is read from the render,
so an oauth2-proxy bump re-checks the alpha configuration.

Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-13 11:21:42 +07:00
Michel Jansen 3265892826 test(kubernetes): group sysctl safety checks with heredoc tests
The heredoc suite owns escaped-input and render-time rejection coverage.
Keeping sysctl safety checks there leaves bootstrap-name agreement tests
focused on the shared content hash.

Assisted-by: LLM
Signed-off-by: Michel Jansen <mjansen@whero.xyz>
2026-11-12 21:35:53 +01:00
Michel Jansen 9b6128d3ca fix(kubernetes): reject invalid UTF-8 sysctl file values
Raw Helm file inputs can carry invalid UTF-8 that Go quoting turns into
different Unicode characters. Reject these bytes rather than silently
changing the requested worker configuration.

Assisted-by: LLM
Signed-off-by: Michel Jansen <mjansen@whero.xyz>
2026-11-12 21:35:53 +01:00