mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 14:42:05 +09:00
1791336e0413ed62da52ed3556a85b4863b14859
1783
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1791336e04 |
feat(mongodb)!: mint tenant passwords through the credentials API (#5380)
## What this PR does MongoDB passwords are no longer readable from the per-user `<release>-user-<name>` Secrets, and tenants lose the `databaseAdmin` login from `<release>-credentials`. Every tenant tier can read both today. An administrator mints a password on the user's `Credential` and sees it once, the operator applies it live, and the next mint or a revoke kills it. MongoDB computes SCRAM itself, so the account Secret keeps the plaintext, readable only by the platform. A user removed from `users` is now also dropped from the database. This is the MongoDB part of the user secrets API design (cozystack/community#137). Stacked on #5379. Review only the top three commits: - `credentials-migrate` gets `--source-key` and `--source-per-account`, to read one source Secret per user. - The chart renders a `plaintext` CredentialTemplate per user, points `passwordSecretRef` at its account Secret and hides `<release>-credentials` from tenants. Every declared user holds an empty marker role, and a post-upgrade hook drops users that hold it but are no longer declared, since the Percona operator never drops a user removed from `spec.users`. - Migration 67 seeds the account Secrets from the per-user Secrets before the chart switches. Its finish Job deletes the per-user Secrets Helm left behind. Tested on a three-node cluster, fresh install: a minted password logs in after 3 s, the old one fails 3 s after the next mint, revoke works, no pod restarts. That run showed a removed user staying in the database, which the last commit fixes. Full upgrade from 1.7.1 on the same cluster, all engines at once with a client loop each: migrations 64-71 ran in order and every account was adopted with its old password. The MongoDB loop had one server-selection timeout during the platform roll and no authentication error. After the upgrade, a removed user is gone from `admin.system.users`. Breaking for users: tenants lose `databaseAdmin`, their only admin login today. Passwords can't be read any more. A user name that collides with a system user, maps to an invalid account name (such as `_backup`), is longer than 63 characters, or maps to the same account as another name (`a.b` and `a-b`) now fails the render. A user removed from `users` is dropped on the next upgrade. Open questions: 1. Should the conversion rotate `databaseAdmin`? Tenants could read it. 2. Without `databaseAdmin`, no tenant user can manage users or the cluster. Add a per-database admin role, or leave it like that? 3. The drop hook fails the upgrade if there's no writable primary within 5 minutes, on purpose. Is that the right trade? ### Screenshots No UI change. ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: needed, a MongoDB note for the credentials API docs (cozystack/website#753) and an upgrade note that tenants lose `databaseAdmin` - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: needed, `cozystack_mongodb` still sends `users.<name>.password` - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: needed, the MongoDB row in the design, and the `databaseAdmin` row once question 1 is decided ### Release note ```release-note feat(mongodb)!: MongoDB passwords are issued through the credentials API. The per-user `<release>-user-<name>` Secrets are removed, `users.<name>.password` is ignored, and tenants can no longer read `databaseAdmin`. An administrator mints a password on the user's Credential; it is shown once and applies within seconds without a restart. A user removed from `users` is now dropped from MongoDB. Existing passwords keep working through the upgrade. Clients that log in as `databaseAdmin` must move to a declared user, and user names that collide with a system user must be renamed before upgrading. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * MongoDB user passwords are now managed through platform account credentials, with one-time issuance and revocation. Password values in app configuration are ignored, and reserved MongoDB system-user names are rejected. * Obsolete chart-managed MongoDB users are removed during upgrades. * Migration support transfers existing MongoDB passwords to platform-managed account credentials. * **Bug Fixes** * MongoDB credential Secrets are excluded from tenant access and enumeration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
06c2be9745 |
fix(platform): stop handing tenants a root S3 the root tenant does not run (#5097)
## What this PR does `cozystack-basics` writes `seaweedfs: tenant-root` into the `cozystack-values` Secret of the root tenant unconditionally, so every tenant without its own SeaweedFS inherits `tenant-root` as its S3, even when `Tenant/root` has `spec.seaweedfs: false`. On a v1.6.5 cluster whose root tenant runs no SeaweedFS, a tenant created a Bucket, its BucketClaim asked for bucket class `tenant-root`, and the objectstorage controller logged `bucketclasses.objectstorage.k8s.io "tenant-root" not found` 8796 times over three days while the app stayed Ready. #5096 makes that state visible in WorkloadsReady, this PR removes its cause. The new platform value `seaweedfs.rootEnabled` reaches cozystack-basics as `_cluster.seaweedfs-enabled`, the same way `monitoring.rootEnabled` reaches it as `_cluster.monitoring-enabled` for #3181, and `_namespace.seaweedfs: tenant-root` is written only when it is true. The default `true` keeps today's behaviour. The slim variants, which do not install SeaweedFS for the root tenant, set it to `false` next to `monitoring.rootEnabled`. Without S3 up the tenant chain the bucket and harbor charts now fail to render with a message that names the problem, instead of creating a claim for a class that never appears. A lookup of the live Tenant is not used, for the reason `monitoring-external-services.yaml` gives for the monitoring gate. An existing Bucket or Harbor in a tenant without S3 up its chain fails its next upgrade with that message once the flag is false. Its BucketClaim was never provisioned, so nothing that worked stops working. The platform tests cover propagation of seaweedfs.rootEnabled. Rendering the root Secret with a missing flag keeps S3 enabled for older installations. For a present key, only true or the string "true" enables it. The bucket and harbor tests also cover the error when the tenant has no S3. All 546 Helm tests across the four charts passed locally. ### Screenshots Not a UI change. ### Downstream repositories `packages/core/platform/values.yaml` gains `seaweedfs.rootEnabled`, which the trigger map routes to `platform-package.md` on the website. The variants page lists what the slim variants need for SeaweedFS, so it gets the same note as monitoring. No app schema, values default or other contract changes. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: https://github.com/cozystack/website/pull/774 - [ ] [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(platform): new platform value seaweedfs.rootEnabled. Set it to false when the root tenant runs no SeaweedFS, so tenants stop inheriting tenant-root as their S3 and a Bucket or Harbor without S3 up its tenant chain fails to render with a clear message instead of waiting on a bucket class that does not exist. The slim variants set it to false, so a slim cluster that runs SeaweedFS on Tenant/root must set seaweedfs.rootEnabled: true before the upgrade, or its Buckets and Harbors stop rendering. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a setting to control whether the root tenant provides SeaweedFS for S3. It is enabled by default and disabled in slim ISP configurations. * Tenant configuration now includes SeaweedFS when root provision is enabled or the setting is unspecified, and omits it when disabled. * **Bug Fixes** * Bucket and Harbor deployments now report a clear error when neither the tenant nor an ancestor provides SeaweedFS, rather than rendering an unusable S3 bucket claim. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
69f5d07c1d |
feat(mariadb)!: mint tenant passwords through the credentials API (#5379)
## What this PR does MariaDB passwords are no longer readable from `<release>-credentials`, which every `use` member and every parent tenant can read today. An administrator mints a password on the user's `Credential` and sees it once. The database stores only its `mysql_native_password` hash, and the next mint or a revoke kills it within seconds. `root` stays the platform's account and is hidden from tenants. This is the MariaDB part of the user secrets API design (cozystack/community#137). Stacked on #5378. Review only the top three commits: - `credentials-migrate` gets `--skip-account`, so no account is written for `users.root`, which the chart always ignored. - The chart renders a `mysql-native` CredentialTemplate per user and points each `User` at its account Secret through `passwordHashSecretKeyRef`. - Migration 66 writes the hashed account Secrets before the chart switches. Its finish Job removes the tenant keys from `<release>-credentials` and keeps `root`. Tested on a three-node cluster, fresh install: a minted password logs in after 3 s, the old one gets `Access denied` 3 s after the next mint, revoke works, and removing a user drops the `mysql.user` row too. Full upgrade from 1.7.1 on the same cluster, all engines at once with a client loop each: migrations 64-71 ran in order and every account was adopted with its old password. The MariaDB client loop had no failures. Breaking for users: passwords can't be read any more. A user name longer than 63 characters, one that starts or ends with a character other than a letter or digit (such as `_backup`), or two names that map to one account (`a.b` and `a-b`), now fail the render; such a release is not converted. A password changed inside MariaDB is reverted by the operator. Open questions: 1. `root` is not rotated, although the design says it should be. The operator reads it on every reconcile and the pods take it as `MARIADB_ROOT_PASSWORD` for their probes, so changing it needs a coordinated restart. So the `root` password tenants could read stays valid. Accept that and fix the design, or rotate it before merge? 2. Not from this diff: the backup CronJob reads `root-password` from a Secret `<release>` that doesn't exist. It needs a separate fix. ### Screenshots No UI change. ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: needed, a MariaDB note for the credentials API docs (cozystack/website#753), an upgrade note, and `backup-classes.md` still points at credentials in `<release>-credentials` - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: needed, `mariadb_schema.go` tells users the password is in `mariadb-<name>-credentials` - [ ] [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: needed only if `root` stays unrotated, to fix the design ### Release note ```release-note feat(mariadb)!: MariaDB passwords are issued through the credentials API and are no longer readable from `<release>-credentials`. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. `root` is no longer visible to tenants. Existing passwords keep working through the upgrade. A user name longer than 63 characters, one that starts or ends with a character other than a letter or digit (such as `_backup`), or two names that map to one account name (such as `a.b` and `a-b`), now fail the render and keep the release unconverted until renamed. Switch clients to minted passwords after the upgrade. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * MariaDB tenant accounts now use individually issued credentials. Passwords are returned when minted, while only password hashes are stored; credentials can be rotated or revoked through the credentials API. * Existing MariaDB accounts are migrated to the new credential system. The platform-managed `root` account remains separate from tenant accounts. * **Bug Fixes** * Tenant-supplied `password` values and `root` entries are ignored, with admission warnings for supplied passwords. Password changes made directly in MariaDB are reverted during reconciliation. * Tenant access to MariaDB credentials Secrets is restricted. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
137b68f07a |
test(hack): skip request-timeout calls that name a kubeconfig or context (#5406)
## What this PR does `hack/check-hook-request-timeout.bats` exempts a file only when it names `KUBECONFIG`. A hook script under `files/` that gets `KUBECONFIG` from its template's env has no reason to name it, so a call that goes through that kubeconfig with `--context` is flagged as an in-cluster call. That is what turned `capi-providers-core/files/upgrade-providers.sh` red on main; #5398 fixed that script by naming `KUBECONFIG`, and this keeps the next script written the same way from hitting it again. The check now skips a line that passes a non-empty `--context` or `--kubeconfig`. client-go serves such a call from the loaded kubeconfig, and without one `--context` fails with "context was not found" instead of falling back to localhost:8080. An empty value (`--context ""`, `--context=`, `--kubeconfig=`) does fall back, so it is still reported, and so is a bare call in the same file. The header notes the limits: a variable that is empty at runtime is not visible to the check, and the match is per line. Tested with `bats hack/check-hook-request-timeout.bats`: 11 of 11 pass, the new cases fail without the change, and each part of the filter is pinned by a mutation. The empty-value fallback was reproduced with kubectl v1.37.2. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note NONE ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Timeout checks now exclude matching lines that specify a non-empty context or kubeconfig value. Empty option values and bare calls on separate lines are still reported; files naming `KUBECONFIG` remain excluded. * **Documentation** * Clarified how context and kubeconfig options affect timeout reporting. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
79ed8e1164 |
fix(redis): let the operator delete a disabled Sentinel PDB instead of a per-upgrade hook (#5429)
## What this PR does When a Redis instance runs a single pod, the chart runs one Sentinel and sets `disablePodDisruptionBudget` on it. The redis-operator stops ensuring the Sentinel PDB once that flag is set, but never deletes the PDB it created earlier, and the PDB's owner reference only removes it together with the RedisFailover. An instance scaled down from three pods therefore keeps a `minAvailable: 1` PDB on its only Sentinel, and every node drain blocks on it. The chart worked around this with a post-upgrade Helm hook: a ServiceAccount, a Role, a RoleBinding and a kubectl Job, rendered on every upgrade of every single-replica instance, to delete a PDB the operator should have removed itself. The operator image is already built in this repository with carried patches, so I fixed it there instead. - `redis-operator`: a new source patch makes the operator look the Sentinel or Redis PDB up on reconcile while its `disablePodDisruptionBudget` is set, and delete it only when the RedisFailover is its controller. A PDB without that owner is left alone, no delete is sent when there is no PDB, and one that disappears between the lookup and the delete counts as done. It has a unit test next to the operator's own `EnsureSentinelDeployment` tests, which the image build runs for every package a patch touches. The patch header says it is carried until an upstream release includes the change. - `redis`: the hook, its RBAC, its chart tests and the `redis.sentinelReplicas` helper extracted for it are removed. The single-Sentinel change and its tests stay as they were. - e2e: the base Redis case now scales its instance from two replicas to one and asserts that `rfs-<name>` existed before and is gone after, and that the data pods' PDB stays. Upgrade: an instance that still has the stale PDB loses it on the first reconcile by the updated operator, which resyncs every RedisFailover every 30 seconds. Until the operator Deployment rolls, the PDB stays, so drains on such an instance can block for that window. Hook objects from earlier upgrades are not release resources, so Helm does not touch them; the successful runs already deleted theirs through `hook-succeeded`. A run that failed leaves its ServiceAccount, Role and RoleBinding named `<release>-sentinel-pdb` behind (its Job goes after an hour through `ttlSecondsAfterFinished`). They grant only get and delete on one PDB and can be removed by hand. Cost: while a PDB is disabled, every reconcile (on each RedisFailover change and on the 30-second resync) reads it once from the API server; a delete is sent only when an owned PDB is still there. I have not run the image build or the e2e suite. The patch series applies on the v3.3.5 tarball, alone and together with the operator patch of the open draft #5382, and every package it touches passes `go test` and `go vet -tags integration`. `helm unittest packages/apps/redis` passes. Upstream v3.3.5 is the latest release and its master still has the same code, so there is no version to bump to; a version of the patch rebased onto upstream master, without the `tlsHash` parameter the carried TLS patch adds, is open as freshworks-oss/redis-operator#93, and the patch header links to it. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: No values key, schema, README or version enum changes; the diff touches an image patch, chart templates and tests, and the Redis e2e suite only. ### Release note ```release-note fix(redis): the redis-operator now deletes the Sentinel or Redis PodDisruptionBudget it created once that budget is disabled, so a Redis scaled down to one replica no longer keeps the Sentinel PDB that blocks node drains, and the chart no longer runs a cleanup Job with its own RBAC on every upgrade of a single-replica instance. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Redis and Sentinel PodDisruptionBudgets are removed when their respective settings disable management, provided they are owned by the RedisFailover. Missing or unrelated budgets are left unchanged. * Sentinel replica counts remain at one when Redis is configured with one replica, and three otherwise. * When switching to one Sentinel replica with PDB management disabled, the Sentinel budget is removed while the data-pod budget remains. The Helm release is then verified as ready. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
19ab55c030 |
fix(platform): stop handing tenants a root S3 the root tenant does not run
cozystack-basics wrote seaweedfs: tenant-root into the root values unconditionally, so every tenant without its own SeaweedFS inherited tenant-root as its S3 even when Tenant/root runs none. A Bucket there got a BucketClaim for a bucket class that never appears, and Harbor got its registry bucket the same way. seaweedfs.rootEnabled records that choice the way monitoring.rootEnabled does for monitoring, and the bucket and harbor charts refuse to render without S3 up the tenant chain rather than wait on a class that does not exist. Older configurations have no SeaweedFS flag. Keep their root S3 enabled. For an explicit value only true or the string "true" enables it. Assisted-by: LLM Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com> |
||
|
|
1b5a5e5cf5 |
test(redis): assert a scaled-down instance loses its Sentinel PDB
Every Redis e2e case runs two replicas, so the single-Sentinel path, where the chart disables the Sentinel PDB and the operator has to delete the one it created for three Sentinels, was covered only by the operator's unit test. Scale the base instance from two replicas to one and assert that the PDB existed before, is gone after, and that the data pods' PDB stays. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
7a94e202ca |
fix(cluster-api): pin the ConfigMap version in every provider selector
capi-operator v0.30 refuses a provider whose fetchConfig.selector matches more than one ConfigMap, and it decides that before it reads spec.version (processProviderConfigMaps). Talos bootstrap, KubeVirt, Kamaji, Proxmox and in-cluster IPAM selected their bundle by a provider-kind label alone, so a version bump left the old and the new ConfigMap matching for the length of the Helm upgrade and failed that reconcile. Core and kubeadm already carry provider.cluster.x-k8s.io/version in both the ConfigMap and the selector; this brings the remaining five packages in line. Each package now defines that version once, in templates/_helpers.tpl, and the ConfigMap name, its version label, the selector and spec.version all include it. Hard-coding the value in four places per provider meant a bump could move the ConfigMap name and leave the label behind, and two bumps in flight in the same package (as #5243 does for capmox and in-cluster IPAM) would then disagree with each other. With one definition a bump is one line and the four references cannot drift. The Talos pair uses its own define because it tracks CABPT, while the kubeadm pair keeps the chart appVersion. The comment in the Proxmox ConfigMap claiming the operator would still pick the right one described the v0.30-or-earlier behaviour and is replaced with what the operator does now. Refs: #5394 Assisted-by: LLM Signed-off-by: Goldloli <39011904+Goldloli@users.noreply.github.com> |
||
|
|
79883fed36 |
feat(platform): convert MongoDB users to minted credentials
Migration 67 seeds the account Secret of every user of every MongoDB release before the chart switches, from the per-user Secret the old chart rendered, so clients keep logging in through the upgrade and the controller adopts the Secrets once the templates exist. The finish Job then strips users.*.password from the values and removes any per-user Secret Helm left behind; <release>-credentials holds only the databaseAdmin platform account and is left alone. The Job's ServiceAccount, ClusterRole and binding carry the migration number: one upgrade can run several conversion migrations in a row, and a shared ServiceAccount deleted by a later hook would cut off an earlier finish Job still running as it. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
0eb96ac872 |
feat(mongodb)!: render a CredentialTemplate per user
Tenant passwords move to the Cozystack credentials API: the chart renders one CredentialTemplate per user and each user of the PerconaServerMongoDB reads its password from the account Secret the controller keeps, so a password is shown once, at mint, instead of being generated at render time. MongoDB computes SCRAM from the plaintext, so the account Secret stores the password itself. The operator re-reads that Secret on every reconcile and runs updateUser when its digest changes, so a mint applies without a restart and the Secret needs no label. The per-user Secrets and users.<name>.password are gone; a password left in values is ignored and draws an admission warning that points at a mint on the user's Credential. <release>-credentials keeps the databaseAdmin system user, a platform account: it is rendered not tenant-visible and the ApplicationDefinition excludes it instead of including it. Users named like a system user, or mapping to one account name or to one longer than 63 characters, are refused. The Percona operator creates and updates the users in spec.users but never drops one that leaves it, so a removed user would lose its CredentialTemplate and account Secret yet keep its last password in MongoDB, with no Credential left to revoke it through. Every declared user therefore also holds a marker role that grants nothing, and only the operator grants it. A post-upgrade hook logs in as the userAdmin platform account and drops the users in admin that hold the marker, are no longer declared, and are not system users. A user without the marker, created by hand or before the marker existed, is never touched. The hook is skipped while restoring from a backup. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
d5c6170892 |
feat(platform): migrate MariaDB accounts to minted credentials
Existing MariaDB releases must keep their clients logging in while the chart switches the Users to account Secrets. The pre-upgrade hook writes those Secrets from the passwords in <release>-credentials, hashed, and marks a fully converted release for seeding; the finish Job then removes the tenant keys from that Secret once the converted chart is Ready, keeping root, the platform's own account. The finish Job and its least-privilege identity get names of their own, so this hook cannot delete the ServiceAccount of migration 64's Job while that one still runs. root is not rotated here: the operator, the server pods' environment and their probes all read it, and an ALTER USER without a coordinated restart fails the probes. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
6c047a473d |
feat(mariadb)!: issue user passwords through the credentials API
Tenant passwords lived in <release>-credentials next to root, which every use-tier member and every ancestor tenant could read, and which had no platform path to rotation. The chart now renders a CredentialTemplate per user and points each User at its account Secret through passwordHashSecretKeyRef, so the database stores only the mysql_native_password hash the API writes, and the watch label makes mariadb-operator apply a mint at once. The reference is there from a User's first reconcile, because a User created without one is locked for good; with the Secret missing the operator only reports the User not ready. root stays chart-generated in <release>-credentials, since rootPasswordSecretKeyRef cannot change once set, and that Secret is now platform-only: the definition excludes it and the chart labels it tenantresource=false. Users mapping to one account name are refused on every path. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential instead of <release>-credentials. BREAKING CHANGE: tenants can no longer read MariaDB passwords from <release>-credentials; a password is obtained by a mint on the account's Credential and is shown once. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
6d72324818 |
feat(platform): migration 65 converts ClickHouse credentials
Existing ClickHouse releases keep working across the chart switch: the hook writes each tenant account's Secret from the password in <release>-credentials and adds the valuesFrom entries the converted chart reads the verifiers from, so its first render already lets every client in. A release with a user under a reserved name is left out and keeps its previous chart. The hook also holds every ClickHouse release, suspended, until both cozystack-controller and cozystack-api run their new revision. Without the hold the converted chart switched while the old controller was still running; it had already rebuilt each release's valuesFrom without the account entries this migration added, so the first render left every tenant user out of the installation and clients were locked out until the new controller put them back, ten minutes later on a test cluster. The old cozystack-api drops the same entries on any tenant write. The finish Job then resumes the releases with the entries put back, strips leftover users.*.password, keeps only the backup password in <release>-credentials and rotates it once, because tenants could read it before. Its ServiceAccount, ClusterRole and binding are named cozystack-credentials-migration-65 like the Job, so an operator finds them next to it and this hook never deletes the identity migration 64's Job may still run as. The role may read Deployments for the hold. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
2f4f82a36c |
feat(clickhouse)!: render a CredentialTemplate per user
Tenant passwords move to platform-minted credentials. The chart no longer generates, looks up or renders any tenant password and ignores users.<name>.password: it renders one CredentialTemplate per user, and cozystack-controller keeps the account Secret holding the SHA-256 of the password the Cozystack API mints. The operator watches no Secrets, and a hash inline in the ClickHouseInstallation is the only path it applies without a restart, so the template asks for a valuesPath: the HelmRelease pulls each stored hash into _accounts.u<digest of the user name>, the chart renders it as password_sha256_hex, and the Flux watch label upgrades the release when a mint changes the Secret. A user with no verifier in the values is left out of the installation, because the operator would give a passwordless user the password "default". backup stays a platform account in <release>-credentials, which now holds only it, is labelled not tenant visible and is no longer selected by the ApplicationDefinition. The names backup, default and clickhouse_operator are refused for tenant users. A rotation of the backup password restarts the pods once, since the backup sidecar reads it from its environment at start. A user whose account name is longer than 63 characters, does not start and end with a letter or a digit, or is shared with another user is refused at render, as credentials-migrate refuses it, so an install and an upgrade accept the same names. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential. Existing clients lose readable passwords; an administrator mints a new one. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
09f6fb5757 |
perf(ci): build release lines from their own cache, in parallel
Release-line image builds read only main's build cache. Once main moved its builder and base images, release-1.7's Dockerfiles stopped matching that cache, and the rc Build step went from 19 to 53 minutes on amd64 and from 10 to 46 on arm64 between v1.7.1-rc.2 and v1.7.2-rc.2. Each line now keeps a cache of its own. build-release.yaml writes buildcache-release-X.Y on every push to the line, and rc builds import it together with main's buildcache. The arm64 rc build, the only arm64 build a line has, keeps buildcache-arm64-release-X.Y itself. CACHE_FROM_TAGS lists every cache a build imports; unset, it is CACHE_TAG, as before. The units of hack/build-matrix.sh now build four at a time (make build- parallel, hack/build-units.sh), since they spend most of their time on registry round trips, one image after another. Every output line carries its unit and is written as it comes, so a job that times out still shows where it stopped. objectstorage-controller waits for the rest because it writes seaweedfs' values.yaml. The rc jobs also leave their buildx builder to the throwaway runner: removing it took up to 11 minutes on arm64. A cache write that fails no longer fails the build (ignore-error=true on every --cache-to): OCIR refuses a blob upload now and then, which already failed the arm64 nightly twice in its last thirty runs, and rc and line builds now write a cache too. Tested with bats: the cache macro, the unit builder against a fake make (the BUILD_JOBS limit, ordering, a failing unit, a failing objectstorage-controller, a unit list that cannot be generated, and output that shows while a unit still builds) and the workflow settings, plus a dry run of hack/build-units.sh over the real units with make -n. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> |
||
|
|
fa9b8f07a2 |
feat(postgres)!: mint tenant passwords through the credentials API (#4922)
## What this PR does Postgres passwords are no longer readable from `<release>-credentials`, which every `use` member and every parent tenant can read today, and `users.<name>.password` is ignored. An administrator mints a password on the user's `Credential` and sees it once. The account Secret stores only the SCRAM verifier, CloudNativePG applies it, and the next mint or a revoke kills the previous password. This is the Postgres part of the user secrets API design (cozystack/community#137) on top of #4921. - The chart renders one `scram-sha-256` CredentialTemplate per user and points each managed role at its account Secret. - The CloudNativePG bootstrap secret of the `app` owner is now that user's account Secret, so the chart no longer generates a password into `<release>-app-owner`. - `users.<name>.createRole: true` is refused at render. A CREATEROLE user becomes a member of each role it creates, CloudNativePG revokes every membership a managed role does not declare, and that revoke fails on the dependent grant, so the role gets stuck in `cannotReconcile`. CloudNativePG has no per-role switch to leave memberships alone. - `credentials-migrate` and migration 64 convert existing releases. The pre-upgrade hook applies the CredentialTemplate CRD, writes each account Secret from the current password as a verifier, and marks the release for seeding only when every account got one. The finish Job runs under its own `cozystack-credentials-migration-64` identity and removes `<release>-credentials` once the controller adopted the accounts. A transient API error is retried before a release is recorded as left out. Live results, on a three-node test cluster upgraded from 1.7.1, with a client logging in every second: - Upgrade: the migration wrote the verifiers, the controller adopted them, the finish Job removed the old Secret, and the client logged in 1014 times with no failure. A later run that upgraded all converted engines at once (migrations 64-71) also had no Postgres failure, for `web` and for the database owner `app`. - A mint returns a password that logs in over TCP; the next mint and a revoke each kill the previous password within 2 s. A stale precondition gets 409 with no password, and a tenant viewer can't mint. - Removing a user removes its template, Secret and role. `createRole: true` fails at render. - After a mint on `app`, the password survived a primary failover and two restarts: CloudNativePG did not reset it from the bootstrap Secret. Breaking for users: passwords can't be read any more, so clients switch to a minted one after the upgrade. A release with `users.*.createRole: true` is left out of the conversion: it keeps its previous chart version, raises `CredentialsMigrationIncomplete`, and fails every upgrade until the flag is set to `false`. The red `E2E (in-tree)` comes from `mariadb-2-backup-roundtrip`, where SeaweedFS rejected a freshly granted BucketAccess key before any Postgres code ran; the three postgres tests pass. ### Screenshots No UI change. ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: needed, a Postgres note for the credentials API docs (cozystack/website#753) and an upgrade note that clients must mint and `createRole` must be off - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: needed, `cozystack_postgres` still sends `users.<name>.password` - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(postgres)!: Postgres passwords are issued through the credentials API and are no longer readable from `<release>-credentials`; `users.<name>.password` is ignored. An administrator mints a password on the user's Credential; it is shown once and applies within seconds. Existing passwords keep working through the upgrade: migration 64 converts every Postgres release and then removes the old Secret. `users.<name>.createRole: true` is no longer supported: a release that sets it is not converted, raises `CredentialsMigrationIncomplete` and fails its upgrades until the flag is set to `false`. Switch clients to minted passwords after the upgrade. ``` |
||
|
|
48d91c2413 |
feat(release): sign the release images and attach their SBOMs (#5042)
## What this PR does
Follow-up to #4997 (merged as
|
||
|
|
8a31d2b09f |
test(postgres): check that a minted password is shown only once
The e2e test mints a password, logs in with it, and checks every place it could be read again: the account Secret must hold a SCRAM verifier, decoded rather than matched in the raw base64; neither the application, any Helm revision nor what the tenant's super-admins read through tenantsecrets may carry it; and they cannot read the account Secret. Each read is captured in an assignment, which stops the script on failure, so a failed kubectl, base64 or gunzip cannot leave a check with nothing to assert on, and at least one Helm release Secret is required. The step runs under bash and passes the password to psql on stdin, never as an exec argument. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
d7144cda9e |
feat(platform): migrate Postgres accounts to minted credentials
Migration 64 converts the existing Postgres releases. It first applies the CredentialTemplate CRD baked into its image, owned by the cozystack-controller release so that release's upgrade adopts it: on a live upgrade the tenant releases switched to the converted chart about 17 minutes before cozystack-controller upgraded, and every render in between failed on the unknown kind. It then runs credentials-migrate seed, which writes the account Secrets from <release>-credentials so clients keep logging in at every point of the upgrade. A release that grants createRole is left out and keeps its previous chart. The finish half runs from a Job the migration creates, not from the platform chart: a chart-rendered Job has a fixed name and an image that changes every release, so the next platform upgrade cannot patch its immutable pod template, and helm-controller would wait on a Job that runs up to 30 minutes and exits non-zero while any release is left out. The Job runs the image the hook runs as, read from its own pod, under a least-privilege ClusterRole rather than cluster-admin, and its ServiceAccount is owned by the Job so the garbage collector removes it. The identity carries the migration number like the Job, so a later conversion migration cannot delete the ServiceAccount a still-running earlier Job uses. The CredentialsMigrationIncomplete alert keys on the incomplete label of the state ConfigMap through kube-state-metrics, which allowlists only that one ConfigMap label, so a release whose plaintext was never retired stays visible after the Job's TTL. The bats suite pins the CRD apply, seed, image read, Job apply, ownership and stamp steps as fail-closed; its fake kubectl counts the Job's name inside the Job document only. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Co-authored-by: Andrei Kvapil <kvapss@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
f982ea2cb9 |
fix(examples): mint the Postgres password in the backup examples
The examples read the application password from <release>-credentials, which the chart no longer renders. They now mint it and pass it to psql on stdin rather than as a kubectl exec argument, which travels in the request URI the audit log records at any level. The minted password is cached in a per-run mktemp -d directory, private and fresh each run, so a later run never reads a password a mint has since replaced and no other host user can read it. The helper's tests stub the mint. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
a67fa94fdb |
feat(postgres)!: issue user passwords through the credentials API
The chart generated every user's password at render time into <release>-credentials, which tenants could read again at any time and which Helm history kept for MaxHistory revisions, so a deployment whose policy requires a credential shown once could not run PostgreSQL here. The chart now renders a CredentialTemplate per user, and the users move under CloudNativePG's managed roles, each pointing at its account Secret, so the operator creates the role with the SCRAM verifier the Secret holds, applies a changed Secret live, and reverts a password set inside PostgreSQL. Every role is rendered as the init-script created it, because the operator reverts an attribute that differs, revokes a parent role missing from inRoles and clears a comment the spec leaves unset. The init-script stops creating, passwording and altering accounts, where it would be a second writer, and keeps the two things the operator has no field for: the marker membership and the reset of the createrole_self_grant an earlier chart set. Its marking pass waits a bounded time for CloudNativePG to create the declared roles before it marks them. users.app adopts the owner CloudNativePG bootstraps, whose password the instance manager applies again from the bootstrap secret on every pod start, so that secret is the app user's account Secret and both writers apply the one stored verifier. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential. createRole is refused on every render path. A role a CREATEROLE user creates makes that user a member of it, CloudNativePG revokes every membership a managed role is not declared to hold, and the revoke fails on the dependent self-grant, so the user would sit in cannotReconcile on ordinary use; there is no per-role switch to leave memberships alone. The account-name checks render with the managed roles too, so a restore cannot bypass them: a user CloudNativePG or PostgreSQL reserves, a database whose derived <name>_admin or <name>_readonly role starts with pg_ or cnpg_ (which makes the CloudNativePG webhook reject the whole Cluster), and a user whose account name is no valid object name are refused. The chart's account naming is pinned to the API's on one table of names. A pre-upgrade hook refuses to let CloudNativePG adopt a role the chart did not mark, because the operator adopts a managed role within seconds of the spec reaching it, before any post-upgrade job could look. It reads the live Cluster first and connects to the database only when the upgrade adds a name CloudNativePG does not manage yet, so a database that is down does not block the resize that might fix it. For each absent declared database role it creates and marks the role as the superuser before the Cluster applies, so no tenant can plant it in the adoption window. The refusal and the create run in one psql session, keyed on a snapshot of the role's existence taken at the top, so a role planted in between collides with the CREATE and stops the hook; the statements are built with format() and \gexec, since psql does not substitute :'role' inside a DO $$ block. Verified on postgres:18: a fresh role is created NOINHERIT, commented and marked, a role planted after the snapshot fails the hook, and an existing unmarked role is refused. The hook reads the Cluster at run time with a ServiceAccount that may get only that Cluster, rather than through a template lookup, which nothing re-renders when the object changes. The flag an earlier chart set when a user held createRole is still read and never set, so such a release keeps refusing to adopt a role it did not mark. The EndpointAttachment e2e suite read testuser's password from that Secret to probe the attached addresses. It now mints one per probe and waits until the application's own Service accepts it, so the attached address is still queried exactly once. BREAKING CHANGE: PostgreSQL passwords are no longer readable from <release>-credentials. A password is issued once, by a mint on the account's Credential in core.cozystack.io, and replaced by the next mint. users.<name>.createRole is refused; a release that sets it keeps its previous chart version and passwords until it is false. Deleting a Postgres application whose release is suspended is refused. The conversion needs a platform variant with migrations enabled. Co-authored-by: IvanHunters <xorokhotnikov@gmail.com> Co-authored-by: Andrei Kvapil <kvapss@gmail.com> Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
c8ffc87717 |
fix(postgres): run the collation repair outside the Helm hook (#5479)
## What this PR does Refs #5459 (item 3: "Waiting for rollout eats Job budget"). **Depends on #5505.** Merge #5505 first or together with this PR. Here a failed repair no longer fails the HelmRelease. #5505 makes the WorkloadMonitor report the failed repair Job as `WorkloadsReady=False` with reason `JobFailed`. Without it the failure shows only on the Job itself. Moving tenant PostgreSQL to another image (for example bullseye `17.7` to `17.12-standard-trixie`) fails the first Helm upgrade of every release whose clients keep sessions open. The collation repair at the end of the post-upgrade init-job waits for CNPG to move the primary to the new image. CNPG rolls the primary last, and every instance spends up to `smartShutdownTimeout` (180 s) in smart shutdown, so the wait uses up the init-job's 540 s deadline and the HelmRelease goes `UpgradeFailed` until Flux retries. When the repair instead meets the primary restart, psql fails with `FATAL: the database system is shutting down` and the upgrade fails the same way. The one commit moves the repair out of the hook. A short post-install/post-upgrade hook, run after the init-job, creates a `<release>-collation-repair` Job through the API (outside the release, so helm-controller does not wait for it) and returns. That Job keeps the OID mark / fingerprint resume and the in-place attempt records. It waits for the new image whenever the image changes, not only when an index already depends on a versioned collation: a plan built on the previous primary would miss an index created meanwhile, which the release recorded at the end would then claim as repaired. In the hook that wait was too expensive to make unconditional. The Job gets an hour, is owned by the Cluster, and its fixed name keeps two repairs from running at once. It carries the WorkloadMonitor's selector labels plus the opt-in `workloads.cozystack.io/report-failure: "true"` from #5505, and has no `ttlSecondsAfterFinished`, so a failed repair stays until the next upgrade replaces it (see the proposal in #5459). Both Jobs now rerun their idempotent script on psql exit status 2 (connection refused or dropped) with backoff instead of failing. Decisions for reviewers: - **Repair failures no longer fail the HelmRelease.** A repair that cannot finish (for example duplicates under a UNIQUE index) shows up as a Failed `<release>-collation-repair` Job and its log, kept until the next upgrade starts a new run. The next upgrade retries it. Before, it showed up as `UpgradeFailed`. - **The repair also runs after install.** The install-time init-job used to record which Debian release each database starts on. Without that record, a cluster whose first upgrade moves the image would have its C.* indexes rebuilt only if the repair reached the primary before it restarted. On a fresh cluster the run only writes that record. The Job sets `PGCONNECT_TIMEOUT=10`. - **A failed rebuild no longer holds back the PostGIS update.** The update runs after the collation pass whatever it found, and the Job still fails at the end if a rebuild failed. - **The e2e upgrades twice.** The second upgrade finds the first repair Job complete on the same image, and the test waits for its replacement to complete. - **Lock waits are bounded by the Job's remaining hour, not about 8 minutes.** This is harmless for `REINDEX CONCURRENTLY`. For the in-place rebuild of an exclusion-constraint index, writers to that table can queue behind its lock wait for longer. Capping it separately means touching the per-index code that the parallel PRs on #5459 also edit, so I left it out. - **The hook's Role** has `get`/`delete` on the repair Job and `get` on the release's Cluster, both by `resourceNames`. It also has `create` on jobs, which RBAC cannot narrow by name. The SA, Role and RoleBinding are deleted once the hooks succeed. - **Verified under Flux.** helm-controller v1.5.0 runs the post-upgrade hooks about a second after it patches the Cluster, without waiting for the rollout. The rollout therefore no longer counts against the release timeout. Details in the PR thread. Rebased onto main after #5477 and #5485. The PostGIS extension update from #5477 waits for the same rollout, so it moves into `repair.sh` after the collation pass; left in the init-job, it would bring the hook-budget problem back for postgis clusters. Every message about a repair or update that did not finish says that the next upgrade of the release starts it again. The starter and the repair Job take their names from one base, which stays distinct and within 63 characters for any release name. ### Testing - `helm unittest packages/apps/postgres`: 32 suites, 257 tests pass, including a new `collation_repair_test.yaml`. It checks gating (upgrade only, skipped while bootstrap is on), hook order after the init-job, the Role rules, RBAC removal on success, name length, and the init-job command. - Docker, with the rendered `run.sh` + `repair.sh` against `postgres:17-bullseye` and stale ICU / en_US collations: - Killing the `REINDEX INDEX CONCURRENTLY` backend mid-rebuild made the pass exit 2. `run.sh` reran it, the already rebuilt index was skipped by the OID mark, and the other index was rebuilt. amcheck was clean and the versions were refreshed. - With the server stopped before the first connection, the script retried with 5 s and 10 s pauses and finished once the server came back. - An SQL error exits 1 and is not retried. - dev7 (cozystack v1.7.0): two 3-instance v17 releases installed from v1.7.1 (bullseye `17.7`), with ICU and en_US UNIQUE indexes on 200k rows and `pg_sleep(3600)` sessions held on `-rw` and `-ro`. Both were upgraded with `helm upgrade --timeout 10m`: - origin/main: the init-job waited for `PostgreSQL 17.12 pgdg13`, hit `DeadlineExceeded`, and the command failed with `UPGRADE FAILED: post-upgrade hooks failed: resource Job/tenant-root/rr-main-init-job not ready. status: Failed` (exit 1 after 611 s). - This branch: exit 0 after 70 s (init-job 9 s, starter 10 s, starter RBAC removed afterwards). The repair Job waited out the rollout and rebuilt `t_u` and `t_k`. Collation versions were refreshed to `2.41` / `153.128`, `bt_index_check(..., true)` passed on all three instances, and the resume mark was reset. - A second upgrade replaced the finished repair Job, and the rerun found nothing to do. - The rebuild sat in `waiting for old snapshots` behind the test client's open transaction. That is expected for `REINDEX CONCURRENTLY`; I ended that session to finish the run. ### Downstream repositories Walked against the diff (the new template, test and init-script/init-job changes in `packages/apps/postgres`). The diff changes no values, schema, `ApplicationDefinition`, Secret or Service names, package layout, or tooling. The only new objects are a hook-scoped ServiceAccount/Role/RoleBinding/Job and a Job created at runtime, which no listed repository refers to. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: - Flux (dev cluster, helm-controller v1.5.0): a tenant app on the v1.7.0 chart (bullseye `17.7`, 3 instances, sessions held on `-rw`/`-ro`) was upgraded by switching the platform's postgres chart. - With this PR, the HelmRelease reached `UpgradeSucceeded` in 21 s, and the repair Job finished after the rollout with `bt_index_check` clean on all instances. - With main, the upgrade took 7 min 06 s of the 10-minute timeout. - Docker: the rendered `repair.sh` for the postgis flavor moved PostGIS 3.6.1 → 3.7.0 after the collation pass. A tenant trigger on `spatial_ref_sys` did not run. ### Release note ```release-note [postgres] An image change of a tenant PostgreSQL no longer fails the Helm upgrade while CNPG rolls the instances. The collation repair now runs in a separate `<release>-collation-repair` Job, started after each upgrade, which waits for the new image and retries after connection drops. Check that Job's status and log to confirm the repair finished. ``` |
||
|
|
0c00c4545e |
ci(release): refuse a Promote RC dispatch from any ref but main (#5181)
## What this PR does Adds a first step to the `parse` job of `promote-rc.yaml` that fails when `github.ref` is not `refs/heads/main`, before anything is written. This is A20 in #3278. A `workflow_dispatch` runs the copy of the workflow at the dispatched ref. On 2026-10-16 a dispatch from `release-1.6` ran that branch's older copy (one job instead of five, https://github.com/cozystack/cozystack/actions/runs/38882938797) and was re-run from `main`. Since #4861 the release assets are signed, and the same dispatch would now fail at the upload step, after the staging branch, the `promotion-*` candidate and the draft release already exist. `docs/release.md` also pins the signature identity to this workflow on `main`, so a dispatch from another ref should stop at the front door. The step follows the shape of `Validate dispatch branch` in `cut-prerelease.yaml`: one shell comparison, an `::error::` that names `main`, `exit 1`. ## Test `hack/promote-rc-dispatch-ref_test.bats` extracts the step's `run` with `yq` and executes it under `dash` for `refs/heads/main` (passes), a release branch, a tag and an empty ref (each fails and names `main`), and pins the step to be `parse`'s first step reading `github.ref`. It runs with the rest of `hack/*_test.bats` via `make bats-unit-tests`. `zizmor` on the workflow reports no findings. ## Docs One clause in step 3 of the regular release sequence in `docs/release.md`. #5169 edits the same file further down and the `promote` job of the same workflow; the hunks do not overlap. ## Checklist - [x] Commit is signed off with `--signoff` - [x] Commit carries exactly one `Assisted-by: LLM` trailer - [x] `hack/check-commit-trailers.sh upstream/main..HEAD` passes - [x] `bats hack/promote-rc-dispatch-ref_test.bats` and `bats hack/bats-strict-setup.bats` pass <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Workflow Updates** * Release candidate promotions dispatched from branches or tags other than `main` are rejected. Older workflow copies on release branches may still create a staging branch and draft release before stopping. * **Documentation** * Release instructions clarify that promotions must be dispatched from `main`, regardless of the release line, and note the behavior of older workflow copies. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
b08b4949eb |
feat(release): sign the release images and attach their SBOMs
A release has signed its assets since #4861, but not the container images a cluster installed from it pulls, and the SBOM each image carries since #4997 sat in the registry only, readable with buildx and signed by nothing. A user could verify the ISO they booted and not the platform it installed. hack/sign-release-images.sh signs every first-party digest the repinned tree holds with cosign, keylessly, in prepare-release after the stitch, one cosign call per digest so that cosign's per-call timeout does not grow with the number of images. It skips a digest that already verifies, so a re-run stacks no second signature, and verifies each one against the identity docs/release/signatures-and-sbom.md names before hack/upload-assets.sh runs, so nothing is uploaded over an unsigned image. The draft release is created only after that step, so a failed signing run leaves no draft for a re-run to take for a finished release. The signature over an index covers the attestation manifest the index lists, so the SBOM needs none of its own, and cosign stores it as a referrer of the digest in the repository hack/promote-retag.sh copies the digest within, so promote-rc.yaml only verifies, with the rc tree's script, before it stages the stable release, and prints cosign's reason for every digest that fails. hack/collect-image-sboms.sh reads the SBOM attestation of every such image back into cozystack-images-sbom.tar.gz, one SPDX document per platform, and fails on an image that lacks one for any platform its index serves. With cozystack-images.txt, the digests the signatures are bound to, both join the asset list hack/upload-assets.sh hands to hack/sign-release-assets.sh, so the existing checksums signature covers them. docs/release/signatures-and-sbom.md gains the verification recipe for a whole release, which requires a signed checksum entry for each of the two image assets; cozystack-scheduler, whose image a separate repository builds, is not in the list. The bats files pin the scripts, the recipe, the upload list and the two workflow steps. Refs #2937, #3278 Assisted-by: LLM Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua> |
||
|
|
a768c81b49 |
feat(linstor): add Blockstor as a selectable storage backend (#2942)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list; pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Adds Blockstor as a second control plane the `linstor` package can deploy, chosen at install time with `storage.backend` on the platform. LINSTOR stays the default, and a cluster that does not select blockstor renders exactly what it renders on `main`. Blockstor serves the LINSTOR REST API, so linstor-csi, piraeus-operator and the StorageClasses are the same for both. This PR is for new clusters only. Moving a cluster that already holds LINSTOR volumes to blockstor (the `storage.blockstorMigration` steps, the hook Jobs that relax piraeus's webhooks while the operator is stopped, and the README order) is split out into #5466, stacked on this one. Blockstor is experimental. The package pins blockstor 0.4.0, all three images by digest, and the chart refuses to render if the controller, apiserver and satellite tags name different releases. 0.4.0 advertises REST API 1.29, which the linstor-csi v1.13 on `main` requires. A LUKS volume formatted by blockstor 0.2.x is neither opened nor re-formatted by 0.3.0 and later, since 0.3.0 wraps a per-volume password under a master key. This only matters for clusters that ran an earlier revision of this branch; nothing on `main` ever shipped blockstor. Default path: - `helm template packages/system/linstor` is byte-identical to `main` (defaults, `talos.enabled=false`, `drbd.enabled=false`, explicit `backend=linstor`). - The platform renders the `cozystack.linstor` Package without components, as on `main`, so an upgrade rolls no new revision of the release. Selecting the backend: `storage.backend` falls back to `linstor` only when the key is absent. Any other present value fails the render, `""`, `false` and `0` included. `null` is the one case the chart can't see, Helm drops a null key before rendering. The `linstor` chart checks the value on its own too. Changing the backend of a running cluster fails the render, the same way the networking variant guard works: the platform looks up the live `cozystack.linstor` Package, and `storage.acknowledgeBackendChange: <target>` confirms the switch on a cluster that has no volumes yet. Under blockstor the package renders blockstor's controller, apiserver and satellite, plus its CRDs with `helm.sh/resource-policy: keep`, since those objects are the whole blockstor database. piraeus-operator runs in external mode against the apiserver's mTLS port and uses a client cert from the same CA for its own version probe (#4016). linstor-scheduler and linstor-gui are told only the backend by the platform and read the endpoint and client Secret from that same `LinstorCluster` (`spec.externalController.url`, `spec.apiTLS.clientSecretName`), the object that points linstor-csi there, so the names of blockstor's Service and Secret live only in the linstor package and nothing renders objects under piraeus's names. Under linstor they get no values and keep their defaults; the scheduler chart takes this through one more vendored patch. Under blockstor a `LinstorCluster` that names no external controller yet fails their render instead of falling back to linstor-controller: on a backend switch they can upgrade before the linstor release has rewritten that object, and the fallback left them on a Service the operator then deletes, with nothing to render them again. The platform's HelmReleases retry a failed render every retry interval without counting it as a failure, so they follow once the linstor release is through. Every blockstor component finds the Secret that opens its master key through `ControllerConfig/default`. A post-install/post-upgrade hook Job server-side applies `spec.passphraseSecretRef` there, pointing at piraeus's `linstor-passphrase` (key `MASTER_PASSPHRASE`, the name is the `blockstorPassphraseSecret` value), and leaves the rest of the object to blockstor. It is a Job and not a release object because the CRD comes with the same release. The controller opens nothing and creates no keyring until the reference is there, so starting before the Job is harmless. Because the passphrase Secret is always named, `linstor encryption create-passphrase` is refused under this chart: the operator creates `linstor-passphrase` by hand before the first encrypted volume. piraeus still runs a `linstor-satellite` pod on every node it picks for `linstor-csi-node`, and `LinstorCluster` has no setting that stops one without the other. So cozystack's satellite configuration, its internal CA and the satellite scrape stay under both backends: the pod is pinned to our image, with TLS, limits and host networking, and the address the operator registers a node with is the node's own. The plunger and the opt-in Talos graceful-shutdown hook stay LINSTOR-only (the hook is refused under blockstor), because they act on DRBD resources that under blockstor belong to blockstor-satellite. blockstor-satellite runs the plunger's DRBD workarounds itself, and the chart lets it act on a stalled resync (LINBIT/drbd#149) instead of only reporting it: `blockstorSatellite.stalledResyncAct`, on by default. There is one `LinstorCluster` document for both backends, only the keys that differ are gated, so the CSI part (strict topology and main's group-snapshot gate included) can't drift. RBAC and exposure: - `cozy-linstor` is shared with piraeus, so no blockstor component can read an arbitrary Secret there. Each has a namespaced Role naming only `blockstor-master-key`, `blockstor-unlock` and the passphrase Secret: the satellite gets `get`, the controller and the apiserver get `get` and `update`, plus `create`, which RBAC cannot limit by name. The named rules also allow `list` and `watch`, which newer blockstor releases use with a `metadata.name` field selector; - because that `create` is unnamed, a ValidatingAdmissionPolicy admits a Secret create by a blockstor ServiceAccount in the release namespace only for the keyring and the generated `blockstor-unlock` Secret, with the types blockstor gives them; - no component has cluster-wide Secret access; - the apiserver's plain HTTP listener is bound to `127.0.0.1`, port-forward still works; - the controller has no leader election, so its Deployment uses `Recreate`, and neither it nor the satellite gets leases; - the satellite deletes nothing but the PhysicalDevices it discovers, and the roles name every blockstor kind they grant; - the satellite's host ports (3372, 9101, 8080) are closed to the world, same as drbd-reactor's; - the controller and the apiserver get 21s to stop, so a SIGTERM does not cut a detached rollback short. The snapshot stream between satellites runs on port 3372 over mutual TLS, with a CA of its own from `ca-bootstrapper`, kept apart from the API CA. The `blockstor-satellite` DaemonSet rolls one node at a time and holds each node for `blockstorSatellite.minReadySeconds` (180 by default) after Ready, because the satellite is Ready seconds after start while its first pass over the node's DRBD resources ended 1.5 to 2.7 minutes later on a test cluster with about 110 resources per node. `maxUnavailable` is fixed at 1 and `maxSurge` at 0, and `OnDelete` is there for an upgrade checked node by node; the README describes that procedure. The trade-off to review: the HelmRelease waits for the whole rollout, about 3.5 minutes per node at the default, so on more than two or three nodes the first upgrade attempt times out and the retry finishes it, and `HelmReleaseNotReady` fires meanwhile. None of the three components sets a CPU limit, as the LINSTOR controller and satellite don't: under a 500m limit every reconcile pass got throttled and each volume create took tens of seconds. Memory stays limited. The e2e scripts prepare and check whatever `COZY_STORAGE_BACKEND` says, and refuse an unset or unknown value. Under blockstor the prep waits until every satellite reports its pool before applying StorageClasses. `make update-blockstor-crds` refreshes `definitions/` from the blockstor tag the images are pinned to. For 0.4.0 it reproduces the release's CRDs byte for byte. Every `DrbdOptions/*` key the chart sets on the controller and the e2e StorageClasses set passes the whitelist 0.4.0 enforces. ### Testing - `make test` in `packages/system/linstor`: helm-unittest 133/133 in 20 suites, Python 20/20. - `helm unittest` in `packages/core/platform`: 394/394; `packages/system/linstor-scheduler`: 31/31; `packages/system/linstor-gui`: 28/28. - `bats`: `hack/linstor-storage-mode_test.bats` 33/33, `hack/post-install-prep.bats` 25/25, `hack/platform-packages_test.bats` 16/16. - Every guard was checked by reverting it and watching its test fail: empty backend, shared strict topology, loopback bind, `Recreate`, the satellite role, the pool report wait, the pool guard retrying a read that exits 2, the graceful-shutdown refusal, the stream port and its TLS, no cluster-wide Secret access, the named Secret grants, the admission policy, the stop grace, the one-release image check, the rollout strategy and pause. - `hack/check-commit-trailers.sh origin/main..HEAD`: OK. ### Not tested - A live run on 0.4.0 passed on a three-node stand installed with `storage.backend: blockstor` and upgraded to this PR's pin, see https://github.com/cozystack/cozystack/pull/2942#issuecomment-7225299079: Filesystem and Block PVCs, LUKS, snapshot and restore, group snapshots across nodes, online resize, `vmdisk-clone`, and the `vminstance` chainsaw suite including the VM backup roundtrips. That run predates the scheduler and GUI render guard above, which is unit-tested only. No CI lane can run blockstor: every e2e lane runs Talos in containers without DRBD. - The passphrase hook Job and the admission policy are rendered and unit-tested here; this PR has no run of them on a fresh install. - The satellite rollout strategy has not rolled on a live cluster; the timing figures come from a manual node-by-node `OnDelete` upgrade. ### Screenshots N/A, no UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. --> - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: https://github.com/cozystack/website/pull/667 documents the backend, `storage.acknowledgeBackendChange` and this chart. It still describes blockstor 0.2.0 and has to follow this PR to 0.4.0 and to the master key opened from `linstor-passphrase`. Its LINSTOR to Blockstor migration guide belongs with #5466. It stays unticked and merges after this PR. - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: I walked the trigger map against the diff. Only the website is affected: the new `storage.backend` key in `packages/core/platform/values.yaml` and the backend docs, both in website#667. No app package, installer values, variant, bundle, `hack/package.mk` or `hack/update-crd.sh` is touched. ### Release note ```release-note feat(linstor): Blockstor can be selected as the storage control plane for new clusters with `storage.backend: blockstor` on the platform. LINSTOR stays the default and existing clusters are unchanged. Blockstor is experimental, and moving a cluster that already has LINSTOR volumes to it is not part of this change. ``` |
||
|
|
66bba3bf1e |
fix(postgres): run the collation repair outside the Helm hook
The collation repair ran at the end of the post-upgrade init-job and, when the image moved, waited for the primary to run it. Helm starts that hook as soon as the Cluster is patched; CNPG then rolls the replicas first and the primary last, and every instance whose clients hold sessions sits in smart shutdown for smartShutdownTimeout (180s on existing clusters). With three instances the wait took about eight of the Job's nine minutes, the Job printed "the init-job is out of time, the next run of it carries on" and the HelmRelease went UpgradeFailed until Flux retried. When the Job's psql met the primary restart instead, it failed with "FATAL: the database system is shutting down" and failed the upgrade the same way. A rebuild of a large index does not fit the hook budget either. Moving the repair into an ordinary manifest does not help: helm-controller waits for every Job of a release to complete within the same upgrade timeout. So a short post-upgrade hook, run after the init-job, creates the repair Job through the API, outside the release, and returns. The repair Job has an hour, keeps the wait for the new image and the resume marks it had, and is owned by the Cluster. It has a fixed name, so two repairs never run against one Cluster: the hook leaves one still running on the same image alone and deletes any other, waiting for its pod to go, before creating the new one, which also retries a repair that failed. The hook's Role reaches only that Job and the release's Cluster by name, apart from create, which RBAC cannot narrow, and is deleted once the hooks succeed. psql exits with status 2 both when an instance refuses connections while shutting down and when it drops a session, so both Jobs now rerun their script after a growing pause on that status instead of failing; the scripts are idempotent and their elapsed-time bounds keep counting across attempts. A connection lost during an index rebuild is reported the same way. smartShutdownTimeout stays as it is: the repair no longer waits inside the hook, so the rollout's length does not matter. The PostGIS extension update waits for the same rollout, so it moves into the repair Job with the collation pass, and the messages of both name the next upgrade of the release as what starts them again. A lost connection in the PostGIS pass is reported with the same status as in the collation pass, so the Job reconnects instead of giving up. The repair runs after install as well. The init-job used to record there which Debian release each database started on, and without that record the first image move is detected only if the repair reaches the primary before it restarts. The Job sets PGCONNECT_TIMEOUT, so a primary that does not answer is retried instead of using up the Job's deadline. A failed index rebuild no longer stops the PostGIS update that follows it: a unique index that duplicates keep from being rebuilt would otherwise hold the extensions back until an operator removes them. The Job still fails at its end. With an hour to spend, the repair now waits for the new image whenever the image changes, not only when an index already depends on a versioned collation. Otherwise it planned on the previous primary, missed an index created meanwhile, and the release it recorded at the end claimed that index repaired. The repair Job carries the WorkloadMonitor's selector labels, opts in to having its failure reported with workloads.cozystack.io/report-failure, and has no ttlSecondsAfterFinished, so a failed repair stays visible until the next upgrade replaces it instead of vanishing while the indexes stay wrong. Refs: #5459 Assisted-By: LLM Signed-off-by: Andrey Kolkov <androndo@gmail.com> |
||
|
|
d617d52bfd |
refactor(linstor): follow blockstor's API group to blockstor.org
blockstor moves its API group from blockstor.cozystack.io to blockstor.org before anything is deployed on it. The chart's CRD copies, the RBAC rules of the apiserver, controller and satellite, the chart tests and the e2e helpers that read the storage pools now use the new group. This needs the blockstor release that carries the rename, which the backend is pinned to before this PR merges. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
cf7bd11eeb |
test(e2e): prepare and check the backend the install deploys
The e2e scripts assumed LINSTOR throughout: the prep created pools through linstor-controller and the replicated suite's pool guard read them from it. COZY_STORAGE_BACKEND is now set once by the install step and reaches the platform values, the prep and the Chainsaw suites alike. The prep refuses a missing or unknown value instead of guessing, which would race the install and fail open to linstor. Under blockstor the prep waits for blockstor's own Deployments and for every LinstorSatellite to apply, registers a Node per Kubernetes node at its InternalIP, creates the data zpool and its StoragePool on each satellite, and waits until every satellite has reported its pool, since placement does not count a pool before that. The pool guard reads StoragePool objects and lists datasets through blockstor-satellite. The backend is validated before the guard starts polling. Inside the loop every failed read is retried: the remote jq exits 2 on the output a restarting controller can print, so no read status can mean "give up". blockstor needs DRBD and the QEMU lane's private disk, so the pair with COZY_LINSTOR_DRBD_ENABLED=false is refused rather than installed into a prep that cannot finish. No CI lane sets the variable, so the default runs are unchanged. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
be0a55c072 |
feat(linstor): make Blockstor a selectable storage backend
Blockstor is a control plane for DRBD-replicated volumes that serves LINSTOR's REST API and keeps its state in Kubernetes objects instead of a SQL database. Because it speaks LINSTOR's API, linstor-csi, piraeus-operator and the StorageClasses stay as they are, and the linstor package can deploy either control plane behind them. The platform chooses through storage.backend, linstor by default. The default leaves the linstor Package as it was, with no components, so existing clusters render exactly what they rendered before and roll no new revision. A value present but not one of the two strings fails the render, empty ones included: read as linstor, an empty override on a blockstor cluster would switch its control plane back. The linstor chart refuses an unknown backend on its own too, since a value can reach it without passing through the platform. Under blockstor the package renders blockstor's controller, apiserver and satellite, and its CRDs with helm.sh/resource-policy: keep, since those objects are blockstor's whole database and a switch back to linstor must not delete them. piraeus-operator runs in external mode against blockstor-apiserver's mutual-TLS port, and is pointed at a client certificate from the same CA for its own version probe, which otherwise fails and stops every LinstorCluster and LinstorSatellite reconcile. linstor-scheduler and linstor-gui read that endpoint and client Secret from the same LinstorCluster, rather than from objects rendered under piraeus's names, so the platform tells them only the backend and no package but this one names blockstor's Service. piraeus still runs a linstor-satellite pod on every node it selects for linstor-csi-node, and nothing in LinstorCluster stops that without also stopping the CSI node plugin. So cozystack's satellite configuration, its internal CA and the satellite scrape stay under both backends: what runs is pinned, uses TLS and host networking, and the address the operator registers each node at is the node's own rather than one on the pod network. The plunger stays with LINSTOR, as it drives DRBD resources that under blockstor are blockstor-satellite's alone, and the opt-in Talos graceful-shutdown hook is refused under blockstor for the same reason: it downs every idle Secondary resource in the shared kernel. The LinstorCluster is one document with the differing keys gated, so the CSI half, strict topology included, cannot drift between the two. The apiserver's plain-HTTP listener, which authenticates nobody, is bound to loopback. The controller runs without leader election, so its Deployment uses the Recreate strategy. Each workload is granted what it uses: the apiserver writes Secrets only in its namespace, the satellite reads its one Secret there and deletes nothing but the PhysicalDevices it discovers, and neither binary gets leases, since neither runs leader election. The roles name every blockstor kind they grant. The satellite's unauthenticated host-network ports are closed to the world the way drbd-reactor's are. Blockstor is for new clusters only. The pinned release cannot adopt a cluster that already holds LINSTOR volumes safely, and nothing here converts LINSTOR's database, so both values files say so, and the platform refuses to change the backend of a live cozystack.linstor Package unless storage.acknowledgeBackendChange names the new one, the way the networking variant guard does. `make update-blockstor-crds` refreshes the CRDs from the blockstor tag the images are pinned to. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
05477de6f9 |
fix(postgres): rebuild indexes on C.UTF-8 when the Debian release changes
PostgreSQL records no collation version for a libc locale named C.<codeset>, so the collation repair never counted a column declared COLLATE "C.UTF-8", or a database created with LC_COLLATE 'C.UTF-8', as stale. Yet the C.UTF-8 Debian patched into the glibc of bullseye and the one glibc ships since 2.35 order characters differently. After the move to the standard-trixie images an index on such a column misses most of its keys and amcheck reports "item order invariant violated", on PostgreSQL 13 as on 17, and the pass said nothing on PostgreSQL 15 and later. Such a collation, and a database default of such a locale, now take the Debian release of the server's build (the pgdg suffix of server_version) as their version, so their indexes go through the same resumable rebuild as any other stale collation. PostgreSQL keeps nothing to compare that release with, so the pass records the release each database was repaired for in the cozystack.collation_release setting, once the database is repaired without a failure. A database without the setting gets the release of the server the pass first finds it on. The pass looks before it waits for the rollout, so the old release is recorded even when that run then fails, and a retry after the primary has restarted still rebuilds. A database first seen when the server already runs the new glibc is recognised by a libc collation, or a libc database default, whose recorded version differs from the server's. Anything else, a new cluster included, is recorded as repaired for the release it runs and nothing is rebuilt. That includes a database an earlier pass already repaired on the new glibc: it refreshed the libc versions and left no sign of the move, so its indexes on C.* collations need a REINDEX by hand. Before PostgreSQL 15 the pass warned that a C.<codeset> database default could not be checked; it is repaired now, so the warning no longer fires for it. A range partition key on such a collation is reported once, by the run that rebuilds its indexes, since PostgreSQL logs no version mismatch for it later. Refs: #5459 Fixes: |
||
|
|
60cf13dbc4 |
fix(ci): build a stacked PR's images from its line's fork point (#5463)
## What this PR does A pull request stacked on another feature branch builds its images from its own diff against that branch, so one that changes only tests builds no images. The overlay then fills every package from main's or a release line's artifact, which has none of the stack's changes, and the stack's charts run on images that do not match them. In one stacked run cozystack-controller crash-looped on `flag provided but not defined: -enable-gpu`. With this change the build list of such a pull request comes from the fork point with the line whose artifact the overlay reads, so the images of the pull requests below it are built too. On main and the release lines nothing changes. When the fork point cannot be found, CI warns, builds every image, Talos included, and keeps the committed refs out of the overlay. #4460 already fixed the overlay tag for a feature-branch base; this is the build list beside it. #4911 applies the same fork-point rule to the Kairos worker disks only; this PR covers every image. The new hack/pr-changed-paths_test.bats and the existing overlay tests pass locally under Bats. I have not seen a stacked pull request run through this workflow yet. Closes #5444 ### 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 fix(ci): build a stacked pull request's images from the fork point of the line its base belongs to, so a stack that changes only tests no longer runs e2e on main's images. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Build & Validation** * Pull request checks now account for renamed files when determining which builds and tests to run. * If changed-file detection fails, validation falls back to the full build matrix, gated tests, Talos builds, and package coverage. * Base-package overlays now select artifact references based on branch context, supporting stacked pull requests and release branches. * **Tests** * Added coverage for changed-file detection, rename handling, branch scenarios, and fallback validation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
e89821ca2e |
ci(release): refuse a Promote RC dispatch from any ref but main
A workflow_dispatch runs the copy of promote-rc.yaml at the ref it was dispatched from. On 2026-10-16 a dispatch from release-1.6 ran that branch's older copy, one job instead of five, and had to be re-run from main. Since the release assets are signed, the same dispatch would now fail at the upload step, after the staging branch, the promotion-* candidate and the draft release already exist, and docs/release/signatures-and-sbom.md pins the signature identity to this workflow on main. Make the first step of parse compare github.ref with refs/heads/main and fail with an error that names main, so a dispatch from a release branch, a tag or a SHA stops before the first write. The bats test runs the step's shell under dash for main, a release branch, a tag and an empty ref, and pins the step to be the first one in parse. The release docs tell the operator to dispatch from main and state that only a copy carrying the check refuses other refs: older release-X.Y copies stay callable and still write before stopping. Assisted-by: LLM Signed-off-by: Marian Koreniuk <moriarti@cp.if.ua> |
||
|
|
9314becb72 |
fix(ci): push the stable chart once, so a re-run keeps cozy-installer:X.Y.Z (#5486)
## What this PR does Since #5169 finalize publishes the release page last, so a run that fails in `Publish draft release` gets re-run after the chart is already pushed. The re-run packaged and pushed the chart again, and `helm package` doesn't give the same bytes twice (I packaged the same tree twice with different file times and got two digests), so `cozy-installer:X.Y.Z` moved to another digest. Now the chart step pushes only when `cozy-installer:X.Y.Z` is not in the registry yet. `cozy-installer:latest` still follows the latest decision on every run. The test runs the step against stub skopeo, helm and yq: first run pushes once, re-run pushes nothing, older patch leaves latest alone, failed push fails the step. Lines get this in own PRs: #5487 (release-1.7) and #5488 (release-1.6). ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(ci): a re-run of finalize no longer pushes the stable cozy-installer chart again, so cozy-installer:X.Y.Z keeps the digest of its first push ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Chores** * Stable installer chart versions are preserved once published. Re-running a release will not replace an existing version; correcting a published chart requires removing it from the registry before rerunning. * If a version is missing, the release can publish it. Registry lookup or publishing errors stop the release. When configured, the `latest` tag is updated even if the versioned chart already exists. * **Documentation** * Clarified the policy for publishing stable chart versions and handling existing charts. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
e99a15dbee |
fix(ci): push the stable chart once, so a re-run keeps cozy-installer:X.Y.Z
Since finalize publishes the release page last, a run that fails in
Publish draft release is re-run after the chart is already pushed. The
re-run packaged and pushed the chart again, and helm package does not
give the same bytes twice (two packagings of the same tree with
different file times give two digests), so cozy-installer:X.Y.Z moved
to another digest.
The chart step now pushes only when the registry answers that cozy-
installer:X.Y.Z is missing, read as manifest_digest in hack/promote-
retag.sh reads it; any other lookup error fails the step instead of
being taken for a missing tag. cozy-installer:latest still follows the
latest decision on every run.
A bats test runs the step against stub skopeo, helm and yq: the first
run pushes once, a re-run pushes nothing, an older patch leaves latest
alone, a failed push fails the step, and a failed lookup fails it
without packaging or pushing.
Fixes:
|
||
|
|
ed22d251c8 |
feat(api): add EndpointAttachment to attach addresses to app endpoints (#4324)
## What this PR does Implements `EndpointAttachment` (`local.sdn.cozystack.io/v1alpha1`, namespaced) from the design proposal in [cozystack/community#45](https://github.com/cozystack/community/pull/45): a tenant-created resource that attaches one external address to one tenant-facing Service of one managed application. It is the Network load-balancing path (a dedicated address per attachment), complementary to SNI exposure through the tenant Gateway, and it implements the `loadBalancer` union member only. Nothing in it routes by hostname, touches TLS, or reads chart values. Two commits. The first updates address-controller and metallb-iad to v0.3.0: the class's provisioner now reports, in `IPAddressClass.status.loadBalancerClass` with an `Accepted` condition for the class's generation, the `loadBalancerClass` a Service consuming its claims must carry, and the MetalLB driver writes that status. The second adds `EndpointAttachment`, which sets that class on every Service and FloatingIP it renders and renders nothing new until the class is accepted (`ClassNotAccepted`); a Service or FloatingIP already published is kept if the class later loses acceptance. The FloatingIP retarget check needs cozyplane v0.1.5 or later, which stamps `metadata.generation` and `status.observedGeneration`. [#5389](https://github.com/cozystack/cozystack/pull/5389) moves the cozyplane pin to v0.1.5, and this PR merges after it; on an older cozyplane both fields read 0 and the check passes as before. **API** (`api/localsdn/v1alpha1/endpointattachment_types.go`, CRD generated into the cozystack-controller chart). The kind lives in `local.sdn.cozystack.io`, the CRD-served half of the sdn family the address substrate and cozyplane already share, so stock `ResourceQuota` counts still work. `spec` is required at the resource root, since removing it would otherwise skip every rule nested inside it. `spec.applicationRef` (group/kind/name, group defaulting to `apps.cozystack.io`), `spec.endpoint.serviceName`, and `spec.loadBalancer` with `className` | `claimName` (exclusive), `family`, `ports`, `method` (`WholeIP` | `PortList`), `allowICMP`. CEL freezes the address-identity fields (`applicationRef`, `className`, `claimName`, `family`) and the member selection, requires exactly one union member (written as a list so a `gateway` member can be added without restructuring), and holds the static shape rules (`PortList` needs `ports`, `allowICMP` is `PortList`-only). Everything cross-object or dynamic is a condition. `status.phase` is a projection of the `Resolved` and `Provisioned` conditions. **Controller** (`internal/controller/endpointattachment`), one reconcile in four steps: 1. Resolve. The application's HelmRelease is found by the three lineage labels; the attachment gets a non-controller owner reference to it by UID and the lineage labels stamped on itself. The endpoint Service must carry the lineage triple matching `applicationRef` and `internal.cozystack.io/tenantresource: "true"`; lineage alone is refused (`EndpointLineageMismatch` / `EndpointNotTenantFacing`), as is a Service rendered by another attachment, and a LoadBalancer Service a tenant Kubernetes cluster's cloud-controller-manager creates for a Service inside that cluster: it carries the cluster's lineage and the marker, and is told apart by the `cluster.x-k8s.io/tenant-service-name` label that controller writes. A same-name recreated application (different HelmRelease UID) is reported as `ApplicationIncarnationChanged`, the Service is withdrawn, and the owner reference is never rewritten. 2. Claim. `claimName` references an existing `IPAddressClaim` and writes nothing to it; otherwise a claim is minted with `generateName` under the attachment's controller reference. The substrate kinds are read as unstructured, so the controller carries no module or CRD dependency on it and reports `ClaimPending` where it is not installed. `loadBalancerClass` is read from the claim's resolved `IPAddressClass` status before the Service is created, only once the class's `Accepted` condition is True for its current generation, and left empty when the class reports the cluster default. The Service's `ipFamilyPolicy` and `ipFamilies` follow the claim's family (`SingleStack` for IPv4 or IPv6, `RequireDualStack` for Dual) and are reconciled on existing Services; a primary family that differs, which the apiserver never changes, and a create the cluster refuses are both reported as `RenderFailed`. An address whose `IPAddress.status.associatedTo` names another live Service gives `ClaimInUse` and withdraws this attachment's own Service, so two attachments that both rendered before either association was recorded leave one Service asking for the claim. A `family` conflicting with a referenced claim gives `FamilyConflict`. 3. Render. One `type: LoadBalancer` Service via `generateName` (a prefix derived from the attachment name and bounded to what the apiserver accepts for a Service, which also bounds the minted claim's), identified by controller owner reference only (a Service with the ownership label and no reference is ignored, never adopted). It mirrors the endpoint's selector and ports (or the `ports` subset; synthesized ports when the endpoint has only the sentinel port), carries the `local.sdn.cozystack.io/ip-address-claim` annotation, `externalTrafficPolicy: Local`, and `allocateLoadBalancerNodePorts: false` unless the platform says otherwise. It copies no labels or annotations from the endpoint. An endpoint with no selector (hand-managed endpoints) is refused with `NothingToPublish`, and the VM placeholder is recognised by its shape (headless, only port 65535) rather than by the port alone. When the cache shows no owned Service, the controller rechecks through the API reader before creating one, and collapses duplicates to the oldest. Re-mirroring is event-driven through watches on Services, EndpointSlices, HelmReleases and, where served at startup, the claim kind. 4. Report. `status.addresses` mirrors the claim's bound addresses (a list), `status.serviceName` and `status.claimName` name the objects, and `Provisioned=True` asserts address and Service wiring only; its message says so, since reachability additionally depends on the CNI's policy objects. **VM datapath modes.** `method` renders the cozy-proxy Service contract exactly (the `service.kubernetes.io/service-proxy-name: cozy-proxy` label, `networking.cozystack.io/wholeIP`, `networking.cozystack.io/allowICMP`, the sentinel port for whole-IP without ports) and adds nothing beside it. Rendering is gated on a platform declaration, not CNI detection: the controller flag `--cozy-proxy-contract-implemented` is threaded from the system bundle, which sets it exactly when it emits the cozy-proxy Package; without it a method-bearing attachment renders no Service and reports `DatapathContractUnavailable`, because a load balancer would still attract the address while every proxy skipped the Service. Exclusivity is keyed on the backend pod and counts every delegated Service in either mode (attachments, chart Services rendered with `external: true`, hand-made ones): a delegation no attachment renders (a chart Service with `external: true`, or a hand-made one) always wins, since nothing would ever withdraw it; between attachments the oldest wins, ties by name. The loser reports `BackendAlreadyDelegated` and renders nothing rather than fighting for the slot. cozy-proxy v0.4.0 programs IPv4 only (one IPv4 nftables table, every address through `To4()`), so a method attachment off a VPC with an `IPv6` or `Dual` claim renders no Service and reports `FamilyUnsupportedByDatapath`; the cozyplane path still serves IPv6 through the FloatingIP. `WholeIP` on an endpoint with more than one ready backend keeps its Service and claim but selects nothing (`MultipleBackends`), so a rolling update or live migration passes through held-but-dark and recovers without churning the address. **VMs in a VPC.** On a cozyplane VPC the VM's only interface is in the VPC, so the launcher pod address a cozy-proxy Service maps to never reaches it. When a backend pod carries the VM chart's `sdn.cozystack.io/vpc` annotation and the cluster serves cozyplane's `FloatingIP`, a `WholeIP` attachment owns a FloatingIP in its namespace (`vpcRef` from the annotation, `target` from the `sdn.cozystack.io/vpc-ip` address cozyplane's CNI stamps, `addressClaimName` the attachment's claim) instead of a Service, and `Provisioned` mirrors the FloatingIP's readiness. FloatingIP is read as unstructured and only where served, so there is no dependency on the cozyplane PR. Refusals there: `PortList` (`MethodUnsupportedInVPC`), a `Dual` claim, since a FloatingIP wears one address (`DualStackUnsupportedInVPC`), a VPC in another namespace (`VPCNotInNamespace`), several distinct VPC addresses or a mix of VPC and non-VPC pods (`MultipleBackends`, claim held), no VPC address stamped yet (`WaitingForVPCAddress`), and a VPC backend where FloatingIP is not served (`DatapathContractUnavailable`, no Service). A live migration's two launcher pods share the VPC address and stay one binding; a stopped VM keeps its FloatingIP. Since only a backend pod says whether a VM is in a VPC, a `method` attachment that has published nothing yet waits for one (`WaitingForBackend`), so an attachment created before its VM starts never pins the claim to a cozy-proxy Service first. On the kube-ovn VPC the VM keeps its pod-network interface and joins VPC subnets through extra interfaces, so the cozy-proxy path is unchanged there. **Detach semantics.** An endpoint Service that disappears withdraws the rendered Service, keeps the claim (minted or referenced), and reports `Detached`; the same claim is reused when the endpoint returns. Deleting an attachment collects its Service and its minted claim; a referenced claim is untouched. **Wiring.** The controller is registered in `cmd/cozystack-controller` behind two flags (`--cozy-proxy-contract-implemented`, `--endpoint-attachment-allocate-node-ports`), the chart exposes them as `cozystackController.endpointAttachments.*`, the platform system bundle derives both (cozy-proxy emitted, Hetzner RobotLB enabled), the controller ClusterRole gains Service writes, the `endpointattachments` kind, `ipaddressclaims` create/delete and `sdn.cozystack.io` `floatingips` writes, and the tenant ClusterRoles get `endpointattachments` beside `securitygroups` (full in `cozy:tenant:base`, read in `cozy:tenant:view:base`, write in `cozy:tenant:admin:base`). **Tests.** `crdcel_test.go` compiles the shipped CRD and pins the create and update admission matrix. `reconciler_test.go` (fake client) covers the resolve/deny matrix over both label families, mirroring and port subsetting, the minted-claim path, the two proof sequences (a labelled-but-unowned Service is ignored and a same-name recreated application is not re-acquired; a reserved claim holds across detachment and moves to a different application), detach/reattach, the sentinel-port rule, the capability gate, both modes, held-but-dark on multiple backends, pod-keyed exclusivity, the substrate-absent path and the family conflict. Admission tests also validate from the resource root (removing or restoring `spec`). The reconciler tests cover a Dual claim that is provisioned only once the Service carries both addresses, and attachment names up to 253 characters, with dots or a leading digit, on both address-selection paths. `floatingip_test.go` covers the cozyplane path: the FloatingIP's spec and readiness mirroring, the claim worn by its own Service not counting as in use, switching from and back to a cozy-proxy Service, a kube-ovn-shaped backend keeping the Service, each refusal, live migration, a stopped VM, re-pointing in place, detach and name bounds. Chart unit tests pin the platform declaration on every bundle variant, slim opt-in included, and the FloatingIP RBAC rule. `hack/e2e-chainsaw/endpointattachment` carries the postgres hold/move sequence, GC, the lineage refusal of an attachment pointing at another application's Service, and the VM mode Test (re-scoped to a single delegated Service per VM, since current cozy-proxy's rule installer keeps one 1:1 slot per pod). It is registered: `hack/select-install.sh` maps it to `cozystack.address-controller` and `cozystack.metallb-iad`, with Postgres, VMInstance, VMDisk and cozy-proxy as its runtime requirements, and `hack/select-e2e.sh` maps both substrate packages back to it, since no other suite installs them. The e2e install enables both packages, and `hack/e2e-post-install-prep.sh` creates the default `IPAddressClass` on a dedicated, non-auto-assigning MetalLB pool whenever metallb-iad is installed. `hack/e2e-chainsaw/endpointattachment-vpc` covers the cozyplane FloatingIP path (whole-IP published through a FloatingIP, `PortList` and `Dual` refused) and stays parked as `chainsaw-test.yaml.disabled`, because no e2e lane installs the cozyplane networking variant. **Upgrade.** Additive: a new CRD, a new reconciler, new RBAC rules, no migration. The system bundle now always passes the cozystack-controller component an `endpointAttachments` values block, so the first upgrade rolls the controller once with the new flags; the flags change nothing until `EndpointAttachment` objects exist, and no existing object is modified. **Docs.** The user guide is on the website, in [cozystack/website#825](https://github.com/cozystack/website/pull/825): the resource, which Services can be attached, the lifecycle, the conditions' exact meaning, the VM modes and the cozyplane path, and the TLS posture (attaching a database does not turn its TLS on). It is a cross-package guide, so under the documentation placement rules it lives there rather than in `docs/`. **Not in this PR, deliberately.** The `gateway` union member (a reserved name; the CRD ships without it and nothing references it). A certSAN write-back for the managed Kubernetes API. Discovery-engine address write-back. The address-preserving migration from `external: true`. An authoritative exclusivity gate inside cozy-proxy (the attachment-side refusal is advisory); that wants an issue in cozystack/cozy-proxy. ### Screenshots Not a UI change. ### Downstream repositories `ApplicationDefinition.spec.services` now also decides which Services tenants can attach an address to, which the trigger map routes to the website's ApplicationDefinition page: [cozystack/website#825](https://github.com/cozystack/website/pull/825) documents that, and carries the user guide. Nothing else matched: the cozy-proxy runtime contract is consumed with the same three literal strings and nothing is renamed; the new CRD travels as opaque JSON in the terraform provider; no platform `values.yaml` key, variant, asset or node prerequisite changed. An issue in cozy-proxy for an authoritative one-delegation-per-pod gate is worth a human decision rather than a speculative filing. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: https://github.com/cozystack/website/pull/825 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(api): add EndpointAttachment (local.sdn.cozystack.io/v1alpha1), a tenant resource that attaches an external address, minted from an IPAddressClass or bound from a reserved IPAddressClaim, to one tenant-facing Service of a managed application by rendering an additive LoadBalancer Service that mirrors it; VM whole-IP and port-list modes render the cozy-proxy contract where the platform deploys it. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added endpoint attachments to publish eligible application and VM endpoints through dedicated load balancer addresses, with whole-IP or selected-port exposure and IPv4, IPv6, or dual-stack support. * Attachments can use a reserved address or request one through a configured address class. Status shows endpoint resolution, provisioning, assigned addresses, and attachment state. * Tenant access now includes managing and inspecting endpoint attachments. Whole-IP VM exposure is limited to one delegated backend, and VPC support depends on the available network datapath. * **Documentation** * Added guidance on eligible endpoints, address lifecycle, status, and exposure considerations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
8641ebbf63 |
fix(ci): publish the release only after the stable images and chart exist (#5169)
## What this PR does Finalize undrafted the release before retagging the rc images and pushing the cozy-installer chart, so release page announced version whose images and chart still returned `manifest unknown` (7m47s on v1.7.0: https://github.com/cozystack/cozystack/actions/runs/40864518300). Failed retag or chart push also left public release that re-run couldn't repair, because re-run looks for draft and finds none. Now draft lookup and `make_latest` decision are in own step `Resolve draft release`, before any registry write. Retag, chart and `Publish draft release` take the decision from its outputs, and publish goes last. Missing draft fails before anything is pushed, failed retag or chart leaves the draft for re-run. Body selection, orphaned draft repair, `prerelease` and restoring `latest` after older patch are unchanged. Deciding `latest` before the retag opens a window of minutes where two release PRs merged close together both decide they are newest, and the older line ends up with `latest` on release page, image `:latest` and `cozy-installer:latest`. So finalize runs one release at a time: job-level concurrency group built from the job's own `if:` (other closed PRs never join it), `cancel-in-progress: false` and `queue: max`, so third merged release waits instead of cancelling the pending one. Docs and comments in `tags.yaml` and `promote-rc.yaml` that said release is already public when finalize pushes the stable tag now say when it is published. Release checklist no longer says to undraft by hand when draft lookup fails. Closed-PR workflow runs from base branch, so supported lines get this in own PRs: #5480 (release-1.7) and #5481 (release-1.6). Tests: contract tests pin step order, that nothing publishes after failed registry step (no `continue-on-error`, no `if:` on publish, registry steps skip only for prerelease) and the concurrency group. Behaviour tests run both github-script steps under node against stubbed API (missing draft, orphaned draft, older patch after newer minor, all shipped changelog tags). Every new test fails against the old workflow, I also checked them against mutated copies of it. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(ci): finalize publishes the release page last, after the stable image tags and the cozy-installer chart exist, and finalizes one release at a time, so a release is no longer public while its images return manifest unknown ``` |
||
|
|
e1472e58de |
fix(ci): publish the release only after the stable images and chart exist
Finalize undrafted the release before it retagged the images and published the cozy-installer chart, so for the length of the retag the release page announced a version whose images and chart returned manifest unknown. The retag took 80-95 seconds on the 1.6.x patches and several minutes on v1.7.0. A failure in either step also left a public release that a re-run could not repair, because the re-run looked for a draft and found none. Move the draft lookup and the latest decision into their own step that runs before any registry write, hand the decision to the retag, the chart and the release page as step outputs, and undraft last. A missing draft now fails while no stable name exists, and a failed retag leaves the draft in place for a re-run. The comments and docs that took the release to be public by the time finalize pushes the stable tag now say when it is published. Deciding latest before the retag opens minutes in which two release PRs merged close together would both decide they are the newest, leaving latest on the older line on the page, the image aliases and the chart. Finalize therefore runs one release at a time, in a concurrency group that only release PRs join and that queues every merged release rather than cancelling the one waiting. The finalize bats suites run both github-script steps under node against a stubbed API: a missing draft, an orphaned draft, an older patch after a newer minor, and every shipped changelog's tag. A contract test fails on a registry step allowed to fail, a publish step that runs after a failure, a `latest` that moves without the decision, or finalize runs that may overlap. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> |
||
|
|
fc2da5810f |
Merge commit from fork
fix(monitoring): give Alerta a real signing key and its own admin password |
||
|
|
9f00135618 |
feat(api): add EndpointAttachment to attach addresses to app endpoints
A managed application's tenant-facing Services are its endpoints, and the only way to publish one externally has been the chart boolean `external`, which publishes one chart-chosen endpoint on one address from no particular pool through five different render paths. EndpointAttachment attaches one address, minted from an IPAddressClass or bound from a reserved IPAddressClaim, to one tenant-facing Service by rendering an additive LoadBalancer Service that mirrors the endpoint's selector and ports. The mechanism therefore needs no per-engine render knowledge and never touches the application's own objects, and a reserved address survives every attachment and moves between applications. The Service carries the loadBalancerClass the claim's class reports in status, so it reaches the load balancer that owns the class's pool; since a Service's loadBalancerClass is immutable, nothing new is rendered before the class's provisioner accepts the class for its current generation. The rendered Service asks for the claim's IP families, since one left to the cluster's primary family cannot be assigned an address of the other. The endpoint check requires both the lineage labels and the tenantresource marker: lineage alone also covers operator-internal Services. A LoadBalancer Service a tenant Kubernetes cluster's cloud-controller-manager creates carries the cluster's labels and the marker too, so the cluster.x-k8s.io/tenant-service-name label it writes excludes it. Identity is by owner reference throughout, so a Service carrying the ownership label without the reference is never adopted, and a same-name recreated application does not inherit the previous incarnation's attachments. The VM datapath modes render the cozy-proxy Service contract unchanged and are gated on a platform declaration rather than CNI detection: a proxy skips a Service delegated to a name it does not claim while the load balancer still attracts the address. Exclusivity is keyed on the backend pod in both modes because cozy-proxy's egress map holds one address per pod, and holds IPv4 only, so a method attachment off a VPC refuses an IPv6 or Dual claim. A delegation no attachment renders, such as a chart Service with external: true, always takes the pod, since nothing would ever withdraw it; between attachments the oldest wins. A whole-IP attachment with several ready backends keeps its address dark instead of picking one. A cozyplane VPC changes that for whole-IP: the VM's only interface is in the VPC, so the launcher pod address a cozy-proxy Service maps to never reaches it. Where a backend pod carries the VM chart's sdn.cozystack.io/vpc annotation and the cluster serves cozyplane's FloatingIP, the attachment owns a FloatingIP on the VM's VPC address wearing its claim instead, and mirrors its readiness once its status is for its current generation: a re-pointed FloatingIP keeps the old target's status until cozyplane observes the change. FloatingIP is read as unstructured and used only when served, so the controller keeps no dependency on cozyplane. A live migration's two launcher pods share the VM's VPC address and count as one target, and a stopped VM keeps its binding rather than flipping to a cozy-proxy Service. Only a backend pod says whether a VM is in a VPC, so a method attachment that has published nothing yet waits for one; otherwise an attachment created before its VM starts would pin the claim to a cozy-proxy Service first. PortList is refused there: a FloatingIP binds every port and cozy-proxy cannot reach the VPC address. So is a Dual claim, since a FloatingIP wears one address. The kube-ovn VPC keeps the pod-network interface and adds VPC subnets as secondary interfaces, so the cozy-proxy path still delivers to the VM there. The e2e suite is the only one that needs the address substrate, so it owns both of its optional packages in test selection: the e2e install enables them, a selection that leaves the suite out disables them, and post-install prep gives the sandbox a default IPAddressClass on a pool MetalLB does not auto-assign from. The cozyplane VPC suite stays parked, because no e2e lane installs that networking variant. The kind lives in local.sdn.cozystack.io, the CRD-served half of the sdn family the address substrate and cozyplane share, so stock ResourceQuota counts keep working. Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com> |
||
|
|
bcba5d349a |
security(monitoring): reset the Alerta admin password on every start
The entrypoint creates admin users only when they are missing, so an admin user created before Alerta had a password of its own keeps the Grafana password, which stays valid after an operator rotates Grafana's. The respin runs a step right after user creation that sets every admin user's password to ADMIN_PASSWORD, and stops the container if it fails. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
8942c7dfcc |
security(monitoring): keep Alerta credentials out of its container log
The upstream Alerta entrypoint prints the whole environment, including the admin password and API key, and echoes the admin API keys it creates, while nginx logs the request line where Alertmanager passes the key as a query parameter. Pod logs are readable at lower tenant tiers than the credentials themselves. The respin drops the environment dump, silences key creation and masks the api-key parameter in the access log. Each edit is checked during the build, so an upstream change to either file fails the image build rather than bringing the output back. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
9af6594342 |
fix(apps): stop granting tenants core Secrets through dashboard resource maps (#5410)
## What this PR does Every app chart renders a `<release>-dashboard-resources` Role bound to the tenant's use, admin and super-admin groups and to the tenant ServiceAccounts. These started as the kubeapps resource map and became real grants in #1067. The console moved to `tenantsecrets`, but the bindings stayed. So a tenant subject can read the named Secrets straight from the API server and skip the `-rd` allowlist. For a bucket with no users, which is the default, `resourceNames` renders empty and the Role grants every Secret in the namespace. I checked that on a live cluster: the rendered Role lets a `use` subject get and list all Secrets in the tenant namespace. Closes #3613. Nothing reads these Roles any more. Services, ingresses and workloadmonitors are already granted namespace-wide by the `cozy:tenant` ClusterRoles, and every Secret tenants need is in the kind's `secrets.include`, served through `tenantsecrets`. - Remove the Roles and RoleBindings from every chart under `packages/apps` and `packages/extra`, except foundationdb. The qdrant and vm-instance WorkloadMonitors that lived in the same file move to `workloadmonitor.yaml`. computeplane keeps `withholdAdminKubeconfig` for one more release: the new kubernetes chart ignores it, but it covers the window in which the old chart is still served. - Keep the foundationdb resource map and its Role, with a TODO to remove them once Cozystack can serve application ConfigMaps to tenants. They are the only way a tenant reads `<release>-config`, the ConfigMap with the cluster file, and they grant ConfigMaps only, no Secrets. The map now lists only that ConfigMap, the one entry the console's ConfigMaps tab reads, and the foundationdb README says how to read the cluster file. - Point the postgres, mariadb, mongodb and kubernetes docs at `kubectl get tenantsecret`, as redis and rabbitmq already do. - Add `hack/check-tenant-secret-grants.bats`. It renders every chart and fails if any binds a tenant subject to a Role that grants core Secrets. On current main it flags 18 charts, bucket included. One deliberate loss: with OIDC, the `view` tier no longer reads the `kubeconfig-<namespace>` Secret of the info module. The old Role granted it from `view` up, while `tenantsecrets` is granted from `use` up, and giving `view` `tenantsecrets` would show it every tenant credential. The kubeconfig holds no credential (the API address, the public CA and an `oidc-login` call), so `view` users can build it from the docs until `tenantsecrets` can serve such Secrets to `view`. No objects carry `helm.sh/resource-policy: keep`, so Helm deletes them on upgrade and no migration is needed. ### Screenshots N/A, no UI changes. ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: needed, pages that tell tenants to `kubectl get secret` for app credentials or kubeconfigs should say `tenantsecret` - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: needs a check, any data source that reads app Secrets with a tenant identity - [ ] [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(apps): Tenants no longer get direct read access to application Secrets through the per-application dashboard Roles. Those Roles are removed; read credentials with `kubectl get tenantsecret` instead of `kubectl get secret`. This closes a case where a bucket without users let tenant members read every Secret in the namespace. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Updates** * Kubernetes credential retrieval instructions now use `tenantsecret` resources. * **New Features** * Added workload monitoring resources for Qdrant and virtual machine instances. * **Removed** * The application details page no longer includes a ConfigMaps tab. * Dashboard access to selected application and infrastructure resources is no longer provided through chart-defined permissions. * FoundationDB dashboard resource-map checks are no longer part of the end-to-end test. * **Tests** * Added checks to detect tenant access grants to Kubernetes Secrets across rendered charts. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
6aa33e379e |
feat(monitoring): alert when a namespace stays in Terminating (#5040)
## What this PR does On a cluster running v1.6.5 a tenant namespace that was deleted directly, not through the Tenant app, stayed in `Terminating` for about 28 hours, held by the Kamaji finalizers described in #5002. Nothing alerted on the namespace itself. The only signal was `HelmReleaseNotReady` of the tenant release, which kept flapping. kube-state-metrics already exports `kube_namespace_status_phase` and `dashboards/main/capacity-planning.json` reads it, but no alert rule in the repo does. This adds `KubeNamespaceStuckTerminating`, a warning in a new `namespace-deletion` group under `packages/system/monitoring-agents/alerts/`. It fires when `max by (cluster, namespace) (kube_namespace_status_phase{job="kube-state-metrics", phase="Terminating"}) == 1` has held for 30 minutes. kube-state-metrics exports a `Terminating` series for every namespace, 0 while the namespace is active and 1 while it is being deleted ([namespace.go#L109-L135](https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/internal/store/namespace.go#L109-L135)). The scrape adds the node and pod of the kube-state-metrics pod as target labels, so the rule groups by cluster and namespace and its timer keeps running through a kube-state-metrics rollout to another node. A gap in the series, for example while kube-state-metrics is down, starts the 30 minutes over. The description names the namespace and the cluster and points at the namespace status conditions, which list the remaining resource types and finalizers ([status_condition_utils.go#L101-L140](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/namespace/deletion/status_condition_utils.go#L101-L140)). Why 30 minutes. Healthy tenant deletions we watched on current versions took under a minute from the delete request until the namespace was gone, 61 of 61, and about 5 minutes for a tenant with a Kubernetes cluster, a VM and Postgres inside. The namespace itself spent under a minute in `Terminating` in every one of them. 30 minutes leaves wide room and still reports a stuck namespace within the hour. `hack/namespace-deletion-alerts.bats` replays `.spec` of the VMRule through `vmalert-tool` v1.136.0 pinned by digest, the same harness as #4963, #4985 and #4993. `hack/testdata/namespace-deletion-alerts/unittest.yaml` has 5 cases with 11 checks. A namespace in `Terminating` is quiet at 29 minutes and fires at 35, with labels and annotations pinned. A namespace deleted after 20 minutes in `Terminating` stays quiet at 19, 35 and 60 minutes, and an active namespace stays quiet. When kube-state-metrics moves to another node 15 minutes in, the alert still fires at 31 minutes. The same namespace name in two clusters gives one alert per cluster, each with its own timer. ```console $ bats hack/namespace-deletion-alerts.bats 1..1 ok 1 namespace deletion alerts pass their vmalert-tool cases ``` With the expression replaced by `vector(1) == 0` the suite prints `not ok 1` and vmalert-tool fails the 4 checks that expect an alert. On main, where the rule file does not exist, the suite fails too. Each of the following rule changes fails at least one check. They are `for: 15m`, `for: 45m`, no `== 1`, `sum by` instead of `max by`, which only the kube-state-metrics move catches, no `cluster` in the grouping, `phase="Active"`, no aggregation, another severity and another description. With Bats 1.14.0 at the commit CI pins and Helm 3.17.3 on `PATH`, 18 suites pass with 325 of 325 tests, the new one together with `alert-severity-contract`, `bats-strict-setup`, `bats-runner-coverage`, `bats-runner-contract`, `unit-test-parallelism`, `image-pin-consistency` and `check-commit-trailers` among others. The severity contract lists the new alert as `warning`. helm-unittest 1.1.2 passes the monitoring-agents chart with 19 of 19 tests, and `helm template` renders the VMRule the same as the file. Like the migration suites, the new suite needs docker. I have not run the rule in vmalert on a live cluster. The release-1.6 backport is a separate PR with one more commit that drops the `load test_helper` line, because release-1.6 runs `hack/*.bats` through `hack/cozytest.sh`. ### Screenshots Not a UI change. ### Downstream repositories A new alert file under `packages/system/monitoring-agents/alerts/`, a Bats suite under `hack/` and its test data. No values, schema, README, image or `ApplicationDefinition` change, and the website does not list platform alerts by name, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(monitoring): new warning alert KubeNamespaceStuckTerminating fires when a namespace has been in phase Terminating for more than 30 minutes. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **New Features** - Added an alert for Kubernetes namespaces that remain in the `Terminating` phase for more than 30 minutes. - Alerts identify the affected cluster and namespace and note that remaining finalizers may be preventing deletion. - **Tests** - Added coverage for deletion timing, active namespaces, node changes during termination, and identically named namespaces across clusters. Test cases verify expected alert labels and annotations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
da8d8e69bb |
fix(ci): build a stacked PR's images from its line's fork point
A pull request whose base is another feature branch listed its changes against that base, so one that changed only tests built no images. The overlay then filled every package from main's or a release line's artifact, which has none of the stack's changes, and the stack's charts ran on images that did not match them: in one stacked run cozystack-controller crash-looped on "flag provided but not defined: -enable-gpu". The overlay's choice of artifact moves into hack/pr-artifact-ref.sh, unchanged. The plan step now takes its path lists from hack/pr-changed-paths.sh, which uses the same choice: on main and the release lines, which read their own artifact, it is the pull request's own diff as before; on any other base it is the diff from the fork point with the line whose artifact the base reads, so the images of the pull requests below are built too, and a stack on a release line does not rebuild everything for the line's own commits. When the fork point cannot be found nothing may trust the lists: the step warns, builds every image, Talos included, runs the backport-batch tests and keeps every package's committed refs out of the overlay. Closes: #5444 Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
6ed0541eb2 |
fix(apps): stop granting tenants core Secrets through dashboard resource maps
Every app chart rendered a <release>-dashboard-resources Role and a RoleBinding to the tenant's groups and ServiceAccounts. The Roles began in 2024 as a resource map that the kubeapps dashboard read to list an application's objects, and had no bindings. When the tenant roles lost the core wildcard, the maps were bound so kubeapps kept working, and they became real grants. The console that replaced kubeapps reads Secrets through core.cozystack.io/tenantsecrets, which cozystack-api serves with its own identity and only for what the ApplicationDefinition admits, yet the bindings stayed. So any tenant subject at the bound level could read the named Secrets directly through the API server, bypassing the -rd allowlist: database credentials, the kubernetes admin kubeconfig, Grafana's admin password. A bucket with no users rendered an empty resourceNames list, which RBAC reads as every Secret in the namespace. Nothing reads these Roles' Secret rules any more. Services, ingresses and workloadmonitors are already granted namespace-wide by the cozy:tenant ClusterRoles, and the Secrets tenants need are all in secrets.include. Remove the Roles and RoleBindings from every chart except foundationdb. The qdrant and vm-instance WorkloadMonitors that shared the file move to workloadmonitor.yaml. foundationdb keeps its resource map and Role: they are the only way a tenant reads <release>-config, the ConfigMap with the cluster file, since no cozy:tenant role grants ConfigMaps and tenantsecrets serves only Secrets. They grant ConfigMaps and no Secrets, and the map now lists only that ConfigMap, the one entry the console reads. They go once Cozystack can serve application ConfigMaps to tenants. The new kubernetes chart ignores computeplane's withholdAdminKubeconfig pin, but it stays for one more release: until the ExternalArtifact catches up, the previous kubernetes chart would otherwise render its admin kubeconfig rule again. None of these objects carries helm.sh/resource-policy: keep, so Helm deletes them on upgrade and no migration is needed. A new bats check renders every chart under packages/apps and packages/extra and fails if any binds a tenant subject to a Role that grants core Secrets. The suites and e2e steps that pinned the Roles' rules are removed with them. The charts that needed cluster state only to render the Roles now render offline, so they leave the release-size check's NO_OFFLINE_RENDER list. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com> |
||
|
|
94c79925f8 |
feat(api): add the credentials API with mint and revoke subresources (#4921)
## What this PR does Tenants read application passwords from Secrets today, and a leaked password can't be taken back. This PR adds the platform side of the user secrets API design (cozystack/community#137, ADR 0002): a password comes out once from a mint, the next mint replaces it, and a revoke kills it. The engines are converted in the PRs stacked on top, starting with Postgres in #4922. How it works: - A kind's chart renders one `CredentialTemplate` (`cozystack.io/v1alpha1`) per account: the username, the stored format (`scram-sha-256`, `mysql-native`, `sha256` or `plaintext`), labels for the account Secret, and an optional `valuesPath` for an operator that reads no Secret. - cozystack-controller keeps the account Secret `<template>.account`. It seeds it on a release the API marked for seeding, adopts an unowned Secret with the same username, leaves a foreign one alone with a `SecretConflict` condition, and mirrors the record (origin, time, actor, history) into the template status. For a `valuesPath` template it maintains an optional `valuesFrom` entry on the release. - `core.cozystack.io/v1alpha1` serves `credentials` as a read-only view of the templates, plus `mint` and `revoke` subresources. A mint checks the caller's `resourceVersion` precondition against the mirrored status, builds the whole Secret and writes it in one request, or answers 409. It never reads the Secret back. One API request writes one object; the best-effort Event is the only extra write. - The Application API marks a new release for seeding, keeps the account `valuesFrom` entries when it rewrites a release, and refuses to delete a suspended release that still has accounts, since Flux would skip its uninstall. - The dashboard gets a Credentials tab on the application page. It lists accounts with origin and history; an administrator can mint or revoke, and a viewer sees no buttons. The application charts are untouched here: a kind starts using this only when its chart renders templates. The `CredentialFormat` webhooks that ADR 0002 describes are not in this PR, so `format.name` accepts only the four built-in names for now. ### Screenshots <img width="1440" height="900" alt="01-admin-tab" src="https://github.com/user-attachments/assets/8c48086c-8f6c-4908-82c1-40e9078afe57" /> <img width="1440" height="900" alt="02-mint-dialog" src="https://github.com/user-attachments/assets/802b2963-3f57-4c0b-ab84-f74bad28c343" /> <img width="1440" height="900" alt="03-mint-result" src="https://github.com/user-attachments/assets/0e9ae3cc-7a3c-4daf-9a09-d4abf53bf70b" /> <img width="1440" height="900" alt="04-viewer-tab" src="https://github.com/user-attachments/assets/10e940f2-4ceb-469d-a0f9-6c9d20a62919" /> ### Downstream repositories - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: needed, cozystack/website#753 should document the `Credential` mint/revoke flow and the dashboard tab - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: needed later, a way to mint from Terraform; nothing breaks in this PR alone - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: none, the design is cozystack/community#137 ### Release note ```release-note feat(api): Add the credentials API. Applications that support it expose their accounts as `credentials.core.cozystack.io`; an administrator mints a password once with the `mint` subresource, and `revoke` invalidates it without issuing a new one. The dashboard shows a Credentials tab for such applications. No application uses it in this release on its own; see the per-engine changes. ``` |
||
|
|
ef32ff8d71 |
fix(postgres): bound a backup whose cnpg Backup stalls in pending (#5320)
<!-- 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 Part of #5209. The other part, a Plan that does not start a run while its previous BackupJob is still running, follows in a separate PR. A Postgres BackupJob whose `cnpg.io/Backup` never left `pending` stayed `Running` with no bound. In CloudNativePG 1.30.0 a Backup is pending for one of two reasons: it is queued behind a started or running backup of the same Cluster (`waitIfOtherBackupsRunning`), which is healthy, or the instance to run it on cannot be found or is not ready (`startBackupManagedByInstance`), which lasts for as long as the Cluster is fenced. A restart on another instance goes through the second path too. The driver tells the two apart only by whether a backup of the Cluster is `started` or `running`; it does not model which pending Backup CloudNativePG lets through first. Each poll reads the Cluster's backups from the cache, and the job reads them again from the apiserver right before it gives up, since the cache can still show pending a backup that has just started. Behind a started or running backup the wait stays uncapped and the BackupJob says which backup it waits for. Otherwise the BackupJob records a `CNPGBackupStalled` condition, and once that has lasted the backup deadline (30 minutes, the same bound as the plugin rollout wait) the BackupJob fails with the cause, and its own `cnpg.io/Backup` is deleted so it does not run later with no Cozystack `Backup` recording it. The delete is conditional on the UID and resourceVersion the driver read, so a Backup CloudNativePG started in between is kept. The give-up is recorded before the delete, so a Backup found missing later fails the job only when the driver removed it; a Backup deleted by hand is replaced and its stall counts afresh. The stall also ends, and a later one counts afresh, as soon as the Backup moves to any other phase. The reason CloudNativePG gives (`BackupPending: Backup target pod not ready: ...`) exists only as an event on the Backup, so the condition and the failure message carry the newest Warning event recorded on the job's own Backup, or, when it carries none, on another pending backup of the same Cluster. The events are listed by the Backup's UID through the uncached reader, so the controller gains `list` on events and no watch; when the read fails, the message says so instead of omitting the reason. A job is no longer held on the plugin rollout another job started when the Cluster is fenced and every instance pod postdates that attach: a fenced Cluster is neither healthy nor ready until the fence is lifted, so waiting there would only delay the bound by up to the rollout deadline. An instance pod older than the attach still holds the job, so a Backup never starts on a pod without the plugin. The postgres e2e (`examples/backups/postgres/run-all.sh` step 26) fences the source Cluster, checks that a BackupJob reports the stall with the reason CloudNativePG recorded, which exercises the `involvedObject.uid` selector and the events grant against a real apiserver and replaces a helm-unittest that only matched the rendered rule, then lifts the fence and checks that the same job completes with the stall ended. Failing at the deadline is covered by the unit tests. Known limit, left as is: a backup of the Cluster in `finalizing` does not count as running, which only a hand-made `volumeSnapshot` Backup can reach, since platform flows create plugin backups only. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(postgres): a Postgres BackupJob whose cnpg.io/Backup stays pending because its target instance is not ready, for example while the Cluster is fenced, now fails after 30 minutes with the reason CloudNativePG gives, and the abandoned cnpg.io/Backup is removed. A Backup queued behind a running backup of the same Cluster is not affected. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Pending backups that stall for 30 minutes now fail with a recorded reason. Backups queued behind an executing backup, progressing, or finished are not incorrectly treated as stalled. * Backup handling accounts for concurrent progress, external deletion, and retries, and reports the newest available warning for a pending backup. * Fenced clusters now use instance-pod creation time when evaluating plugin rollout readiness. * **Tests** * Expanded coverage for stalled backups, warning reporting, queue handling, and fenced-cluster backup recovery. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
74e103d6f2 |
ci(workflows): run push and schedule workflows only in cozystack/cozystack (#5186)
## What this PR does GitHub runs no CI in a security advisory's temporary private fork, and merging from the advisory skips branch protection, so an embargoed fix currently reaches `main` with nothing having run on it. This PR prepares the repository for verifying such a fix in a separate private copy of the repository (an embargo mirror), and documents that process. - Every job of a workflow that a push or a schedule starts now runs only in `cozystack/cozystack`. A mirror receives all workflow files on each sync, and without the guard it would build, publish, prune and cut releases from that copy on every sync and cron tick. Workflows that also run on `pull_request` keep running on pull requests, which is what the mirror is for. Every job carries the guard rather than only the root jobs, because a job whose condition calls a status function such as `!cancelled()` runs even when the job it needs was skipped. - `hack/workflow-repo-guard.bats` holds every current and future push or schedule workflow to that guard, accepting it only as the leading conjunct so nothing ORed after it can reopen the job. - `docs/security/incident-response.md` describes the verification flow: sync the mirror on demand, open the fix PR inside it, record the green run in the advisory, then merge from the advisory. It also records why the mirror must not hold the public registry credentials: pull request CI pushes every image and the packages artifact (the full chart tree) to a registry that is anonymously readable, tag listing included, so a run there would publish the fix before the release. Behaviour in `cozystack/cozystack` is unchanged: the guard is true there, and each existing condition is kept intact inside the new conjunction. Contributor forks with Actions enabled stop running these workflows too. Out of scope, as a follow-up: letting pull request CI push to a private registry and pull from it in the E2E cluster, so the mirror can run the E2E suite and not only planning, pre-commit and the unit tests. Verification: - `hack/workflow-repo-guard.bats` was red before the workflow changes (30 unguarded jobs) and is green after; removing the guard from `tags.yaml` `rc-e2e`, dropping the pull request clause from `zizmor.yml`, or adding an unguarded scheduled workflow each turns it red. - Every changed workflow is identical to `main` once job `if` fields are removed (`yq 'del(.jobs[].if)'`). - `zizmor --offline` reports no findings; `actionlint` reports the same findings on the changed files as on `main`. - `hack/stitch-multiarch_test.bats` pinned the exact `if` of two `tags.yaml` jobs and is updated to the guarded form. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The trigger map entry that touches this diff is `cozystack/ccp` for `tags.yaml`: its `package-bump` skill describes the release pipeline of `cozystack/cozystack`, which this PR does not change. ### Release note ```release-note ci(workflows): push- and schedule-triggered workflows run only in cozystack/cozystack, so a private mirror used to verify embargoed security fixes does not build, publish or release from its copy. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **CI** * Scheduled, release, and maintenance workflows now run only in the canonical repository. Pull-request checks continue to run where configured. * Build, validation, and security workflows now follow repository-specific run conditions. * **Documentation** * Updated incident-response guidance with steps for verifying fixes in a private advisory mirror, including CI limitations, check requirements, and credential restrictions. * **Tests** * Added workflow checks to verify repository guards and event-specific conditions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
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 --> |
||
|
|
6d1eeba65b |
fix(postgres): bound a backup whose cnpg Backup stalls in pending
CloudNativePG keeps a Backup pending either behind a started or running backup of the same Cluster, which is healthy, or because the instance to run it on cannot be found or is not ready, which lasts as long as the Cluster is fenced. The BackupJob waited on both forever. The driver now tells the two apart by whether any backup of the Cluster is started or running. It does not model which pending Backup CloudNativePG lets through first. With none running, the job records a CNPGBackupStalled condition and fails once that has lasted the backup deadline. Before it gives up it reads the Cluster's backups again from the apiserver, since the cache can still show pending one that has just started. Its own Backup is deleted, conditionally on the version read so a Backup CloudNativePG has just started is kept, because otherwise it would run later with no Backup recording it. The give-up is persisted before the delete, so a Backup found missing afterwards fails the job only when the driver removed it; one deleted by hand is replaced and its stall counts afresh. The reason CloudNativePG gives exists only as an event on a Backup, so the driver reads the newest Warning on its own Backup, or on another pending backup of the Cluster when its own carries none, by UID and uncached, which needs list on events but no watch. A job is no longer held on the plugin rollout another job started when the Cluster is fenced and every instance pod postdates that attach: a fenced Cluster is neither healthy nor ready until the fence is lifted, so waiting on that would only delay the bound by up to the rollout deadline. The postgres e2e fences the source Cluster, checks that a BackupJob reports the stall with that reason, then lifts the fence and checks the same job completes with the stall ended. That exercises the events grant and the involvedObject.uid selector against a real apiserver. The step creates the BackupJob only once every instance pod has gone NotReady, since the fence takes effect asynchronously and CloudNativePG starts a Backup on a target that is still Ready. Assisted-by: LLM Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io> Signed-off-by: Andrey Kolkov <androndo@gmail.com> |