mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
00a540eb62b8a71ed3e98d9b3a734c8eaea31c40
339
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9baf43c632 |
test(kafka): check tenant-visible Strimzi Secrets in the e2e suite (#5424)
## What this PR does Moves the check of which Kafka Secrets a tenant can read from a unit test in the shared lineage webhook package into the kafka e2e suite. `internal/lineagecontrollerwebhook/kafka_rd_secrets_test.go` read the raw `kafka-rd` ApplicationDefinition and ran it against Strimzi labels typed by hand. The selectors are kafka's, and the labels are whatever the Strimzi User and Cluster Operators write at run time, so the test pinned one application's configuration against a guess of operator behaviour, from a package that should know neither. The generic part, how `matchLabels` and `resourceNames` select an object, is already covered by `matcher_test.go` in the same package. The kafka suite now creates one SCRAM user and checks the deployed Secrets. First, the user's password Secret and both CA certificate Secrets must carry `internal.cozystack.io/tenantresource=true`. Then no tenant-visible Secret of the cluster may hold a `*.key` entry, which is where Strimzi puts every private key. This check goes by content, so it covers the CA keys and the per-node key Secrets, whose names follow the node pools, and it does not break if a later Strimzi labels one more certificate Secret. A positive control fails the step if no Secret of the cluster holds a `*.key` entry at all, so the check cannot pass vacuously if Strimzi changes how it names keys. I also removed `hack/check-kafka-rd-secrets.bats`. It grepped the same YAML for the CA certificate names, so it passed on a name that only appeared in a comment or an exclude list. The e2e step now checks those names against the real Secrets. Nothing shipped changes: only tests are touched. The new e2e step has not run anywhere yet; it is exercised for the first time by CI on this PR. Locally I checked that the suite YAML parses, that the chart renders the `KafkaUser` from the fixture, and that the step's shell logic passes, fails on a leaked key and fails on the vacuous case when `kubectl` is stubbed. ### Screenshots No UI changes. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note test(kafka): check tenant-visible Strimzi Secrets in the kafka e2e suite instead of a lineage webhook unit test ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Expanded Kafka end-to-end checks to verify tenant-visible Secrets are labeled correctly and do not expose private keys. * Added an end-to-end Kafka user configuration for testing. * Removed earlier checks for Kafka certificate Secret naming and selector behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
30ce2a3cb1 |
fix(postgres): move tenant PostgreSQL to patched standard-trixie images (#5405)
## What this PR does Moves the tenant `postgres` application to PostgreSQL minors that fix CVE-2026-116331, and makes the upgrade repair the indexes that the move can break. ### Why the images change CVE-2026-116331 is a type confusion in the min/max aggregate optimisation: a role that can create objects runs code as the operating system user of the server. Tenants hold such roles, so this application is the exposed one. The fixed minors are 18.7, 17.12, 16.16, 15.20 and 14.25. The default flavor pins bare image tags (`postgresql:17.7`). A bare tag is the `system` variant on Debian bullseye, and upstream stopped building it: the fixed minors are published for bookworm and trixie only. This PR takes `standard-trixie`: the standard variant, because backups go through the barman-cloud plugin and need none of the barman binaries the `system` variant adds, and trixie, because the postgis flavor is on it already, so both image families share one Debian release. `hack/update-versions.sh` selects bare tags, so it would have settled on 17.11 and 18.6, which are still affected. This PR: - pins `<minor>-standard-trixie` for the default flavor and bumps every major to its fixed minor; - bumps the postgis flavor to the same minors (it was already on `standard-trixie`), which moves PostGIS from 3.6.1 to 3.7.0; - teaches `hack/update-versions.sh` to pick minors from `standard-trixie` tags. PostgreSQL 13 has no fixed release. It keeps the minor 13.22 and stays exposed to the CVE, and it moves to the trixie variant with every other major, so it takes the base image change and the index rebuild without getting the fix. 14.25 is the last release of the 14 line. ### Why the upgrade needs a repair step For a running default-flavor cluster the image moves from bullseye to trixie, so glibc goes from 2.31 to 2.41 and ICU's collator version from 153.14 to 153.128 under an existing data directory. An index ordered by a collation of either library is then ordered by rules the server no longer applies. PostgreSQL only logs a warning. Reproduced on a live cluster with 60 000 rows of mixed Unicode text: | Index collation | After the image change | |---|---| | `C` (what the chart creates by default) | intact | | libc `en_US.utf8` | intact on this data, version mismatch warning | | ICU `en-x-icu` | `amcheck`: item order invariant violated; 2 604 rows not found through the index | A database the chart created with its defaults uses `C` and is not affected. A tenant who declared `COLLATE` on a column, used an ICU collation, or created a database with a locale is. ### What the init Job does now The post-install/post-upgrade Job gets one more pass. It runs after the passes that manage roles and databases, so a rebuild that fails or runs out of time costs none of them. In every connectable database it: 1. finds the indexes that depend on a collation whose recorded library version differs from the one the server reports. PostgreSQL records a collation for an index only where it orders a key, so the collations of the columns an index reads in its expressions and its predicate count as well; 2. rebuilds them with `REINDEX INDEX CONCURRENTLY` (plain `REINDEX` for an exclusion constraint's index, which cannot be rebuilt concurrently, so its table is neither read nor written meanwhile); 3. refreshes the recorded versions with `ALTER COLLATION ... REFRESH VERSION` and `ALTER DATABASE ... REFRESH COLLATION VERSION`, once every rebuild in that database succeeded. **Timing.** Helm runs the hook as soon as the `Cluster` is patched, while CloudNativePG is still rolling the instances, so the primary can answer from the old image for minutes. The Job runs the new image, so it waits until the server reports the same PostgreSQL version and Debian release as its own `psql`. The rebuild counter of the package is left out, because a tag is rebuilt in place and the Job can pull a newer rebuild than the instances run. It waits only when an index depends on a versioned collation; a cluster with nothing to rebuild is not delayed. **Retries.** `REINDEX CONCURRENTLY` gives an index a new OID, so the highest OID seen when a repair begins separates the indexes still to rebuild from the ones already done. That mark is kept as a setting of the database (`cozystack.collation_repair`) with a fingerprint of the stale collations and the list of indexes rebuilt in place, and removed when the repair is complete. A retry therefore continues instead of starting over. **Failures.** A rebuild that fails does not stop the others. The pass reports the failures and exits non-zero at the end. A failed or interrupted `REINDEX CONCURRENTLY` leaves an invalid `_ccnew` index on the table; two of those mean two runs failed there, and the pass then leaves that table's stale indexes to an operator instead of scanning the table again on every retry. A rebuild that succeeds drops the leftovers; dropping them by hand lets the next run try again. An in-place rebuild leaves no such trace, so the setting records each attempt with the index's storage file: a changed file means the index was rebuilt, by a run or by hand, and two attempts on the same file leave it to an operator. A rebuild that waits for a lock behind an open transaction gives up when the Job runs out of time, and an in-place rebuild is cut off at the same point, so no backend is left waiting or holding the table after the Job is gone. A concurrent rebuild that is already running is not cut short. **Privileges.** The Job connects as the superuser, so every session of the pass sets `search_path` to `pg_catalog, pg_temp`. A function or operator that a tenant defined in `public` cannot be picked in place of a built-in. **Before PostgreSQL 15** the server records no version for a database's default collation. The version recorded for the libc collation of the same locale stands in for it; the two are matched as glibc matches them, so `en_US.UTF-8` finds `en_US.utf8`. A locale with no such collation cannot be checked, and a run that saw the image change says so in a warning that names the database. **Range partition keys.** Rebuilding an index does not move a row to the partition the new ordering assigns it. A collation that such a key depends on keeps its recorded version, so PostgreSQL keeps logging the mismatch, and the Job prints a warning that names the table on every run. Its indexes are still rebuilt, once. The pass is driven by the version mismatch, not by this particular image change, so it also applies to later glibc or ICU bumps. ### Verified `helm unittest` passes for the chart (236 tests). The e2e suite gains a step that creates a collation with a stale version, upgrades the release and checks that the index was rebuilt and the version refreshed. On a live cluster, applications were installed from the v1.7.0 chart and upgraded with this change applied on top of v1.7.0. Each had a client holding a connection, which is what makes the primary restart take minutes. | Case | Outcome | |---|---| | v17, two instances, default `C` collation only | Job finished in 15 s without waiting; data identical; `amcheck` clean | | v17, two instances, ICU, libc, expression, unique, exclusion and partition indexes | Job waited about 3.5 min for the primary, rebuilt seven indexes; `amcheck` clean; every row found through the ICU index again (run with the first revision of the pass) | | v17, two instances, backups to the system bucket | a backup taken before and one taken after the upgrade both succeed; WAL archiving continues with no failed segment, so the barman-cloud plugin covers the binaries the `standard` variant lacks | | v18, an application that had been running for months (18.1 to 18.7) | row counts identical; `amcheck` clean | | v14 (14.20 to 14.25) and v13 (13.22, base image only) with the same index set | Job waited, rebuilt six indexes; `amcheck` clean | The pass itself was also run against a live server for the cases an upgrade does not produce on demand: - a second run does nothing; - a failed rebuild leaves the other indexes rebuilt, and a later run rebuilds only the failed one; - after two failed runs the index is left alone until it is rebuilt by hand, and the pass then completes; - an exclusion constraint's index is rebuilt in place once, not again by a retry; when a writer blocks it twice it is left alone, and after a manual `REINDEX INDEX` the pass completes; - a collation under a range partition key stays stale and its indexes are not rebuilt twice; - a rebuild blocked by an open transaction fails on its lock wait and leaves no waiting backend; it succeeds once the transaction ends; - a tenant function named like a built-in is not called by the pass, while a session with the default `search_path` does call it; - on PostgreSQL 14 an index on the database default collation is rebuilt, also when the locale is spelled `en_US.UTF-8`, and a database with a locale that has no stand-in gets the warning only in a run that saw the image change; - an index whose expression or partial-index predicate reads a column of a stale collation is rebuilt, although PostgreSQL records no collation for it. ### Known limits - **A window of wrong results.** Between the primary restart and the end of the rebuild, queries through an affected index can miss rows and a unique index can accept a duplicate. The index cannot be built ahead of time, because it has to be built by the new library. A duplicate that slipped in makes that index's rebuild fail until the duplicate is removed. - **The hook budget.** The wait ends 120 seconds before the Job's deadline. A roll that takes longer fails the Job, and the next run finds the server ready. One index must be rebuilt within one run of the Job. A very large index on a non-`C` collation does not fit that: after two attempts the pass stops trying and asks for a manual `REINDEX`, and the release stays failed until then. - **Range partition keys** are reported, not repaired. - **Other dependents** of a collation, such as `CHECK` constraints and materialized views, are not examined. - **PostgreSQL 13 and 14, default collation.** A database whose locale has no libc collation in the catalog has no stand-in. Its default-collation indexes are not rebuilt; the Job warns about it and names `REINDEX DATABASE` as the remedy. - **Collations inside expressions.** An index is found through the collations that order its keys and through the columns its expressions and predicate read. A collation that an expression applies to a column of another collation, with `COLLATE` inside the expression, leaves no trace in the catalog and is missed. - **The wait is not in the e2e suite.** The e2e step does not swap the image, so it runs the rebuild but not the wait for the roll. That part is covered by the live runs above. - **PostGIS 3.6.1 to 3.7.0** on the postgis flavor is not exercised here. - **Upstream `REINDEX` advice for these minors** is not automated. The 17.12 [release notes](https://www.postgresql.org/docs/17/release-17-12.html) ask for a `REINDEX` of btree indexes on unconstrained `bpchar` columns and of `gist_trgm_ops` indexes, among others. The flavor guard is unchanged in behaviour; its comment and messages no longer claim that the two image families always differ in Debian release. ### Screenshots N/A — no UI changes. ### Downstream repositories Walked the trigger map against the diff: two version maps, the image template, the init script, a comment in `db.yaml`, the version update script and one unit test of `packages/apps/postgres`, plus one e2e suite. The `version` enum, `values.yaml`, `values.schema.json`, the README, the `ApplicationDefinition` and the release prefix are untouched. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(postgres): tenant PostgreSQL moves to the minors that fix CVE-2026-116331 (18.7, 17.12, 16.16, 15.20, 14.25) on the standard-trixie image variant. Upgrading rolls every Postgres instance. - PostgreSQL 13 has no fixed release: it keeps 13.22 and stays exposed to CVE-2026-116331, and it still takes the image move and the index rebuild described below. 14.25 is the last release of the 14 line. Plan a move to a newer major for clusters on 13 and 14. - For the default flavor the image moves from Debian bullseye to trixie, which changes glibc and ICU. The upgrade rebuilds the indexes that depend on a non-C collation. Until that rebuild finishes such an index can return incomplete results and a unique one can accept duplicates, so plan a maintenance window if you use ICU or locale-specific collations. Databases created with the chart defaults use the C collation and are not affected. - An exclusion constraint's index is rebuilt in place, and its table is neither read nor written meanwhile. - When a rebuild cannot finish inside the upgrade Job, the release stays failed and the Job is retried. After two failed attempts the Job stops rebuilding that index, names it in its log and keeps failing until an operator steps in. Expect this for a large index on a non-C collation: rebuild it by hand with `REINDEX INDEX CONCURRENTLY`, drop the invalid `_ccnew` indexes the failed attempts left on its table, and the next run completes. A unique index fails the same way while it holds duplicates, which have to be removed first. - Tables range-partitioned on a text key with a non-C collation need a manual check, after which the collation version is refreshed by hand. - On the postgis flavor PostGIS moves from 3.6.1 to 3.7.0, and the upgrade does not update the extension in existing databases: once the new image has rolled out to the primary, run `ALTER EXTENSION postgis UPDATE` in each database that uses it. ``` |
||
|
|
66c7ed42ed |
test(kafka): check tenant-visible Strimzi Secrets in the e2e suite
Which Secrets of a Kafka cluster a tenant can read depends on the labels the Strimzi operators write onto them at run time, matched against the kafka ApplicationDefinition's selectors. A unit test in the shared lineage webhook package read the kafka-rd YAML and fed it hand-typed Strimzi labels, so it pinned one application's selectors against a guess of what the operator writes, from a package that should know neither. The kafka suite now creates one SCRAM user and asserts on the deployed Secrets: the user's password Secret and both CA certificates carry tenantresource=true, and no tenant-visible Secret of the cluster holds a private key. The second check goes by content rather than by name, so it covers the CA keys and the per-node key Secrets, whose names follow the node pools, and does not break when Strimzi labels another certificate Secret. The generic selector matching stays covered by the webhook package's matcher tests. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
a10e449a56 |
fix(postgres): rebuild indexes whose collation changed version
An operand image built on another Debian release ships another glibc and ICU. An index ordered by a collation of either library is then ordered by rules the server no longer applies: lookups through it miss rows, and a unique index stops seeing duplicates. PostgreSQL only logs a warning. The init Job compares the library version each collation was created with against the one the server reports, rebuilds the indexes that depend on a collation whose version changed, and refreshes the recorded versions once every rebuild in the database succeeded. A database on the C or POSIX collation with no explicitly collated index, which is what the chart creates by default, has nothing to rebuild and is not delayed. The pass has to hold on a hook that starts while the instances are still rolling, runs as the superuser in databases tenants own, and is retried after a failure: - It runs after the passes that manage roles and databases, so that a rebuild that fails costs none of them, and it waits for the server to report the PostgreSQL version and Debian release of its own image when an index depends on a versioned collation. The rebuild counter of the package is left out of that comparison, because a tag is rebuilt in place. - Every session pins search_path to pg_catalog, so that a function or an operator a tenant defined in public cannot stand in for a built-in. - A retry continues where the last run stopped. REINDEX CONCURRENTLY gives an index a new OID, so the highest OID seen when a repair begins marks what is left; an index rebuilt in place keeps its OID and is told apart by its storage file. Both live in a setting of the database. - A rebuild that cannot finish is not started for ever: after two attempts the index is left to an operator, the pass says how to clear it, and the release stays failed until then. Lock waits and in-place rebuilds are bounded by what is left of the Job. - A collation that a range partition key depends on keeps its recorded version, because rebuilding an index moves no row between partitions. PostgreSQL records a collation for an index only where it orders a key, so the collations of the columns an index reads in its expressions and predicate count as well. Before PostgreSQL 15 the server records no version for a database's default collation, and the libc collation of the same locale stands in for it. The e2e suite creates a collation with a stale version and checks that an upgrade rebuilds a unique index and an exclusion constraint's index on it, refreshes the version and removes the repair setting. Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
470e4c55a7 |
fix(kubernetes): bump tenant worker Talos to v1.13.12 (CVE-2026-99999)
Tenant worker VMs default to Talos v1.13.6, whose kernel predates the
upstream fix for CVE-2026-99999 (PwnEscape), Linux commit 6785011f8b16
("ipv4: validate checksum_start before completing checksum"). The bug
lets a guest escape into its host, and a tenant worker is a host
whenever the tenant runs nested virtualization inside it. The fix was
backported in Linux 6.18.57, which Talos v1.13.12 ships.
The workers stay on the v1.13 line rather than following the host
nodes to v1.14: Talos v1.14 drops Kubernetes 1.31 and 1.32, which the
tenant chart still offers, so a v1.14 default would fail the
support-matrix guard and break the render of those clusters. The v1.13
matrix entry is unchanged.
The new release changes the worker machine config and the golden image
name, so the content-hashed TalosConfigTemplate names and the default
golden DataVolume name pinned in the chart tests move with it.
Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
Assisted-by: LLM
|
||
|
|
442768abb7 |
feat(kubernetes): give each tenant Kubernetes cluster its own etcd (#4817)
## What this PR does A tenant Kubernetes cluster could not start until an ancestor `Tenant` had `spec.etcd: true`. The chart read the datastore name from `_namespace.etcd` and, with none, rendered only a `<release>-awaiting-etcd` ConfigMap. Every cluster below that tenant then shared one etcd, one CA and one disk, separated by key prefix only. Whoever creates a cluster usually may not edit the `Tenant`, so anything ordering clusters on a tenant's behalf (the portal's controller, for one) had to flip `etcd: true` first. This PR makes the `Kubernetes` application carry its own etcd. It implements phases 1 and 2 of the per-cluster etcd design proposal, [cozystack/community#25](https://github.com/cozystack/community/pull/25), as three commits that can be split later: 1. `refactor(etcd)`: the etcd chart's `EtcdCluster`, cert-manager PKI, `DataStore`, `WorkloadMonitor`, defrag `CronJob`, VPA and `VMPodScrape` move into named templates in `cozy-lib` (`packages/library/cozy-lib/templates/_etcd.tpl`), parameterised by the cluster name. `packages/extra/etcd` calls them with `"etcd"`, and its rendered output is byte-identical before and after (see Verification). 2. `feat(kubernetes)`: a new cluster renders its own `EtcdCluster` and `DataStore` from those templates, and a cluster that already runs on a shared tenant etcd keeps it. 3. `feat(platform)`: migration 63 → 64 reports which clusters stay on a shared etcd and changes nothing. Phases 3 and 4 (deprecating, then removing `Tenant.spec.etcd`, `_namespace.etcd` and `cozy-lib.ns-etcd`) are left for later. ### Design **Names.** For release `kubernetes-<name>` in namespace `<ns>`: | Object | Name | |---|---| | `EtcdCluster`, its headless Service, members `<…>-xxxxx`, `<…>-client` Service | `kubernetes-<name>-etcd` | | Secrets | `kubernetes-<name>-etcd-{ca,client,server,peer,peer-ca}-tls` | | `DataStore` (cluster-scoped) | `<ns>.kubernetes-<name>` | | DataStore endpoint | `kubernetes-<name>-etcd.<ns>.svc:2379` | **Shared templates.** `cozy-lib.etcd.cluster` takes optional `labels` and `annotations` and renders them into the `EtcdCluster`'s `spec.additionalMetadata`, which etcd-operator copies onto every member Pod and PVC. With neither set, it renders no `additionalMetadata` at all. **Values.** One new field, `etcd.replicas`: `3` (default) or `1`. The schema bounds it to 1..3 and the chart refuses 2 at render time. Size (4Gi), resources (1000m / 512Mi limits to start with) and the etcd version (3.6.11, the etcd chart's default) are chart-internal. Where a VerticalPodAutoscaler runs, it sizes each member's requests as it is recreated, up to 5000m CPU / 8Gi memory divided by the platform's CPU and memory allocation ratios (500m / 8Gi at the default ratios of 10 and 1), with the limits scaled in proportion; NOTES.txt and the README say so. **StorageClass.** Two new platform values, `kubernetesEtcd.storageClassLocal` and `kubernetesEtcd.storageClassReplicated`, reach the chart as `_cluster.etcd-storage-class-local` (used with 3 members) and `_cluster.etcd-storage-class-replicated` (used with 1 member). Empty keys fall back to the namespace default StorageClass. `spec.storage.storageClassName` is immutable on an `EtcdCluster`, so the chart reads the live object's class on every render after the first and never re-derives it; scaling 1 → 3 keeps the class the cluster started with. Dropping from 3 members to 1 is refused at render time when the etcd is on the class the platform names for 3 members, or off the class it names for 1, because a single member would then hold the only copy of the control-plane state on storage that does not replicate it. An etcd that was created with one member keeps rendering whatever its class. **New clusters vs existing ones.** The chart decides from the live `KamajiControlPlane`, looked up by release name: - no `KamajiControlPlane`, or one whose `spec.dataStoreName` is the cluster's own name: own etcd; - one that names any other `DataStore`: that `DataStore` is kept, and the chart renders no etcd of its own. Clusters stuck in the old awaiting-etcd state have no `KamajiControlPlane`, so they get their own etcd on their next reconcile. `_namespace.etcd` is deliberately not the signal. `packages/system/cozystack-basics/templates/cozystack-values-secret.yaml` hardcodes `etcd: tenant-root`, and `packages/apps/tenant/templates/namespace.yaml` passes it down, so every tenant publishes a value whether or not an etcd runs behind it. Honouring it for new clusters would change nothing for anyone. Following it for existing clusters is also wrong: today, switching on `spec.etcd` for a mid-level tenant silently moves every cluster below it to a new datastore, which is a Kamaji datastore migration. With this PR, the live binding sticks. An existing cluster renders exactly what it rendered before, pre-delete hook included, apart from randomly generated Talos tokens, so the upgrade rolls no control-plane pods. New clusters carry `policy.cozystack.io/allow-to-etcd-cluster` instead of `policy.cozystack.io/allow-to-etcd`, which only admits a cluster to its tenant's shared etcd. Both lookups the decision rests on read the chart's own live objects: the binding its `KamajiControlPlane` already records, and the immutable `storageClassName` of its `EtcdCluster`. Each gives the same output on every render, and their empty branch is the new-cluster render offline `helm template` sees, which is the kind of `lookup` the chart guidelines allow. **What goes away.** The `awaiting-etcd` beacon goes, along with the `_namespace.etcd` gate on the ~25 addon and satellite templates (`helmreleases/*`, `csi/deploy.yaml`, `kccm/manager.yaml`, `cluster-autoscaler/deployment.yaml`, `ingress.yaml`, the Proxmox CCM and CSI). A datastore now always exists, so these gates were always true. **Deletion.** The pre-delete hook deletes the `TenantControlPlane` and waits up to 120s, and it exits 0 whatever is left, because a failing pre-delete hook keeps the release and retries the same teardown; the one exception is below. Kamaji's `finalizer.kamaji.clastix.io` drops the tenant's etcd role, prefix and user and the datastore-config Secret's finalizer, and it runs only while the `DataStore` is Ready and answers, so a `TenantControlPlane` whose own etcd never came up or has lost quorum would never finish deleting. On a cluster that owns its etcd, those three objects live in the etcd this uninstall deletes next. So when such a `TenantControlPlane` outlives the wait, the hook (Step 4a) removes that one finalizer with a JSON patch that tests it at the index it was read at, waits another 60s, and lets Step 4b clear the Secret's finalizer as before. A `TenantControlPlane` on a shared `DataStore` is left to Kamaji, since that etcd outlives the cluster. The hook also deletes the etcd's five Certificates and then their Secrets (Step 8), which cert-manager issues without an owner, in the same order and for the same reason as Step 7 deletes the Talos PKI. Then: - Helm removes the `EtcdCluster`, `DataStore` and the remaining objects; - the member PVCs go by garbage collection, because the operator owns them through the `EtcdMember`s. If Step 4a's patch is rejected, or the `TenantControlPlane` cannot be read, the hook prints its residue summary and fails before Step 8: Helm would otherwise delete the etcd while Kamaji's finalizer still waits on it, so the uninstall is retried with the etcd and its PKI in place. Steps 4a and 8, that check and their RBAC (a `patch` on this release's `TenantControlPlane`, and `delete` on the etcd Certificates and Secrets by name) render only for a cluster that owns its etcd. ### Deviations from cozystack/community#25 - **DataStore name** is `<namespace>.<release>`, not `<namespace>-<release>`. Tenant names are alphanumeric and nest with dashes, so the dashed form collides: Kubernetes `foo` in `tenant-a` gives `tenant-a-kubernetes-foo`, which is also the namespace, and therefore the shared `DataStore` name, of tenant `foo` under tenant `kubernetes` under `tenant-a`. A namespace cannot contain a dot. Kamaji copies the `DataStore` name into the pod label `component.kamaji.clastix.io/datastore`, so the name is capped at 63 characters, truncated with an 8-character hash past that. - **No truncate-and-hash for `kubernetes.etcdName`.** The app name is now capped at 32 characters (`@maxLength 32`, added with the nodes split), so `kubernetes-<name>-etcd` is at most 48 characters. That is inside the 56 the operator needs: the `<name>-client` Service and the generated member names must fit in 63. The helper fails the render past 56 rather than rename anything. - **"Honour an explicit `_namespace.etcd`"** means keeping a cluster on the `DataStore` its live control plane names, for the reason above. It does not mean following `_namespace.etcd` for new clusters. - **`etcd.replicas` validation** is a schema range of 1..3 plus a render-time refusal of 2, rather than a schema enum. `cozyvalues-gen` v1.7.0, the version CI pins and the latest release, emits string members for an integer enum, which would reject the default `3`. The aggregated API does not validate an application's spec against its schema at all, so neither an enum nor a CEL rule would refuse 2 at admission; Helm's `values.schema.json` check and the render are where it is refused. - **The delete-hook branch** keys on the same live-`KamajiControlPlane` condition as the render, as #25 asks, and additionally checks at run time that the `TenantControlPlane` names this cluster's own `DataStore` before touching Kamaji's finalizer. Helm deletes release resources only after the pre-delete hook, so the etcd outlives Kamaji's normal finalization without any ordering inside the hook. - **TLS** reuses the etcd chart's `secretRef` shape (chart-issued certificates) rather than the operator's `certManager` mode. Kamaji's `DataStore` needs the CA private key to sign each tenant's client certificate, and `secretRef` keeps that key in a Secret the chart controls. The server certificate also carries the operator's `<name>-client` Service names, which the etcd chart's does not. - **Satellites.** The `PrometheusRule` stays in the etcd chart only, so a cluster's own etcd has no alert rules. `VMPodScrape`, VPA and the `CiliumNetworkPolicy` render only where their APIs are served. The etcd chart's `VMPodScrape` now selects `app.kubernetes.io/instance: etcd` instead of `app.kubernetes.io/name: etcd`: etcd-operator stamps the latter on every member it runs, so a tenant etcd would otherwise also scrape the cluster etcds in its namespace and count their members as its own. - **Name budget.** The defrag `CronJob` is `<etcd name>-defrag`, which reaches 55 characters for a 32-character app name while the apiserver caps CronJob names at 52; past 52 the template truncates it and appends an 8-character hash. The etcd chart's `etcd-defrag` is unaffected. - **Defrag image.** The defrag container pulls `ghcr.io/ahrtr/etcd-defrag:v0.13.0` through `cozy-lib.image`, pinned to the multi-architecture index digest, so a configured registry mirror applies; `_etcd.tpl` is tracked by Renovate and listed in `IMAGE_REF_EXTRA_FILES`. This changes the etcd chart's CronJob too, after the extraction commit. Contributed by @yankawai in #5387 and folded in. - **Migration.** The opt-in migration runbook is not implemented here (see below), and no `talosconfig` is issued. The numbered migration only reports, as #25 suggests. ### Gaps #25 did not cover - **Backups.** Covered through the `Kubernetes` backup strategy (#4931), which `cozy-default` routes `apps.cozystack.io/Kubernetes` to. It resolves the datastore from the `TenantControlPlane`, so it dumps the cluster's key prefix from its own etcd or a shared one alike. Its dump Job runs in the application namespace, and the deny policy below would refuse it, so the strategy's pod template now carries `policy.cozystack.io/allow-to-etcd-cluster: {{ .Release.Prefix }}{{ .Release.Name }}-etcd`, which is inert for a cluster on a shared etcd. The strategy's Velero half does not select the etcd's PVCs or TLS Secrets and does not need to: the dump restores into whatever etcd the control plane runs on. - **Per-cluster network policy.** A `CiliumNetworkPolicy` named after the etcd selects its member pods with `ingressDeny` on 2379/2380 against two sets of pods and one entity. The first is pods in the tenant namespace that are neither members nor carry `policy.cozystack.io/allow-to-etcd-cluster: <etcd name>`, a label set on the control-plane pods, the defrag Job and the backup dump Job. The second is pods in any other namespace except `kube-system` and namespaces labelled `cozystack.io/system: "true"`, which is where Kamaji, its migrate Job and etcd-operator run. The entity is `world`, which the tenant's `allow-external-communication` admits to every endpoint, so sources off the cluster, such as Proxmox workers, are denied too. The node's own `host` and `remote-node` traffic is not. Deny rules are needed because the tenant's own policies allow all traffic within a namespace and from ancestor tenants, and allow rules only add. Metrics on 2381 stay open. The pods also carry `cozystack.io/service: kubernetes-etcd` rather than `cozystack.io/service: etcd`, so the tenant-wide `<tenant>-ingress-etcd` policy does not admit child tenants' control planes to them. The policy renders only where Cilium serves `cilium.io/v2/CiliumNetworkPolicy`. - **Platform ordering.** `cozystack.kubernetes-application` now `dependsOn` `cozystack.etcd-operator`. Both come with the isp-full variants, the only ones the iaas bundle allows. The selective-install fixture is unchanged (`hack/select-install.sh --disabled postgres` produces the same set). The same edge makes an etcd-operator change select the `kubernetes-latest`, `kubernetes-previous` and `computeplane` e2e suites besides `etcd`, and `hack/select-e2e_test.bats` now expects that. - **e2e.** - `hack/e2e-install-cozystack.bats` no longer turns on tenant-root's etcd, which only Kubernetes clusters used, and no longer waits for it. A cluster that fell back on a shared etcd would therefore not come up. - `run_kubernetes_test` asserts the control plane names `tenant-test.kubernetes-<name>` and that `kubernetes-<name>-etcd` reaches `Available`. - `kubernetes-latest` runs the shipped defrag CronJob once and asserts the Job completes (from #5387), then probes the etcd client port with `nc -z`: an unlabelled Pod in `tenant-test` and a labelled Pod in `tenant-root` must be refused, and a labelled Pod in `tenant-test` must connect as the control. Each Pod ends `Succeeded` only when its verdict matches, so a probe that cannot run fails the step. - `cozy_cleanup` waits up to 3m until the `EtcdCluster`, `DataStore`, member PVCs and Secrets are gone, each read bounded by that deadline; both Kubernetes suites' teardown op grows from 22m to 25m to cover it. - The Proxmox suite's tenant drops `etcd: true` and the comment calling it mandatory. - The ComputePlane suite's comment no longer cites #4726. - `hack/admin-kubeconfig-invariant.bats` drops its two awaiting-etcd cases, and the now-unused `tests/values-ci-no-etcd.yaml` goes with them. - **Generated artifacts** come from the tooling. `make -C packages/apps/kubernetes generate` produced `values.schema.json`, the README table, `api/apps/v1alpha1/kubernetes/types.go` and `packages/system/kubernetes-rd/cozyrds/kubernetes.yaml`. Root `make generate` regenerated `zz_generated.deepcopy.go`, and `pkg/generated/openapi` did not change. `make generate` in every touched package leaves the tree clean. - **Existing clusters.** Migration 63 → 64 lists every `KamajiControlPlane` whose `DataStore` its own release did not render, judged by Helm's release annotations on the `DataStore`, with that `DataStore`'s endpoints. It writes nothing but the version stamp. Slot check on 2026-11-23: - `main` ships through 62 (#5239) with `targetVersion: 63`; - `release-1.7` ships through 60 (target 61), and `release-1.6` through 53 (target 54); - so this PR takes 63 and sets `targetVersion: 64`. - **README.** `packages/apps/kubernetes/README.md` now describes the cluster's own etcd, the case of a cluster that keeps its tenant's shared one, the VPA sizing and the backup path. The ComputePlane README no longer lists a tenant etcd as a prerequisite. ### Migrating an existing cluster (designed, not implemented) Nothing here moves a cluster, and nothing should until the runbook below has an e2e. It combines #25's runbook with SerjioTT's Talos measurements of 2026-09-03 (about 20s copy, 43s from patch to Ready, reads uninterrupted) and with what Kamaji 26.9.4-edge's code does. 1. **Opt-in.** The opt-in has to make the chart render the cluster's own etcd beside the shared one, without switching `dataStoreName`. The likely shape is a chart-internal value, or an annotation the chart reads, that the operator sets. Wait for `Available=True`. 2. **Snapshot the source etcd.** This is the rollback path. 3. **Pre-flight reachability from the cluster's namespace, not Kamaji's** (SerjioTT finding 1). Kamaji's migrate Job runs in Kamaji's namespace and can reach any etcd, so the copy "succeeds" toward a target the control-plane pods cannot dial; the new apiserver generation then crash-loops and the cluster stays write-frozen. Run `nc -zv <target> 2379` from a pod carrying the control plane's labels in the cluster namespace. For the per-cluster target this holds by construction (same namespace, and the deny policy admits the control plane), but the check stays because rollback goes the other way. 4. **Switch.** Point `KamajiControlPlane.spec.dataStoreName` at `<ns>.<release>`, with the CAPI provider re-projecting it onto the `TenantControlPlane`. `kamaji.clastix.io/migration-timeout` can go on the `KamajiControlPlane`, because the provider copies annotations to the `TenantControlPlane`. Before switching, delete any leftover `migrate-<TCP UID>` Job in Kamaji's namespace: - a leftover with identical arguments is taken as success and switches the datastore without copying; - one with different arguments is deleted and recreated, with the freeze already installed. 5. **Verify writes, not status** (SerjioTT finding 2). Kamaji installs a `kamaji-freeze` ValidatingWebhookConfiguration in the guest, and only its soot controller removes it, only when the `TenantControlPlane` status is exactly `Ready`. A paused `TenantControlPlane`, or one sitting in `WriteLimited`, `Sleeping` or `Upgrading`, keeps the freeze. Node leases are exempt and reads are untouched, so nodes and `kubectl get` look healthy. The success criterion is a canary write through the guest API; if `kamaji-freeze` is still in the guest after the `TenantControlPlane` is `Ready`, delete it. 6. **Restart every worker kubelet, one node at a time** (SerjioTT finding 3). Until it restarts, a kubelet keeps running existing pods but never starts a newly bound one, so the cluster looks healthy and silently stops starting workloads. The per-node check is a new pod starting on that node. - On Talos there is no operator path to the workers' API today: the chart has a per-cluster `talos-ca` Issuer but issues no client credentials from it, so the fallback is `virtctl restart` per VM. - Issuing an operator `talosconfig` from that CA alongside the admin kubeconfig is the follow-up that makes this step cheap. It is not in this PR: it is a separate credential with its own exposure question. - Any pod-based restarter must be deployed before the switch, because a deaf kubelet will not start it. 7. Retain the source prefix and the snapshot for a cool-off period, then reclaim. Kamaji does not clean the old prefix after a migration. Rollback is the same procedure in reverse, against the retained snapshot. ### Test plan Done here, on today's `main`, no cluster involved: - [x] `helm template` of `packages/extra/etcd` before and after the extraction (commit 1) is byte-identical: 14 renders (default; 1 member + local SC + 10Gi; resources with CPU and memory allocation ratios + another version; a global topology spread; a hard affinity with 5 members and 512Mi; leftover `backup.*` values with 0 members; 1 member at 8Gi with a CPU allocation ratio, for the defrag quota flag), each in `tenant-root` and `tenant-abc`, all identical by sha256. After commit 2 the one difference in each is the `VMPodScrape` selector. - [x] `helm template` of `packages/apps/kubernetes` with Cilium served. With `_namespace.etcd` set to `tenant-root`, or empty, both with 3 members: `EtcdCluster/kubernetes-demo-etcd` replicas=3 on the namespace default StorageClass, and `DataStore/tenant-demo.kubernetes-demo` pointing at `kubernetes-demo-etcd.tenant-demo.svc:2379`. The `KamajiControlPlane` names that `DataStore`, and the policy renders. - [x] With the platform StorageClass keys set: 1 member uses `replicated` and 3 members use `local`. 2 members is refused at render time; 5 is refused by the schema. - [x] An existing cluster (live-`KamajiControlPlane` lookup stubbed to return `tenant-root`) renders identically to `main` with `values-ci.yaml`, pre-delete hook included, apart from random Talos tokens. A new cluster's render differs from `main` only by the old shared `dataStoreName`, the shared-etcd pod label and the added etcd objects. - [x] helm-unittest: - `packages/apps/kubernetes`: 392 tests. The 28-case `tests/etcd_test.yaml` covers names, the second cluster in one namespace, the 63-character `DataStore` cap, the 52-character defrag `CronJob` cap at the longest app name, the defrag quota for a 4Gi etcd, StorageClass choice and stickiness, the refused and the allowed drops to one member, refusal of 2, the policy with its `world` deny, and the hook's Step 4a/8 RBAC. For an existing cluster it covers staying on the shared `DataStore`, ignoring a changed `_namespace.etcd`, keeping the shared-etcd label, no own etcd and no Step 4a/8. - `packages/extra/etcd`: 29, including the new scrape-selector case. `packages/core/platform`: 335. `cozy-lib-tests`: 90. `packages/system/backupstrategy-controller`: 67, now asserting the dump Job's label. `packages/apps/tenant`: 89. `packages/extra/computeplane`: 18. - [x] bats, 867 cases, all passing (`helmrelease-readiness` and `bats-runner-coverage` included): every `hack/run-kubernetes*_test.bats` (including two new cases pinning the teardown reads to their deadline), `kubernetes-pre-delete-hook` (13, split into the shared and the own-etcd branch, including the fail-closed exit before Step 8), `check-render-matrix`, `chainsaw-op-budgets`, `migration-62-shared-etcd-report` (new, 4), `admin-kubeconfig-invariant`, `check-hook-request-timeout`, `app-cleanup-hooks_test`, `bats-no-negated-assert`, `bats-no-exit-trap`, `select-install_test`, `select-e2e_test`, `linstor-storage-mode_test`, `cozystack-version-stamp` and `md-no-hardwrap`. - [x] `go build ./...` and `go vet` on the `api/apps/v1alpha1` Kubernetes package. - [x] `make generate` in every touched package and at the root leaves no diff; `hack/check-commit-trailers.sh origin/main..HEAD` passes. Needs a live cluster: - [ ] The e2e lanes: `kubernetes-latest`, `kubernetes-previous` and `computeplane`, now without tenant-root's etcd. The Proxmox lane on its self-hosted runner. - [ ] Upgrade from `main` with an existing cluster on tenant-root's etcd. It must stay on `tenant-root` with no control-plane rollout, and migration 63 must list it. No CI lane runs a cluster on a shared etcd, because the chart no longer creates one; an upgrade lane that installs the previous release first is a follow-up. - [ ] The deny policy beyond what `kubernetes-latest` now probes: from a guest worker VM and from outside the cluster, `nc -zv kubernetes-<name>-etcd.<ns>.svc 2379` must be refused. The control plane, the defrag Job, a `Kubernetes` backup dump Job, an `EtcdSnapshot` Job, Kamaji and etcd-operator must still connect, including a freshly started control-plane pod (Cilium can briefly classify a new pod IP as `world`). - [ ] Delete a cluster whose own etcd never became Available (for example, the quota case below). Step 4a must release the `TenantControlPlane` and the uninstall must finish without manual work. - [ ] A tenant whose `ResourceQuota` cannot fit 3 × 1000m/512Mi limits and 3 × 4Gi requests must surface the quota error on the etcd member pods. - [ ] A backup and a restore through the `Kubernetes` strategy of a cluster that owns its etcd, including the rebuild of a deleted cluster. ### Follow-ups, not opened These are listed here at the maintainer's request rather than filed: - **cozystack/website**: - `content/en/docs/next/operations/configuration/platform-package.md` gains `kubernetesEtcd.storageClassLocal` and `kubernetesEtcd.storageClassReplicated`; - `content/en/docs/next/kubernetes/relocate-etcd.md` describes the shared tenant etcd as what a cluster uses; - tenant and Kubernetes docs telling users to set `etcd: true` for a cluster, which is now an obsolete workaround; - the Kubernetes app reference is regenerated from the README on the next stable tag. - **cozystack/terraform-provider-cozystack**: `internal/provider/kubernetes_schema.go` and `kubernetes_model.go` need `etcd.replicas`, with the default of 3, a 1..3 range and the expand/flatten pair. - **cozystack/cozystack**, after this lands: - an upgrade e2e lane that keeps a cluster on a shared etcd across the upgrade; - alert rules for a cluster's own etcd; - the opt-in migration path and its e2e; - an operator `talosconfig`; - phases 3 and 4. ### Screenshots Not a UI change. ### Downstream repositories Follow-ups are listed above under "Follow-ups, not opened". By the maintainer's decision they are not filed from this draft, so no box is ticked. - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: listed above, not yet filed - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: listed above, not yet filed - [ ] [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(kubernetes): each new tenant Kubernetes cluster now gets its own etcd (EtcdCluster `kubernetes-<name>-etcd` and Kamaji DataStore `<namespace>.kubernetes-<name>`), created and deleted with the cluster, so no ancestor Tenant needs `etcd: true` and the `awaiting-etcd` state is gone. The new `etcd.replicas` field chooses 3 members (default) or 1. Each member starts at 1000m CPU and 512Mi memory limits with a 4Gi volume, counted against the tenant's quota, and a VerticalPodAutoscaler may resize it as it is recreated. The platform values `kubernetesEtcd.storageClassLocal` and `kubernetesEtcd.storageClassReplicated` choose the StorageClass for 3 members and 1 member respectively. Existing clusters keep the shared tenant etcd they run on, unchanged; the upgrade lists them in the migration log. The `Kubernetes` backup strategy covers a cluster's own etcd as it covers a shared one. The tenant etcd's metrics scrape now selects only its own members. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * New Kubernetes clusters now use dedicated etcd by default, with one- or three-replica configurations and platform-selected storage. * Clusters already using shared etcd continue to use it. Installation notes show where control-plane state is stored and summarize resource limits. * Kubernetes add-ons can render independently of tenant-shared etcd settings. * **Bug Fixes** * Cluster removal now waits for dedicated etcd resources to be reclaimed. * Platform upgrades report clusters still using shared etcd without modifying them. * **Documentation** * Updated Kubernetes and ComputePlane guidance on dedicated etcd, storage options, and migration considerations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
16da53637e |
feat(kubernetes): give each new cluster an etcd of its own
A tenant Kubernetes cluster could only start once an ancestor Tenant had an etcd module turned on, which nobody creating a cluster may do, and every cluster below that tenant then shared one etcd, one CA and one disk. Anything that orders clusters on a tenant's behalf had to flip the tenant's etcd on first. A new cluster now renders its own EtcdCluster and DataStore, from the cozy-lib shapes the etcd chart uses, and is created and deleted with them. The awaiting-etcd state goes, since a datastore always exists. An existing cluster stays on the DataStore its live KamajiControlPlane names, and renders what it rendered before. Changing that name starts a Kamaji datastore migration, which freezes the tenant's writes and leaves every worker kubelet needing a restart, so no upgrade may do it. _namespace.etcd cannot decide this: tenant-root publishes one to every tenant whether or not an etcd runs behind it. On uninstall, Kamaji's datastore finalizer drops the tenant's role, prefix and user from an etcd this release deletes next, and it never completes while that etcd is down. The pre-delete hook therefore removes it from a TenantControlPlane on the cluster's own DataStore that outlives the wait, and deletes the etcd's PKI, which cert-manager issues without an owner. If the finalizer stays on, or the TenantControlPlane cannot be read, the hook fails before the PKI goes, so the uninstall is retried with the etcd still in place. A TenantControlPlane on a shared DataStore is left to Kamaji as before. A Cilium deny policy keeps the rest of the tenant namespace, ancestor tenants and off-cluster sources off the etcd ports; the Kubernetes backup strategy's dump Job carries the label it admits. The tenant etcd's scrape now selects its own members by instance, because every member etcd-operator runs carries app.kubernetes.io/name: etcd. The platform waits for etcd-operator before offering the application. The defrag job both charts share pulls its image through the configured registry, pinned by digest to the multi-architecture index, so a mirrored installation does not depend on ghcr.io for it. Tested with helm-unittest on both the own and the shared branch, the pre-delete hook's bats suite run against a stub kubectl for both, and a render of an existing cluster that matches main byte for byte. The guest e2e runs the defrag CronJob once, and probes the etcd client port from a labelled Pod, an unlabelled one and one in tenant-root. Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> |
||
|
|
8f0082a1c8 |
fix(clickhouse): delete the archive when its Backup is deleted (#5224)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Builds on #5229 (merged), which gives every backup run an archive of its own. Deleting a `Backup` taken with the Altinity (ClickHouse) strategy released its finalizer at once and left the archive in the bucket. On the system bucket nothing else prunes it, so every ClickHouse backup stayed until someone called the sidecar by hand, and the route the chart and the examples documented for that, `DELETE /backup/<name>/remote`, does not exist in clickhouse-backup 2.7 and answers 404. The driver names each archive `<application>-<start time as YYYYMMDDHHMMSS>-<first 12 hex digits of the BackupJob UID>` (#5229) and records it on the `Backup` under `altinity.strategy.backups.cozystack.io/archive`. This PR also records, under `altinity.strategy.backups.cozystack.io/use-system-bucket`, the application's `backup.useSystemBucket` as it read when the backup Job was created: the setting is stamped on the backup Job and copied onto the `Backup`, because the application may switch before the controller sees the Job complete. A Job created before the stamp existed falls back to the application as it reads at completion. For a system-bucket application the bucket the projected credentials (`cozy-backups-creds`) name is recorded the same way, under `altinity.strategy.backups.cozystack.io/bucket`. The `Backup` is created with its cleanup finalizer already set, so a `Backup` deleted before the `Backup` reconciler first sees it still has its archive deleted. On `backup.useSystemBucket: true`, deleting the `Backup` runs a one-shot cleanup Job that calls `POST /backup/delete/remote/<name>` on the application's sidecar and holds the finalizer until it completes. The sidecar refuses a delete with 423 while any other operation runs and cannot be reached while its Pod restarts, so the Job waits both out within its deadline; an archive that is already gone counts as deleted, and any other answer fails the Job, which is reported as an `ArtifactCleanupFailed` Warning Event carrying the reason the Job failed and retried after a wait that starts at 30 seconds and doubles with each failure up to 30 minutes (kept on the `Backup` under `altinity.strategy.backups.cozystack.io/cleanup-failures` and `.../cleanup-retry-after`, since the failed Job is deleted to make room for the next). The Job starts only once the projected credentials have reached the sidecar, as the backup and restore Jobs do. It is built by the controller, not rendered as a whole from the strategy template, because the shipped and the example templates run `restore_remote` for every mode other than `backup`; only the image, how to pull it and where the Pod may be scheduled (node selector, tolerations, affinity, priority class) come from the template, rendered as for the strategy's own Pods. When the delete cannot or must not run, the `Backup` is released with an `ArtifactNotDeleted` Warning Event naming the archive left behind: the namespace is terminating, the strategy, the application or its API Secret is gone, the application no longer uses the system bucket (also when it leaves while the delete runs), the system bucket is no longer the one the `Backup` records or cannot be read (also when it changes while the delete runs; a sidecar on another bucket would answer "not found" and the delete would count as done), another Job holds the cleanup Job name, or the archive has the older `clickhouse-<application>-<YYYYMMDDTHHMMSSZ>` form, without its BackupJob's UID. Such a name comes from a controller that predates per-run names; two runs of one application started within the same second share it, and a run still in flight when the controller is upgraded records it later, so it is never deleted. `backups.cozystack.io/skip-artifact-cleanup: "true"` releases a `Backup` without deleting anything. An application on its own bucket keeps the archive's lifecycle, as with MongoDB. The wrong delete route is corrected in the chart comments and the restore scenario. A BackupJob or RestoreJob no longer takes the outcome of a batch Job of its name that it does not control. A Job left by an earlier owner of the same name is waited out, with the `Ready` condition (`PredecessorJobPending`) naming it, until the garbage collector removes it; any other Job holding the name fails the BackupJob or RestoreJob with a message naming the Job. The condition is dropped once the run's own Job starts. The example strategy under `examples/backups/clickhouse` now uploads under the archive name the controller chose and restores the archive the `Backup` records, as the shipped strategy does, keeping its clock-made name and the newest archive only as the fallback for a run given no name; `hack/clickhouse-example-strategy.bats` runs it against a stubbed sidecar. The backup scenario no longer says the archive is expired by the upstream tool's retention, which the chart does not configure. Known limitations: a `Backup` taken before #5208, or by a custom strategy that does not use `.ArchiveName`, does not name its archive and keeps it; a `Backup` that names its archive but not the bucket setting, as every `Backup` taken before this change does (a 1.7.x release that carries #5208 among them), keeps its archive too and is released without an Event; a `Backup` that records no bucket, taken before buckets were recorded, is deleted without the bucket check; a `Backup` deleted during an application uninstall can lose its cleanup Job to the chart's own `<release>-cleanup` hook and is then released with a Warning Event, leaving the archive; the recorded setting and bucket are read when the backup Job is created, not observed from the upload, so a switch made just before a backup, while the sidecar still runs on the previous bucket, is recorded for an archive written to the previous one. Related gap outside this PR, in main today: an archive uploaded by a run whose `Backup` name is already taken is recorded by nothing, so no `Backup` deletes it. Verified with unit tests that drive the cleanup path through a fake client and the cleanup script against a stub `curl`, with mutation checks on every guard, and on a test cluster running v1.7.0 with the backup controllers built from this branch (before #5229 shortened the run name to its current form, which leaves the deletion side unchanged), against the real clickhouse-backup sidecar and SeaweedFS: a backup records a per-run archive name and the bucket setting on a `Backup` created with its finalizer; deleting the `Backup` deletes the archive's objects in the bucket; a restore from a `Backup` brings the data back; a BackupJob recreated under a used name waits for the earlier Job and then writes an archive of its own; a Job of that name created by anything else fails the BackupJob; a `Backup` recording an archive named without a UID is released with `ArtifactNotDeleted` and its objects stay. The changes made after that run (the recorded bucket, the retry wait, the credentials wait before the cleanup Job, the rendered cleanup Pod settings, the cleared predecessor condition, the example strategy) are covered by the unit tests and bats, not by a live run. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#809 (for cozystack/website#808; its `next/` pages should merge after this PR) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(clickhouse): deleting a Backup taken on the system bucket from this release on now deletes its clickhouse-backup archive and keeps the Backup until the delete finished, reporting an archive it cannot or must not delete (including one named without its BackupJob's UID, or in a system bucket the platform has left) as a Warning Event and retrying a failed delete with a growing wait; the cleanup Pod is scheduled as the strategy's own Pods; a BackupJob or RestoreJob no longer reports the outcome of a batch Job it did not create; the documented sidecar delete route is corrected to POST /backup/delete/remote/<name>. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * ClickHouse backups using the system bucket now remove their recorded archive when the backup is deleted. Deletion waits for cleanup to finish. * Backup and restore operations use the controller-provided archive name when available. Restores can fall back to the latest matching archive. * **Bug Fixes** * Temporary sidecar failures are retried with increasing delays. If cleanup cannot safely remove an archive, it completes with a warning rather than risking deletion of the wrong archive. * **Documentation** * Clarified that archives in tenant-owned buckets remain until manually deleted or removed by bucket lifecycle rules. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
4fb8ea40e2 |
test(clickhouse): delete the system-bucket Backup while its S3 host resolves
Deleting a system-bucket Backup now deletes its archive through the clickhouse-backup sidecar, and the Backup is held until that delete is answered. The delete reaches S3 at s3.example.org only through the CoreDNS rewrite and the Ingress certificate the round-trip installs, and the script's EXIT trap removes both. The round-trip therefore deletes its Backup inside the script, before the trap runs, and waits for the cleanup; the preconditions and the step's finally mark a Backup they still find with skip-artifact-cleanup, since no S3 host is mapped by then. The wait covers a cleanup Job that runs out its 600s deadline, the 30s retry delay and a second Job, so the route is not removed while a retried delete still needs it. The test then checks the delete itself by listing the objects under the archive's prefix in the system bucket, through the S3 Ingress with the projected credentials and with folder entries left out: some before the delete, none once the Backup is gone. clickhouse-backup's list/remote is not used for this: it reports an archive for every prefix at the top of the bucket, and SeaweedFS was seen to keep the folders the delete emptied for minutes after all their objects were gone. Co-authored-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> Assisted-by: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> |
||
|
|
0887b43793 |
Merge branch 'main' into feat/capi-v1.13
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
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. ``` |
||
|
|
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> |
||
|
|
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> |
||
|
|
2568db67b1 |
Merge branch 'main' into fix/kubernetes-nodes-surge-before-drain
Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io> |
||
|
|
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 --> |
||
|
|
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 --> |
||
|
|
3badbdef74 |
fix(clickhouse): let a running backup sidecar pick up system-bucket credentials (#5232)
<!-- 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 release with `backup.useSystemBucket: true` can start before the platform projects `cozy-backups-creds` into its namespace. Its `clickhouse-backup` sidecar took the S3 settings from environment variables, which are fixed when the container starts, so the first BackupJob or RestoreJob of such a release failed with `no EC2 IMDS role found` until the Pod was restarted, and a rotated key stayed stale the same way. The projector now also writes a `clickhouse-backup.yml` key into `cozy-backups-creds` (bucket, `https://` endpoint, region when set, keys, `force_path_style` from `backupStorage.forcePathStyle`). On the system-bucket flow the chart mounts that key as an optional Secret volume and points `CLICKHOUSE_BACKUP_CONFIG` at it, instead of setting `S3_*` variables. clickhouse-backup reloads its config file in each API handler that reaches S3 (among them the `create_remote`, `restore_remote` and `list` calls the strategy makes; the `status` and `actions` reads it polls with do not) and kubelet rewrites a mounted Secret in place, so credentials projected after the Pod started, or rotated since, reach the running sidecar. `S3_PATH` stays in the environment because the prefix belongs to the release. Kubelet takes about a minute to refresh the volume, so the projector stamps `backups.cozystack.io/credentials-updated-at` when the projected content changes, and the Altinity driver holds a new backup or restore Job for up to two minutes after that stamp, with `Ready=False` and reason `WaitingForCredentials`; the condition is dropped once the Job runs. A stamp that cannot be read, or one further ahead than clock skew explains, is logged and ignored rather than holding the namespace's jobs for good. The hold applies to every Altinity job in a namespace whose projected Secret just changed, including releases on their own Secret, where it is only a delay. The new e2e Test `clickhouse-3-system-bucket-roundtrip` starts a ClickHouse on the system bucket with no projected Secret, then runs a backup and an in-place restore through `cozy-default` and checks that the sidecar that started without credentials served both jobs. In CI the system bucket's advertised host `s3.example.org` neither resolves nor gets an ACME certificate, so for the duration of its own step the Test serves a SeaweedFS-CA certificate under the S3 Ingress TLS Secret name and adds a marked `rewrite name exact` line for that host to the host CoreDNS Corefile, removing both on exit; it proves the served certificate before any job starts. The bug was reproduced on a test cluster running the code before this change: a ClickHouse started before the projection failed its first BackupJob with `no EC2 IMDS role found`. The new e2e Test has not run green yet outside CI, because it edits the host CoreDNS, which is shared on that cluster. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#799 (draft until this PR merges): `operations/services/backup-classes.md` for the mounted config file, the credentials wait and the upgrade window, without the Pod restart this change removes - [ ] [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): a ClickHouse release on the platform system bucket (`backup.useSystemBucket: true`) now backs up and restores without a Pod restart when its namespace had no projected backup credentials at start, and picks up rotated credentials while running. The sidecar reads its S3 settings from a `clickhouse-backup.yml` file in `cozy-backups-creds` instead of environment variables, so the upgrade rolls every such ClickHouse Pod once. The first Altinity backup or restore in a namespace after its projected credentials change waits up to two minutes (`WaitingForCredentials`) for them to reach the sidecar. Upgrade the platform as a whole: a system-bucket BackupJob started while the new chart runs against the previous controller fails, because that controller does not write the new key. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * ClickHouse system-bucket backups now use a projected configuration file for S3 settings, supporting HTTPS endpoints and optional region and path-style settings. * Backup and restore jobs wait briefly for recently updated projected credentials before starting. * Path-style settings accept common true and false values and are normalized consistently across backup storage integrations. * **Tests** * Added end-to-end coverage for system-bucket backup and restore, verifying restored data without restarting the ClickHouse Pod or backup sidecar. * Added checks for TLS certificate validation and safe restoration of shared network and ingress settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
90f0b043a6 |
fix(kubernetes)!: remove the talos block the chart no longer uses
The kubernetes chart declared a talos block (version, schematicID, imageFactoryURL, installerRepository, registryMirrors). Workers are KubernetesNodes pools and take every one of these from their own talos values, so an operator who set them on the cluster got no error and no effect. The only reader left was a copy of the Talos to Kubernetes support-matrix check, and the pool chart already runs that check itself, against the Talos release each pool actually boots, including one an osImage override selects. The cluster's copy compared the Kubernetes version against a Talos release no node runs. The block leaves the API schema, hence the "!". Stored specs that still carry it keep rendering: the values schema does not close the object and the API does not validate spec against it. A helm-unittest case pins that. Readers outside the chart moved with it. The e2e install read talos.schematicID from this chart's values.yaml in a best-effort block that only warns, so removing the field would have stopped the image cache being seeded without failing anything; it now reads the pool chart, as the proxmox template script already does. The e2e no longer writes a talos block into the Kubernetes CR, the spec test checks the pool chart for the key it emits, the release checklist diffs the pool chart's pins as well, and the catalog guard drops the two tests that compared or read the parent's block. The null-normalization Go tests used talos keys of the real Kubernetes schema as their fixtures; they use oidc.mode, the same required-with-default shape under an optional root section, and addons.cilium.valuesOverride for the free-form case. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> |
||
|
|
c63e83466a |
ci(e2e): raise the E2E job limit from 215 to 265 minutes
A green run of the full Chainsaw suite no longer fits in 215 minutes: the last four nightly runs were cancelled at the limit, and pull requests that select the full suite end the same way while every suite that got to run passed. All lanes that run the suite keep one figure, so a change that passes on a pull request is not cut off on nightly or on a tag. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> |
||
|
|
fe810b7da8 |
test(e2e): read MachineDeployment readiness through the v1beta1 API
The Kubernetes suite waited on status.v1beta2.readyReplicas through a bare "machinedeployment" resource name. That name resolves to the version the cluster prefers: v1beta1 under Cluster API v1.10, v1beta2 from v1.11. In v1beta2 the counter is status.readyReplicas and status.v1beta2 does not exist, so after a Cluster API upgrade the wait would run out its ten minutes and fail. The wait now names the v1beta1 resource, which carries status.v1beta2.readyReplicas on both sides of the upgrade and is served until Cluster API v1.16. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
9978771858 |
feat(observability-proxy): serve tenant namespace logs through an authorizing proxy (#5214)
## What this PR does Adds `observability-proxy`, a new system component that lets a tenant user read the logs of their own namespace from VictoriaLogs with the same Kubernetes credentials they already use for the console, and with Kubernetes RBAC deciding what they can read. This is the first part of the design proposals [Tenant application logs](https://github.com/cozystack/community/pull/95) and [Tenant resource-consumption metrics](https://github.com/cozystack/community/pull/94); this PR implements the namespace logs root only. Metrics and the per-application roots follow in separate PRs. Why a proxy: today the log stores are shared per root tenant and have no notion of a caller, so tenants cannot be given direct read access without seeing other tenants' logs. The proxy authenticates the caller, authorizes the request from its path, and rebuilds the upstream query so that its scope cannot be widened by the client. Backward compatibility: this adds a new package and a new HelmRelease; nothing existing is renamed, removed or changed, so no migration is needed. What is included: - `cmd/observability-proxy` and `internal/observabilityproxy`: the proxy. - Serves `/apis/cozystack.io/v1alpha1/namespaces/<ns>/logs/select/logsql/<endpoint>` for the VictoriaLogs read endpoints the console needs (`query`, `hits`, `stats_query_range`, `tail`, `field_values`, `stream_field_values`, `facets`). Anything else under the root answers `404`. - Authentication by `TokenReview`, authorization by one `SubjectAccessReview` built from the path (`list` on `cozystack.io/logs` in the namespace), both cached briefly. - The upstream request is rebuilt from an allowlist of parameters; the namespace scope is always forced as `extra_stream_filters`. Client-supplied `extra_filters`, `extra_stream_filters`, any LogsQL `options(...)` block, and tenant headers such as `AccountID`/`ProjectID` are not forwarded or are refused. - Non-canonical paths (`..`, `//`, encoded separators) are refused with `400` before any authorization is built, because the console nginx matches on the normalized path but forwards the raw one. - Time window, step, bucket count and result limits are clamped; per-user rate, concurrency and open-tail limits answer `429`. Invalid time, step and limit parameters answer `400`. - The store is resolved from the namespace's `namespace.cozystack.io/monitoring` label. - Live `tail` streams are passed through unbuffered, and the upstream tail request disables compression so headers reach the client before the first line. - `packages/system/observability-proxy`: chart and image build, wired into the root `make build`. - Platform wiring: a new `cozystack.observability-proxy` PackageSource, enabled by default on the full variants and opt-in on the slim ones, the same way as `monitoring-agents`. - RBAC: an aggregated `cozy:observability:view` ClusterRole grants `list` on `cozystack.io/logs` to tenant `view` and above. No API server serves this resource; the rule exists only for the proxy's `SubjectAccessReview`. The proxy's own ClusterRole is limited to the calls it makes (`tokenreviews`, `subjectaccessreviews`, `list`/`watch` on namespaces). - Console nginx: when the proxy is not installed or cannot be reached, the observability roots answer `404` with a Kubernetes `Status` body, which the console shows as not available on this cluster; the proxy's own `502`/`504` for an unreachable store pass through unchanged. - Console: one regex `location` in the console nginx routes the four observability roots to the proxy ahead of `/apis`. The upstream is resolved at request time, so the console starts even when the proxy is not installed; those paths then answer `404` with a Kubernetes `Status` body. The console Deployment now receives the cluster domain for that resolution. - E2E: a new Chainsaw suite `hack/e2e-chainsaw/observability-proxy/` with two tenants, covering `401`/`403`/`200`, scope-widening attempts, path normalization and a long-lived `tail`. #### How it was tested - `go test -race` and `go vet` for the proxy packages. - helm-unittest for `observability-proxy`, `dashboard`, `tenant` and `core/platform`; bats tests for the console nginx routing. - The Chainsaw suite was not run as-is: it deploys its own VictoriaLogs as the root store and refuses to run when a real one exists. Its cases were replayed by a script against the real store on a test cluster. - Verified on a test cluster: - `401` without a token and with an invalid token, `403` for another tenant's namespace, `200` for the caller's own. - Client `extra_stream_filters`/`extra_filters` (GET and POST), an `AccountID` header and another tenant's stream named inside the query do not widen the scope; `options(...)` answers `400`; a path with `..` pointing at another tenant answers `400`; an endpoint outside the allowlist answers `404`. - Through the full browser chain (OIDC login, gatekeeper, gateway, console nginx), a single `tail` stayed open for more than two minutes without reconnecting, and requests from the same session to other tenants' roots answered `403`. - Not verified: the `429` limits under real load. `golangci-lint` has not been run locally. #### Known limitations - The proxy is reachable only through the console route; tenant workloads have no egress rule to it. Every request takes its concurrency or tail slot before the body is read; the token and access reviews and the body read run under `--request-timeout`, so a stalled kube-apiserver answers `503` rather than holding the request; and writes to the client carry a deadline (renewed per line for tails). `--request-timeout=0` disables those bounds and should not be used in production. - The first lines a newly started pod writes can be missing from an already open `tail`, although they are in the store. The likely cause is that Fluent Bit picks up a new log file later than the VictoriaLogs live-tail window; later lines of the same pod arrive. A history query shows them. - The per-application roots (`.../<plural>/<name>/log`, `.../metrics`) and the namespace metrics root answer `404` in this PR. ### Screenshots No UI changes. ### Downstream repositories - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: https://github.com/cozystack/website/issues/787 (docs land once the implementation PRs merge) - [ ] [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: Downstream: `cozystack/website` is reached. A new platform component (`packages/core/platform/sources/observability-proxy.yaml`) triggers `content/en/docs/next/guides/platform-stack/_index.md` and `operations/configuration/licenses.md`; adding it to the system bundle (`packages/core/platform/templates/bundles/system.yaml`) may also need a line in `operations/configuration/variants.md`. A user-facing page for the logs API and the new tenant `view` permission is not required by the trigger map but would be useful. Tracked in cozystack/website#787. Other repositories: no trigger matched. `packages/core/platform/values.yaml` is not changed (only a test fixture), no package under `packages/apps/` gains a values field, and no CRD changes. The root `Makefile` `build` target builds one more image; this does not touch `hack/` or the make targets `ccp` relies on, so `ccp` is not considered affected, but a reviewer may want to confirm. ### Release note ```release-note feat(observability-proxy): add an authorizing proxy that lets tenant users read their namespace logs from VictoriaLogs with their Kubernetes credentials, under `/apis/cozystack.io/v1alpha1/namespaces/<ns>/logs/`. Access requires the tenant `view` role or higher. The component is enabled by default on full variants and opt-in on slim variants. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added an observability proxy for tenant-scoped log access through the console, including live log streaming. Requests are authenticated, access-controlled, and subject to configurable rate and concurrency limits. * Added platform packaging and deployment support, with console routing for observability requests. * **Tests** * Added automated coverage for access control, tenant scoping, query handling, streaming, proxy behavior, and deployment configuration. * **Documentation** * Updated end-to-end test guidance with host requirements for running the observability proxy suite. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
35823c6c9c |
test(clickhouse): list the system-bucket round-trip in the suite header
The header names the backup Tests of the suite and why they are split; it still described two of them after the third was added, so a reader starting from it would miss the only Test that covers the system-bucket path. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
c26d2773a5 |
test(clickhouse): name what really leaves the round-trip's Secret behind
The projected Secret the preconditions delete is left by whichever BackupJob ran in tenant-root before this Test, from this suite or another: Chainsaw does not fix the order of the Tests in a suite, so no particular one can be named. The restore budget is also not spent on a credentials hold: by then the stamp is older than the backup's own two-minute wait. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
5a2582e21c |
test(observability-proxy): preserve JSON seed request bodies
Send JSON seeds with their content type so VictoriaLogs does not consume
log records while parsing form parameters before ingestion.
Fixes:
|
||
|
|
3e907e6f9a |
test(observability-proxy): declare the shell of the e2e helper library
The library is sourced by sh scripts and has no shebang, so shellcheck could not tell which shell to check it as and refused the file. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com> |
||
|
|
f775948d2c |
test(observability-proxy): replay the early line into the e2e tail
The background tail goes through the console route and the proxy's reviews before it subscribes, so the early ingest can land first, and a tail without start_offset returns only lines written after it starts. The tail now replays the last minute, which still leaves the hold and the late-line check meaningful. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com> |
||
|
|
f2ee3ec8ad |
test(computeplane): pin the maxUnavailable bounds and zero through the API
A zero dropped anywhere between the ComputePlane API and the pool chart would let a GPU pool fall back to the chart default of 1, and the render tests never cross the aggregated API. A negative value let through by the ComputePlane schema would only be refused by the pool chart, after the parent release had already been upgraded. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io> |
||
|
|
72a94ee426 |
test(clickhouse): give the round-trip's preconditions room for their deletes
The step's ceiling SIGKILLs the shell and reports only "signal: killed", while a kubectl --timeout that fires first names the object that would not go. The deletes it runs now wait up to 270s in all, past the 3m ceiling, so a stuck delete late in the list would be reported by the ceiling instead of by kubectl. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
0dc5a54731 |
test(clickhouse): remove the round-trip's TLS objects a killed run left
Chainsaw deletes an applied object only when its own apply created it; one left behind by a run killed past its cleanup is patched and kept. The Certificate would then outlive every later run and keep re-issuing its Secret after each step cleanup, and a probe Pod whose sleep had ended never turns Ready, failing the next run's assert. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
f003851338 |
fix(postgres): refuse system databases and never drop them
postgres, template0 and template1 were accepted in databases and handled like an application database. The init job made <db>_admin their owner, installed the auto-grant event trigger in them and, once the entry left values, ran DROP DATABASE on them. That DROP can only fail (template databases cannot be dropped, and the job is connected to postgres), so every later upgrade failed in the init job and the release stayed in UpgradeFailed even after the entry was put back. template1 also passed the takeover on to every database created from it afterwards, where the trigger, naming a role about to be dropped, makes CREATE SCHEMA fail. A release a previous version let take one of them over has to be repaired without dropping it, and without touching what this chart did not create: a role or owner that merely carries an expected name may belong to a tenant or an administrator, and a role comment can be set by any CREATEROLE holder, so only the cozystack:managed mark is trusted. What the marked roles own goes to cozystack:orphaned rather than to the superuser, since a tenant's SECURITY DEFINER function would otherwise run with superuser rights. A failed lookup of the databases cloned from template1 has to stop the run before template1 stops being selected, or those clones would never be repaired. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io> |
||
|
|
8784863632 |
test(observability-proxy): wait for every seeded line before checking scope
The suite checked that B's line and the account-7 line are absent from A's answers but only waited for A's line to become searchable, so an absence could come from a line the store had not indexed yet. The step budgets in the comments now count the calls the steps make. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com> |
||
|
|
ebb5a9cec4 |
test(observability-proxy): cover the namespace logs scope end to end
Unit tests mock the API server and the store, so nothing shows that the console's nginx, the proxy's TokenReview and SubjectAccessReview and a real VictoriaLogs agree. The suite drives a viewer of one tenant through the console against a seeded store: it reads its own namespace, is refused a sibling's, cannot widen the scope with client filters, an AccountID header or dot segments, and keeps a tail open past a minute. The root store is off in e2e, so the suite runs its own VictoriaLogs under the root store's Service name rather than waiting on Fluent Bit. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com> |
||
|
|
28f3613450 |
test(clickhouse): delete the round-trip's TLS Secret in its own step's cleanup
Chainsaw applied the Certificate, so the scripted delete of it in the run step's finally was hand-rolled teardown of a resource Chainsaw already reclaims. Chainsaw deletes a step's applied resources, waiting for them to go, before it runs that step's cleanup operations, which puts the Secret's delete after the Certificate's without any ordering written into a script. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
6e23bd5629 |
test(clickhouse): delete the round-trip's Certificate before its Secret
cert-manager issues the Secret of a Certificate that still exists again as soon as it is deleted, and the Certificate is only removed by Chainsaw's own cleanup after the step's finally has run. Deleting the Secret first therefore left a freshly issued copy behind in tenant-root, carrying no owner reference to take it down with the Certificate. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
1003cdb1b6 |
test(clickhouse): find the round-trip's Ingress Secret by its owner label alone
kubectl refuses a resource name together with a label selector, and the restore asked for both with its stderr discarded, so the lookup always came back empty and the Secret the Test serves under the platform's S3 Ingress name was never deleted. The next run then stops on its own precondition that the Secret must not exist. A lookup that does fail now fails the restore, since an empty answer from a failed read is what kept this hidden. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
6280d06d01 |
test(clickhouse): describe the round-trip's guards by the archive-recording restore
Restores now take the archive the Backup recorded rather than the newest one, and a leftover Backup of the BackupJob's name that records another archive fails the new BackupJob instead of being adopted. The comments justifying the sentinel row and the Backup cleanup, in the round-trip and in its unit test, still gave the earlier reasons, which would send the next reader after behaviour the driver no longer has. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
603114cd7c |
test(clickhouse): check the round-trip restored this run's sentinel row
Every run inserted the same sentinel row and accepted any row after the restore, while the Altinity restore takes the newest remote archive of the release. A restore of an older run's archive therefore passed. The row now carries a per-run value and exactly that row has to come back. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
dee5e6d8bf |
test(clickhouse): mark the round-trip's reachability poll as a fixed wait
The probe loop sleeps between attempts because no Kubernetes condition reports that the host CoreDNS serves the rewrite and the Ingress serves the Test certificate. The e2e conventions allow such a sleep only under the marker that records it is waiting for something to model it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
cabe9a07e2 |
test(clickhouse): reclaim the round-trip Backup by its name
The Altinity driver names the Backup after the BackupJob and adopts one that already exists under that name. The round-trip's cleanup deleted the Backup only through the BackupJob's status.backupRef, so a Backup whose BackupJob never recorded it survived, and the next run's BackupJob would have adopted it in place of a fresh backup. Both the cleanup and the preconditions now delete it by name; the preconditions ceiling grows to cover the extra wait. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
a662198991 |
test(clickhouse): restore the round-trip's shared objects after a step ceiling
The round-trip changes the host CoreDNS Corefile and the S3 Ingress TLS Secret and puts both back from its EXIT trap. When the run step's ceiling fires, Chainsaw kills the shell and the trap never runs, so the rewrite stays in a cluster-wide object and the next run refuses to start. The step's finally runs regardless, so it repeats the restore; after a run whose trap already restored them it finds nothing to undo. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
003bc3ed0b |
test(clickhouse): fail the round-trip when CoreDNS cannot be restored
The round-trip puts the host CoreDNS Corefile back from its EXIT trap, which runs with errexit off. A refused kubectl replace, for instance a resourceVersion conflict with another writer, fell through to the success message and returned 0, so the run stayed green while the rewrite remained in a cluster-wide object and the next run refused to start. The restore now returns the failure. The restore moves into a file of its own so a unit test can run it against a stubbed kubectl and so other callers can share it. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
0ad642e68d |
test(clickhouse): size the system-bucket round-trip server for SQL
The round-trip ClickHouse ran on the nano preset, whose 128Mi limit the clickhouse-1 contract suite never exceeds because it sends no query. This suite writes a sentinel row before the backup, and the server was OOM-killed on that first statement (lastState OOMKilled, exit 137), so the Test failed before it reached the behaviour under test. clickhouse-2 runs the same statements on the small preset. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
dbcc2af679 |
test(clickhouse): require the system-bucket round-trip to run on the sidecar that started without credentials
A Pod restart during the round-trip would hand the sidecar fresh credentials at start, which is how the old environment-based sidecar got them, and the Test would pass without the running sidecar ever picking them up. The Pod uid and the sidecar's restart count must stay the same across both jobs. The probe deadline is now measured on the clock: counting only its pauses let a hanging exec stretch it past the step budget, so the step timeout would fire before the probe could say what stalled. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
2e37aaec5f |
docs(backups): drop the claim that a region change needs a ClickHouse restart
The ClickHouse sidecar on the system bucket no longer reads S3 settings from environment set at start, so a re-projected region reaches it without a Pod rollout, and the contracts fixture no longer depends on optional Secret keys to start its Pod. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
e752952047 |
test(clickhouse): back up and restore a running release through the system bucket
A ClickHouse release on the system bucket starts before the platform projects cozy-backups-creds into its namespace, and no suite exercised that order: the round-trips bring their own Bucket and endpoint, so the sidecar never had to pick up credentials that arrived after it started. The new Test starts the release without the projected Secret and runs a backup and an in-place restore through cozy-default against the bucket as advertised. In CI that host neither resolves nor has a certificate, so the step makes it reachable from tenant-root for its own duration and proves the served certificate before any job starts, which keeps a DNS or TLS problem from reading as a backup failure. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> |
||
|
|
ba0b1ac6ef |
fix(e2e): validate the leak allowlist against every suite layout (#4972)
`lg_allowlist_validate` in `hack/e2e-chainsaw/_lib/leak-guard.sh`
accepted only `<suite>/chainsaw-test.y*ml`, while the selectors already
see step-file suites and a Test nested below the suite directory
(#4630). A suite in one of those layouts could not be put on the leak
allowlist at all: validation failed and the run stopped before the first
suite.
- `lg_suite_has_test` validates an allowlist entry with the rule
`hack/select-e2e.sh` enumerates suites with: `chainsaw-test.yaml`,
`chainsaw-test.yml`, or a numbered step file, anywhere in or below the
suite directory, with the selector's type test (a step-file name counts
unless it is a directory, a `chainsaw-test.y*ml` counts whatever its
type, so Chainsaw reports a directory by that name); a parked
`chainsaw-test.yaml.disabled` matches none. Both sides carry a comment
pointing at the other so they move together.
- `hack/e2e-chainsaw/README.md` describes the three layouts once, under
Layout, and lists `kubernetes-proxmox` as the parked suite.
`docs/agents/e2e-testing.md` points at it.
- Unit tests: every layout is accepted, including a `chainsaw-test.yaml`
that is a directory; a parked, empty, or not-a-step-file directory is
refused, including `1a-install.yaml` (passes the `find` glob, not the
step-file regex) and a directory named `01-install.yaml`.
Left as they are, with the reasons:
- `docs/agents/e2e-testing.md` calling `kubernetes-proxmox` the one
parked suite is correct on main now: `hack/e2e-chainsaw/backup/` was
removed in
|
||
|
|
013b166967 |
fix(e2e): read the KubernetesNodes pool release in the HelmRelease guard (#4970)
`cozy_guard_all_helmreleases` in `hack/e2e-chainsaw/_lib/run-kubernetes.sh` reads the parent `kubernetes-<test>` release and the addons selected by the `kubernetes-<test>-` prefix. The worker pool is `kubernetes-nodes-<test>-md0`, an Application HelmRelease the aggregated apiserver stamps with `RetryOnFailure` like the parent, and it sits on the node-join path through the talos-reconcile Job it renders. Its name does not start with the addon prefix, so a failed action on it was never read, on the passing path or in the failure-path report. This reads it on both paths, with the `required` strategy check the parent gets, since the apiserver stamps both. The pool name is derived from the parent (`cozy_pool_helmrelease_name`), the way the addon prefix is, so the two cannot drift. The failure-path report checks that the release exists before reading it, with `get hr --ignore-not-found -o name`: a run whose pool apply failed has no pool release (exit 0, empty output), and the report says so instead of reporting a failed read. For that run to reach the report at all, `run_kubernetes_test` now arms the exit handler (`_tenant_failure_on_exit`, with `CURRENT_TENANT_PARENT_HR`) right after the parent `Kubernetes` apply instead of after the `KubernetesNodes` apply: before, a failing pool apply exited under errexit with no handler installed, and the parent went unclassified. The snapshot half still no-ops until the tenant kubeconfig is set. A non-zero exit (a timeout, a kill, a Forbidden) is reported as the failed read it is, through `_cozy_guard_read_failure`, never as absence. The pool reads are gated on the report's own deadline as well as the phase clock, like the addon listing. Unit tests in `hack/run-kubernetes-remediation_test.bats` cover a failing pool release on the passing path, a clean one (the composite returns zero), an empty strategy on the pool, the report with and without the pool release, a cut-off existence read, and a pool read past the report budget; the ordering pin now also requires the handler to be armed before the pool apply. The kubectl stub gained an existence read: an `ABSENT` marker prints nothing and exits 0 under `--ignore-not-found` (NotFound without it, as kubectl does), and the failure markers apply to it as `<name>.exists`. Verified with `hack/cozytest.sh` and Bats on `hack/run-kubernetes-remediation_test.bats` (51 tests), `hack/run-kubernetes-node-join_test.bats` and `hack/remediation-guard.bats`. Closes #4737 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Kubernetes release checks now include worker-pool releases alongside the parent release and add-ons, and flag missing or invalid install strategies and remediation failures. * Failure reports distinguish worker-pool releases that are absent from those whose status cannot be read. Existing releases are assessed against the phase gate and report time budget; when the budget is exhausted, skipped checks are identified. * Failure handling now begins immediately after the parent resource is applied, covering errors that occur while applying the worker pool. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
75bb70e58d |
fix(e2e): arm the tenant failure handler before the pool apply
The exit handler was armed after the KubernetesNodes apply, so a failing pool apply exited under errexit with no handler installed: the parent went unclassified, and the report's "pool release does not exist" line described a run that could never reach it. Arm it right after the parent Kubernetes apply instead. The snapshot half still no-ops until the tenant kubeconfig is set, so the only change is that a failed pool apply now gets the parent classified and the absent pool reported. The ordering pin now also requires the handler to be armed before the pool apply. Assisted-by: LLM Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua> |
||
|
|
048c029e29 |
fix(e2e): keep the Proxmox tenant kubeconfig per run and remove it (#4971)
`hack/e2e-chainsaw/_lib/run-proxmox.sh` wrote the tenant's super-admin kubeconfig to `$TMPDIR/proxmox-e2e-tenant.kubeconfig` with the process umask and never removed it, so it outlived the run on the self-hosted runner, world-readable under the usual umask. `dump_diagnostics` then read whatever sat at that path, so a run that failed before `fetch_tenant_kubeconfig` reported the previous run's tenant as its own. - The file now lives under `RUNNER_TEMP`, which the runner exports into every step and empties between jobs; `COZY_PROXMOX_WORKDIR` overrides it for a local run, and `TMPDIR` is the last fallback. The workflow sets no path of its own: the `runner` context is not available in job-level `env`. - `fetch_tenant_kubeconfig` writes it under `umask 077` in a subshell, since the workflow's `umask 077` covers only the staging step. - `apply-tenant`, the suite's first step, removes a leftover before doing anything else, so diagnostics in this run can only see this run's file. - The suite's `finally` removes it, before the `keep_tenant` exit, and the workflow's "Remove staged credentials" step removes it again for a run killed before `finally`. Verification: `sh -n` and shellcheck on the script; actionlint on `e2e-proxmox.yaml` (only the custom `proxmox` runner label is reported, as on main). `hack/proxmox-e2e-fixture_test.bats` has three new cases with a stub `kubectl`: the fetched file has no group or other bits under `umask 022`, `apply-tenant` removes a planted leftover, and the suite's `finally` (run out of the Chainsaw file on the `keep_tenant` path) removes the file, so `diagnostics` after it prints no tenant section. Each goes red with its line (`umask 077`, the leftover `rm`, the `finally` `rm`) removed. All `hack/proxmox-*.bats` pass (fixture 9, teardown contract 8, step1b 4, talos template 12), also under `hack/cozytest.sh`. Not run on a Proxmox stand: the only stand I have cannot dispatch the workflow at the moment, so the workflow steps themselves are unexercised beyond actionlint. Closes #4806 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Chores** * Proxmox end-to-end test runs store tenant credentials in a temporary work directory and create kubeconfig files with restricted permissions. * Stale tenant kubeconfig files are cleared before a new tenant fixture is applied. Cleanup removes the file even when tenant data is retained or a run is interrupted, preventing credentials from appearing in later diagnostics. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
040ae377ae |
test(kubernetes): name the Proxmox fixture's node pool <cluster>-<pool> (#5000)
## What this PR does The Proxmox suite (`hack/e2e-chainsaw/kubernetes-proxmox/`) has now run for the first time on a real self-hosted stand: a dedicated Cozystack v1.7.0-rc.1 management cluster on Proxmox VE, with the runner CageForge offered to host in cozystack/community#98. The suite failed before it reached the hypervisor, because the fixture and the chart disagree on what a node pool may be called. `kubernetes-nodes` names its release `kubernetes-nodes-<CR name>` and, since |