mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
f293d64e847e87f71be0f20ca56d22648c3c6231
4984
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f293d64e84 |
fix(kafka): delete the release's StrimziPodSets on uninstall
On a cluster upgraded from Strimzi 0.x, deleting a Kafka application leaves its brokers running. kube-controller-manager's garbage collector first saw the StrimziPodSets under v1beta2 and never updates that record, so once v1beta2 is no longer served it retries them forever instead of deleting them, until kube-controller-manager restarts (kubernetes/kubernetes#102641). The pre-delete hook now deletes the release's StrimziPodSets after its node pools, so uninstall no longer depends on garbage collection for the brokers. An absent CRD is not a failure; any other error fails the hook like the pool delete does, because Helm never runs it for the release again. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
a909b733ea |
chore(kafka, kafka-operator): drop the JVM sizing workaround
The workaround passed MaxRAM and ActiveProcessorCount to every Strimzi JVM because the JDK 17 in the 0.45 images could not see the container limits on kernels without CONFIG_MEMCG_V1 (JDK-8347811). The Strimzi 1.2.0 images ship JDK 21.0.12, which carries the fix. On such a kernel, with a 1Gi limit, Strimzi's heap probe in the Kafka image now estimates a 495M maximum heap, where the 0.45.1-rc1 image estimated 13.9G. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
641faa7fde |
build(kafka-operator): vendor Strimzi 1.2.0
Strimzi 0.45 is out of upstream support. Strimzi 1.x serves only the v1 API, so the release now replaces the CRDs on upgrade; helm-controller's default of skipping CRD upgrades would leave the v1beta2-only CRDs from the first install in place. Strimzi 1.x runs no ZooKeeper, so the ZooKeeper alert group goes too. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
3b65cebea3 |
feat(kafka)!: run on the Strimzi v1 API and Kafka 4.x
Strimzi 1.2 serves only the v1 API and runs Kafka 4.2 and 4.3. The node-pool hook no longer drives the ZooKeeper to KRaft migration or the drain that freed the shared "kafka" pool name: Strimzi 1.x has no ZooKeeper support, and the platform migration refuses to upgrade while a ZooKeeper cluster is left. A cluster migrated earlier keeps its "kafka" broker pool. Without the drain the hook takes seconds, so the seven-hour install timeout goes too. Kafka 4 rejects the topic configs it removed and a segment.bytes below 1 MiB, which Kafka 3.x accepted. A KafkaTopic that sets one stays NotReady while the release reports Ready, so the chart refuses to render such a topic. It reads segment.bytes the way Kafka does: trimmed, with an optional sign, leading zeros decimal. BREAKING CHANGE: the Kafka application accepts version v4.3 (default) and v4.2; v3.8 and v3.9 are gone, and the platform migration moves existing applications to v4.3. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
af0db99c71 |
feat(platform): move Strimzi resources to the v1 API before Strimzi 1.x
Strimzi 1.0 removed v1beta2 from its CRDs, and the API server refuses a CRD that drops a version its status still lists as stored. Every stored object has to be rewritten as v1 before the new operator arrives, which needs the CRDs of Strimzi 0.49 to 0.51 that serve both versions and Strimzi's own conversion tool. The 0.45 operator is stopped first: Strimzi supports the conversion only under an operator that knows v1, and 0.45 keeps rewriting the Kafka status through v1beta2. The conversion Job's ClusterRole can patch CRDs and write ConfigMaps in every namespace, so it goes with its binding and ServiceAccount once the Job has finished, successfully or not; a failed Job stays for diagnosis, and a Job still running when the wait times out keeps them, because the retry waits for that Job. Two references to v1beta2 outlive the stored objects. Helm builds the objects of a release before it upgrades or uninstalls it, so every stored revision of every Kafka application is rewritten to v1. And the API server refuses server-side apply to an object whose managedFields still name a version the CRD no longer serves; when helm-controller recovers by wiping them, a field a later chart drops is never removed. Those entries move to v1 as well. A Helm action already running stores the releases it read when it finishes, v1beta2 included, so the version is not stamped while any Kafka release revision is still pending. Strimzi 1.x also runs neither ZooKeeper nor Kafka 3.x. A ZooKeeper cluster, or a shared broker pool still being drained, left by a platform that moved past v1.7 before its ZooKeeper to KRaft migration finished cannot be finished afterwards, so the migration stops instead; Kafka applications on v3.8 or v3.9 move to v4.3. The migration also stops, before it changes anything, while a Kafka application topic or a KafkaTopic sets a config Kafka 4 removed or a segment.bytes below the 1 MiB minimum of Kafka 4: the new kafka chart refuses to render such a topic, and a Kafka 4 broker whose log holds the small segment.bytes does not start. segment.bytes is read the way Kafka reads it: trimmed, with an optional sign, leading zeros decimal. Strimzi's conversion tool refuses some v1beta2 objects outright, and convert-resource stops at the first one, with the operators already stopped. While v1beta2 is served the migration lists every Strimzi kind first and refuses, naming each object and the reason, before it stops anything. The list follows the 0.51.0 tool the conversion Job runs, and a test fails when that image changes. The conversion deletes the Kafka's KRaft metadata state, and KRaft is the state Strimzi never leaves. Before it stops the operators, the migration records an annotation on every Kafka it accepts, so a retry after the conversion still accepts a NotReady Kafka that passed on its KRaft state. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
c1740e7631 |
test(tests): select resources in absence-only Helm checks (#5174)
## What this PR does Select the intended resource by kind or name in 23 absence-only Helm tests: the 21 cases catalogued in #4665, a newer MariaDB backup-script case, and Kafka's JVM-options case. The requested kubernetes-nodes/nodegroup and OpenSearch TLS audit found no remaining unanchored negative-only cases. Add a diff-based CI guard against new positional selectors in first-party suites on templates with multiple literal resource blocks. It preserves single-document uses and unchanged indices, including pure suite renames; renamed suites are still checked for added index lines. It follows Helm's template and index precedence, and its fixtures use portable file writes. The guard runs after the test steps so a guard failure cannot suppress their results. The guard is intentionally static: it counts `---`-separated blocks with a top-level `kind`, not resources produced by helpers or ranges, and does not evaluate whether whole-document branches are mutually exclusive. It does not audit vendored suites or existing indices when a template later gains documents. Validation: - `make helm-unit-tests` passes: 106 package test targets, 556 Helm suite executions, and 4,067 Helm tests, including the dashboard package’s additional Go checks. - All 51 focused BATS checks pass. The full BATS sweep initially passed 2,435 of 2,500 cases; six graph-selection failures were then resolved by using the repository-pinned yq v4.53.3 (127/127 targeted rerun cases pass). The remaining 56 Docker-dependent and three envsubst-dependent cases are blocked by missing host prerequisites; no full BATS pass is claimed. The six yq-related failures also reproduce on the unchanged base with the older tool and pass with the pinned version. - All 17 guard regression tests pass, including first-party scope, inherited index precedence, pure/edited renames, template overrides, nested default templates, conditional kinds, and multiline index values. - Missing-target mutations cover all 23 selector changes: original cases pass against unrelated resources; updated cases fail with `document not found`. - Reordered violating-target mutations cover all 22 formerly positional cases: originals pass against leading unrelated resources; updated cases find the intended target and fail their content assertion. Kafka's updated case also passes when the reordered Job remains valid. - Empty-render mutation confirms that the newer MariaDB backup-script case previously passed without a document and now fails. Existing positional cases already fail on an entirely empty render. - The changed workflow passes the repository-pinned zizmor v1.26.1 offline audit; `git diff --check` is clean. Closes #4665 ### Screenshots Not applicable (tests and CI only). ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note NONE ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Chores** * Pull request checks now flag positional document selections in Helm tests when they target multi-document templates. * **Bug Fixes** * Updated chart tests to select Kubernetes resources by kind or name rather than document position, keeping assertions focused on the intended resources. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
da17254bbc |
fix(kubernetes): bring up a replacement worker before draining the old one (#5153)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Worker pool MachineDeployments roll out with `maxUnavailable: 1`. CAPI therefore drains and deletes an old Machine as soon as its replacement Machine has been created, not once the replacement has joined. Observed on a one-node pool changing instance type (`s1.large` to `s1.medium`): the new Machine was created at 13:07:19, the old node was drained and deleted 17 s later, and the new node was Ready around 13:11, so the pool had no node for about four minutes. Larger pools lose one node of capacity at every step of the rollout for the same reason. This sets `maxUnavailable: 0`, so a node is drained only once its replacement is up. `maxSurge` stays at the pool ceiling (`maxReplicas`), with a floor of 1: CAPI rejects a RollingUpdate where both values are 0, and `maxReplicas: 0` is accepted by the schema. Exception: a pool with `gpus` keeps `maxUnavailable: 1`. Its replacement VM may need the very passed-through GPU the old node holds, and with `maxUnavailable: 0` it would stay Pending and the rollout would never finish. A Proxmox pool that passes GPUs through its template carries no `gpus` value, so the chart cannot recognise it: the new optional `maxUnavailable` value lets such a pool (or any pool) set the strategy explicitly, and set to 1 restores the drain-first behaviour. The value is bounded to 0..2147483647, since CAPI decodes it as an int32. ComputePlane pools render through the same chart, so `packages/extra/computeplane` exposes `nodeGroups.<pool>.maxUnavailable` and its allowlist forwards it. Trade-off: a rollout now needs room for at least one extra VM. A tenant at its quota stalls the rollout (the new Machine stays Pending) instead of temporarily shrinking the pool, which is the safer failure. Tests: `tests/rollout_strategy_test.yaml` (7 cases: the default, the ceiling, a zero ceiling, a GPU pool, and the explicit override) fails on `main` without the template change; the render snapshot is updated. Two more cases cover the int32 maximum, accepted at 2147483647 and refused one above. `helm unittest packages/apps/kubernetes-nodes`: 252 passed. `packages/extra/computeplane/tests/cluster_test.yaml` checks that the wrapper forwards `maxUnavailable` (it fails without the allowlist entry) and refuses a value above the int32 range: 15 passed. Backport: on `release-1.6` the same strategy is also rendered by `packages/apps/kubernetes/templates/cluster.yaml` (the in-chart `nodeGroups`), and the snapshot file does not exist there, so the automatic backport cannot apply. A manual backport PR to `release-1.6` covering both charts follows. `release-1.7` keeps `kind/backport`. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [x] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: cozystack/terraform-provider-cozystack#79 (tracking issue: the provider change is out of scope here). `cozystack_kubernetes_nodes` has no attribute for the new `maxUnavailable`, so a Terraform-managed pool cannot drain first; the provider has no ComputePlane resource yet. - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(kubernetes): worker pool rollouts (instance type, image or version changes) now bring each replacement node up before draining the old one, instead of removing a node first. A rollout needs room for one extra VM. Pools with GPUs keep the previous behaviour. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a pool-level `maxUnavailable` setting to control how many workers may be removed before replacements are ready. It defaults to 0 for non-GPU pools and 1 for GPU pools; configured values override these defaults. * Proxmox pools passing through GPUs can set `maxUnavailable` to 1 to help prevent rollouts from waiting indefinitely. * **Bug Fixes** * Rolling updates now use at least one surge node, even when the replica limit is zero. * **Documentation** * Documented rollout settings, defaults, and capacity considerations. * **Tests** * Added coverage for defaults, overrides, surge limits, and invalid values. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
46cb99df5b |
fix(controller, platform): give unbounded pool members the root's LimitRange (#5265)
## What this PR does Since tenant quotas became hierarchical (#3086), an unbounded sub-tenant (no `resourceQuotas` of its own) shares its parent's pool and receives a controller-owned `tenant-quota-allocated` ResourceQuota. The tenant chart, however, renders the `tenant-range-limits` LimitRange only next to the `tenant-quota` of a tenant that declares `resourceQuotas`, so these namespaces end up with a quota on `limits.cpu`/`limits.memory` and no container defaults. Admission then rejects every container that omits one of those limits. Pods that predate the quota keep running and fail as soon as they are recreated. In production this took down CNPG postgres instances with backups enabled: the `plugin-barman-cloud` sidecar injected by the barman-cloud plugin sets CPU and memory requests and a memory limit but no CPU limit, so the instance pod is refused on its next restart. The same happened to the tenant `kubernetes` app: the `wait-for-kubeconfig` init container of `cluster-autoscaler`, `kcsi-controller` and the `bootstrap-token` jobs has no resources, so their ReplicaSets and Jobs were refused with `failed quota: tenant-quota-allocated: must specify limits.cpu` in every unbounded sub-tenant hosting a tenant cluster. On a production cluster, 131 tenant pods currently get their CPU or memory from the tenant LimitRange (VictoriaMetrics `config-init`/`config-reloader`, Harbor exporter, MariaDB agent, Strimzi entity operator, among others), so the defect is not specific to one chart: any of them breaks once it lands in such a namespace. Workloads that set every limit explicitly are unaffected. The controller already decides which namespaces it clamps, so it now copies the pool root's chart LimitRange into each unbounded member whose allocated quota bounds `limits.cpu` or `limits.memory` as `tenant-range-limits-allocated`, keeps it in step with the root, and deletes it once the namespace leaves the pool (for instance when the sub-tenant declares its own quota and the chart renders its own LimitRange). The chart renders its LimitRange under any non-empty `resourceQuotas`, including one that bounds no compute (#4930), so the copy is limited to members whose quota bounds a compute limit: elsewhere it would impose a 128Mi default memory limit the quota never asked for and refuse pods, virt-launcher among them, that are admitted today. This keeps the change independent of #4954. The copy has its own name so that Helm can still create the chart-owned object in that case without an ownership conflict. The root is the single source of truth for the defaults, so the values stay defined in `packages/apps/tenant/templates/quota.yaml` only. The controller gains `limitranges` RBAC and watches the two LimitRange names so a change propagates without waiting for the 60 s resync. Tests: five reconciler cases cover a member under a non-compute quota (no copy, and a stale one removed), the copy into an unbounded member (and not into the root), propagation of a change on the root, garbage collection once the member is bounded (the chart-owned object is left alone), and a root without a LimitRange. Disabling the copy makes the first two fail. ### Screenshots Not a UI change. ### Downstream repositories Walked the trigger map against the diff. The code touches only `internal/controller/tenantquota/` and the `cozystack-controller` RBAC template, but the website's `system-memory-limits.md` states that tenant namespaces get defaults only from the chart's `tenant-range-limits`, which this change makes untrue; the follow-up is an issue, since the page should change once this is merged. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#806 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(controller, platform): sub-tenants without their own resourceQuotas now receive their parent pool's container defaults (LimitRange) alongside the allocated quota, when that quota bounds a CPU or memory limit, so pods that omit such a limit, such as the postgres barman-cloud backup sidecar, are no longer rejected at admission. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Unbounded pool members now receive their pool’s CPU and memory limit settings when their allocated quota sets those limits. Pool setting updates are reflected in members during reconciliation. * When a member has its own quota, inherited limit settings are removed while settings configured directly for that member remain unchanged. * No inherited settings are created when the pool has no limit settings or the allocated quota does not set CPU or memory limits. * Existing inherited settings are retained if an update temporarily fails. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
f8217be501 |
Merge branch 'main' into chore/cilium-drop-unread-values
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
3ede7c4d33 |
feat(observability-proxy): include platform exporter series in the namespace root (#5277)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Add the label `kind/backport` if it's a bugfix that needs to be backported to a previous version. --> ## What this PR does Builds on #5219 and #5220, both merged. The namespace metrics root `/apis/cozystack.io/v1alpha1/namespaces/<ns>/metrics/...` now also returns series that a platform exporter attributes to `<ns>`. Example: the ClickHouse operator's exporter runs in `cozy-clickhouse-operator`. vmagent scrapes it without `honorLabels`, so its series carry `namespace="cozy-clickhouse-operator"`, and the tenant namespace the exporter reported moves to `exported_namespace="<ns>"`. Until now, any client of the namespace root (kubectl, automation, the console) never saw those series. ### Behavior changes - Namespace root, every endpoint (`query`, `query_range`, `series`, `labels`, `label/<name>/values`): - was: one proxy-set `extra_filters[]={namespace="<ns>"}`; - now: two values, `{namespace="<ns>"}` and `{namespace=~"cozy-.*",exported_namespace="<ns>"}`. vmselect ORs them. - Label APIs without a client `match[]`: the proxy already repeats the scope in `match[]` for `-search.ignoreExtraFiltersAtLabelsAPI`; it now repeats both values. vmselect ANDs every `match[]` with every `extra_filters[]`. Each cross pair is narrower than one of its halves, so the result is still exactly the union. - Client `extra_filters`, `extra_filters[]` and `extra_label` are still dropped. - New flag `--metrics-platform-namespace-prefix` (default `cozy-`) and chart value `observabilityProxy.metrics.platformNamespacePrefix`. An empty value turns the second branch off and restores the single-value scope. The proxy quotes the prefix and anchors it, so the value is matched literally and cannot become a wider regex. The flag accepts only namespace name characters, because any other value would match no namespace and silently drop the exporter series. - Exporter series keep `namespace="cozy-..."`. A query that also selects `namespace="<ns>"` excludes them; select them by `exported_namespace` or by the exporter's own labels (for ClickHouse, `chi`). - The branch is not specific to ClickHouse. For example, kube-state-metrics in the platform monitoring namespace sets `exported_namespace` from `metadata.namespace` on the Flux `gotk_resource_info` series (`packages/system/monitoring-agents/values.yaml`), so a namespace root now also returns the state of that namespace's own HelmReleases and Kustomizations. This is the namespace's own data, but it is a visible change with the default prefix. - Queries grouped `by (namespace)` can now return an extra group labelled with the exporter's platform namespace. The exporter's series also carry its own target labels (`pod`, `instance`, `job`) into the tenant's results. - An empty scope is refused with 500 instead of forwarding a request without `extra_filters[]`. - The application roots of #5220 are not affected: they replace the scope with their own selectors. ### Threat model 1. **Scrape path.** vmagent sets `namespace` from service discovery, while `exported_namespace` is whatever the exporter wrote. Any tenant pod can write a `namespace` label, which arrives as `exported_namespace`, so the extra branch only trusts it on series scraped from platform namespaces. Tenant roles (`packages/system/cozystack-basics/templates/clusterroles.yaml`) grant no access to `operator.victoriametrics.com` and no verbs on `Namespace`. A tenant can therefore neither run a target in `cozy-*` nor point a scrape object at one. 2. **Remote-write writers.** A tenant's nested Kubernetes cluster runs its own vmagent, which remote-writes into the same store when the tenant has no monitoring of its own, and the labels it writes are not enforced. Inside that cluster the tenant can create `cozy-*` namespaces or any other, so it can already write `namespace="<any ns>"` and pass the existing single filter. This is an existing limitation that this PR neither introduces nor widens: anything that can write `namespace="cozy-x",exported_namespace="<ns>"` can write `namespace="<ns>"` directly. Closing it needs enforcement on the write path and is out of scope here. 3. **Impact of a forged series.** The scope only adds series to a namespace's results; it never lets a caller read another namespace. A forged series can spoil or flood another namespace's graphs, up to the series limits that answer 422. ### Rejected alternatives - **Bare `{exported_namespace="<ns>"}`.** Every namespace is scraped by default, so any tenant pod could inject series into another namespace's root. - **Relabeling the ClickHouse operator's scrape so that `namespace` carries the tenant namespace.** It fixes one exporter at a time, each in its own chart, and it changes the label set of every existing series, which splits their history at the change and breaks any query that selects them by the operator's namespace. The proxy-side branch covers every platform exporter and leaves stored series as they are. - **Scraping the ClickHouse pods directly.** The metric names differ from the operator's exporter, so the shipped ClickHouse dashboard (`dashboards/clickhouse/altinity-clickhouse-operator-dashboard.json`), which reads the exporter's `chi_clickhouse_*` series, would have to be rewritten. - **A free regex flag instead of a prefix.** One typo (`.*`) would trust `exported_namespace` from every namespace. ### Tests - Table of namespace-root requests: exactly two `extra_filters[]` values in order with the default prefix, one value with an empty prefix, on all five endpoints. Client `extra_filters[]` still dropped. - A model of vmselect's selection (OR over `extra_filters[]`, AND with each `match[]`) shows that `namespace=cozy-x, exported_namespace=<ns>` is visible, and that `namespace=tenant-y, exported_namespace=<ns>` and `namespace=xcozy-a, ...` are not. - Escaping of `<ns>` in `exported_namespace`, literal prefix quoting, empty scope refused, flag validation, and a chart test that an empty value reaches the binary as an explicit empty flag. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> Not a UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The diff touches only `cmd/observability-proxy`, `internal/observabilityproxy` and the system package `packages/system/observability-proxy` (a new value and flag, no app, platform values, CRD, `hack/` or naming change). None of the triggers in `docs/agents/contributing.md` under "Downstream Repositories" apply. ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note feat(observability-proxy): the namespace metrics root also returns series that exporters in platform (`cozy-*`) namespaces attribute to the namespace through `exported_namespace`, such as the ClickHouse operator's. The prefix is set by `--metrics-platform-namespace-prefix` / `observabilityProxy.metrics.platformNamespacePrefix`; an empty value disables it. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Metrics queries now include series attributed to a tenant namespace by exporters in platform namespaces with the configured prefix. The default prefix is `cozy-`; setting it to an empty value disables this behavior. * Namespace scoping is applied across supported metrics endpoints, including label lookups. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
b1e067f6e1 |
chore(tests): merge upstream main into resource selector branch
Preserve the Helm selector guard alongside main's independently gated backport tests when refreshing the branch's upstream base. Validated with actionlint and 31 focused Bats tests. Signed-off-by: Ahmed Kamal <email.ahmedkamal@googlemail.com> Assisted-by: LLM |
||
|
|
c93af24ea2 |
Merge branch 'main' into fix/vpa-admission-webhook-timeout
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
06ca603f4f |
feat(platform): expose Keycloak truststores through platform values (#5144)
## What this PR does Fixes #5140. #5039 added `truststores` to the Keycloak chart, but that capability was not reachable through the administrator-owned platform Package: the system bundle rendered `Package cozystack.keycloak` without a components override. This PR adds the optional `authentication.oidc.keycloakTruststores` platform value and forwards it unchanged to `spec.components.keycloak.values.truststores` on that child Package. Administrators can configure it under `spec.components.platform.values` on `Package cozystack.cozystack-platform`: ```yaml authentication: oidc: keycloakTruststores: - configMapName: organization-ca key: ca.crt - secretName: partner-ca key: certificates.pem ``` When OIDC is enabled and the list is non-empty, the complete list is forwarded, including entry order, explicitly selected keys, and entries that omit `key` so the chart's `ca.crt` default remains effective. When the value is unset or explicitly empty, the platform continues to use the default Package helper without introducing `spec.components`. When OIDC is disabled, the value is ignored because no Keycloak Package is emitted. The platform layer only forwards references; it does not create Secrets or ConfigMaps. Referenced objects and keys must already exist in `cozy-keycloak`, and the Keycloak chart remains responsible for validation and mounting. Its existing semantics are unchanged: trust applies server-wide across all realms, only public certificate material should be supplied, and changing an object's contents requires a Keycloak restart or a versioned object reference to reload the truststore. ### Validation - `make test` in `packages/core/platform`: all 295 tests pass. The new suite covers unset, empty and null defaults, complete list forwarding, false-y malformed values, both `isp-full` and `isp-slim`, and disabled OIDC; removing the forwarding path or restoring truthiness-based empty checks makes the regression suite fail. - `make test` in `packages/system/keycloak`: all 121 tests pass. - With the system bundle and OIDC enabled, the unset render is byte-identical to `upstream/main`. The explicitly empty case is separately verified to omit `spec.components`; malformed false-y values reach the Keycloak chart and are rejected by its existing `truststores must be a list` validation. - `make generate` has no target in `packages/core/platform`; there are no generated platform schema artifacts to update. - `make show` could not run because `cozyhr` is unavailable. A direct `helm template` render of the system bundle was checked in a temporary chart copy with `templates/repository.yaml` removed because its `lookup` requires a live source. This verifies rendering and forwarding, not a live-cluster deployment or an end-to-end Keycloak TLS connection. ### Screenshots Not applicable; no UI changes. ### Downstream repositories Changing `packages/core/platform/values.yaml` directly triggers the website's hand-written platform-package reference. The existing cozystack/website#765 follow-up covers both the chart-level value and this platform configuration path, including `content/en/docs/next/operations/configuration/platform-package.md`; no other downstream trigger applies to this diff. - [ ] No downstream repository is affected by this change - [x] [cozystack/website](https://github.com/cozystack/website) - follow-up: https://github.com/cozystack/website/issues/765 (covers the platform value and platform-package reference as well as the chart-level guide) - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(platform): add `authentication.oidc.keycloakTruststores` so administrators can forward existing Secret or ConfigMap CA references from the platform Package to the bundled Keycloak server for private-CA LDAPS, external identity-provider, and SMTP TLS connections. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added the `authentication.oidc.keycloakTruststores` setting for configuring additional CA certificates from Secrets or ConfigMaps in `cozy-keycloak`. Certificate entries default to `ca.crt`, and configured certificates apply across all Keycloak realms. * The setting defaults to an empty list. Configured truststores are passed to Keycloak when OIDC is enabled; when OIDC is disabled, the setting is ignored and existing Keycloak package settings remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
233dee7049 |
docs(vpc): generate README parameters from values.yaml (#4944)
<!-- 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 `packages/apps/vpc/Makefile` is the only app Makefile that calls `cozyvalues-gen` without `-r README.md`, and it has been that way since the app was added, so the README's Parameters table was hand-written and never regenerated. It still documents `subnets` as `map[string]object` and omits `peers` and `routes`, and the README example uses the map form, which `values.schema.json` rejects since #2052 made `subnets` a list. That README is also the source of the website's VPC reference page, so the published example is the invalid one. This adds `-r README.md`, regenerates the table with cozyvalues-gen v1.7.0 (the version CI uses), and rewrites the example as a list. `make generate` in `packages/apps/vpc` leaves the CRD and Go types unchanged, and the new example validates against the VPC `openAPISchema`. The draft #4813 edits this `values.yaml`, so once this lands its `make generate` will update the README as well. ### 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: The website's VPC page is regenerated from this README by the release bot, so it needs no separate change. ### 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 docs(vpc): document subnets, peers and routes in the VPC README as the list-based parameters the chart accepts. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated the VPC configuration guide to describe subnet entries, including names, CIDR ranges, and optional allowed source ranges. * Added guidance for configuring VPC peers with a remote VPC name and tenant namespace, and routes with a destination range and next-hop IP. * Revised the subnet example to use a list of named entries. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
2568db67b1 |
Merge branch 'main' into fix/kubernetes-nodes-surge-before-drain
Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io> |
||
|
|
5dbfa1cfad |
fix(linstor): restore snapshots on a schedulable node (#5309)
## What this PR does When linstor-csi restores a snapshot (a PVC with a `VolumeSnapshot` data source, as the Velero data mover creates for every backup), it restores it on exactly one node, and the new volume is pinned there. Two things go wrong in how that node is chosen. - The candidate filter is `slices.Contains(preferredNodes, snapNode)`, but `preferredNodes` is the output of `SortByPreferred`, which holds every node and only orders them. The filter therefore never filters, and the node the scheduler selected for a `WaitForFirstConsumer` volume (`preferredNodes[0]`) gets no priority. When the snapshot is not on that node, the pod's `PreBind` fails with `node affinity doesn't match` and needs another scheduling round. That happens even when the selected node does hold the snapshot. - `NodeAvailable` only checks that the LINSTOR satellite is `ONLINE`. A cordoned Kubernetes node passes. A volume restored there can never be used, because no new pod can be scheduled on that node: the pod stays `Pending` until the node is uncordoned. On a production cluster with two storage nodes cordoned ahead of a reboot, this failed 42 of 44 restores that landed on those nodes, while 0 of 777 restores on the other nodes failed. Each failure surfaced as a Velero `DataUpload` ending in `timeout on preparing data upload`, although the snapshot also existed on two schedulable replicas. Patch `003-snapshot-restore-node-selection.diff` makes the controller: - restore on the scheduler-selected node when it holds the snapshot; - otherwise pick a random snapshot node, keeping the spreading that `001-relocate-after-clone-restore.diff` introduced, but skip cordoned nodes as long as another node holds the snapshot. When only cordoned nodes hold it, behaviour is unchanged. Cordon state is read from the Kubernetes `Node` object (`spec.unschedulable`), through the in-cluster typed client that `utils.KubernetesClient` already provides. The `linstor-csi-controller` ServiceAccount already has `get` on `nodes` for the external-provisioner. Outside Kubernetes, or when the lookup fails, every node counts as schedulable, as before. Tests: `TestLinstor_reconcileSnapshotResourcesSkipsCordonedNodes` reproduces the production case through `reconcileSnapshotResources` with mocked LINSTOR providers. Without the cordon check, 16 of 50 restores landed on the cordoned node; with it, none do. `TestSelectRestoreNode` covers the selected node, the cordoned selected node, only-cordoned snapshot nodes, the preferred-node fallback and the spreading. The Dockerfile runs `go test` in `pkg/client` as part of the image build. ### Downstream repositories The diff only adds a patch under `packages/system/linstor/images/linstor-csi/patches/`. I walked the trigger map against it and found no entry that it matches. - [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(linstor): restore a snapshot on the node the scheduler selected when it holds the snapshot, and never on a cordoned node while another node holds it, so pods using a volume restored from a snapshot (such as Velero data mover backups) no longer stay Pending while a storage node is cordoned ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Snapshot restores now avoid cordoned nodes when another usable node is available and prioritize preferred nodes when possible. * Restore selection remains available when Kubernetes node information is missing or lookup errors occur. * When no preferred or schedulable node is available, restores can fall back to any available node. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
aa36d3fad6 |
fix(kubernetes)!: remove the talos block and other leftovers of the worker pool split (#5191)
## What this PR does Cleanup after the Kubernetes app was split into `Kubernetes` (control plane and addons) and `KubernetesNodes` (one release per worker pool): what the split left behind in values, docs, templates and tests. ### Kubernetes The `Kubernetes` application has no `talos` field any more. Worker pools are `KubernetesNodes` resources and take their Talos release, image, installer and registry mirrors from their own `talos` and `osImage`, so the cluster's copies did nothing. The last one, `talos.version`, fed a duplicate of the Talos to Kubernetes support-matrix check. The pool chart already runs that check against the Talos release each pool actually boots, including one picked through an `osImage` override; the cluster's copy compared the Kubernetes version against a release no node runs. A stored spec that still carries `talos.*` keeps rendering, because the values schema does not close the object and the API does not validate `spec` against it, and a unit test pins that. The pool's check now has render coverage. Its own suite pins the pairings it must accept, and a bats test renders the refusals through `talos.version`, `osImage.factory.version` and `osImage.builtin.version` with schema validation skipped, since the schema offers no Kubernetes version the matrix refuses. I fixed the README and field descriptions that described behavior the chart no longer has, or never had: a dedicated etcd cluster, a `blockSize.matchVolume` setting that does not exist, a default `md0` pool, the host default, the substrate mismatch behavior, and rollout phase names. The README's Breaking Changes section becomes a pointer to the per-release upgrade notes on cozystack.io. Unused helpers and stale comments are removed; the chart renders the same bytes. ### KubernetesNodes Five field descriptions and the `talos` block told users to keep them in sync with parent fields that do not exist. NOTES warned about colliding with a parent-managed `md0` pool, although the parent renders no pools and `md0` is the normal name of a pool. The installer image was credited to an upgrade Job that never runs one. The values descriptions, README intro and NOTES now say what the chart renders today, including which fields have no effect on `substrate: proxmox`: `storageClass`, `diskSize`, `instanceType`, `talos.imageFactoryURL` (beyond its format check) and `talos.imageFactoryCA`. The render error for a pool whose MachineDeployment belongs to another release told users to remove the pool from the parent's `nodeGroups`, which cannot clear the conflict. It now names a remedy that works. Split-era history is gone from Helm and test comments, along with two `storageClass` fallbacks that can only return the value they fall back from, a constant variable, and two `.helmignore` rules that match nothing. The tenant pod and service CIDRs are literals in both charts, and nothing checked that they agree. A new bats test renders both charts and fails when they differ. No rendered manifest of the pool chart changes. I rendered it for the snapshot values, GPU, kubelet-override, factory/CA, storageClass variants and three Proxmox variants on main and on every commit, and the output is byte-identical. The snapshot and TalosConfigTemplate hash tests pass unchanged, so no worker rolls. YAML comments inside the hashed machine config and machine template are left as they are for that reason. ### The rule `docs/agents/overview.md` gains a rule so this does not come back with the next change: app READMEs and field descriptions describe current behavior, a change users must act on goes to the website's upgrade page, and a description does not ask the reader to keep it in sync with another chart. ```release-note [kubernetes] The Kubernetes application no longer has a `talos` field. Talos settings for workers, and the Talos to Kubernetes compatibility check, live on each KubernetesNodes pool. Existing clusters that still store `talos` values keep working; the values are ignored. KubernetesNodes field descriptions, README and install notes now describe the worker pool as it works today, including which fields have no effect on Proxmox pools. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Configuration** * Worker OS image, installer, and registry-mirror settings are configured per worker pool; these settings are no longer available at the cluster level. * Kubernetes and Talos version compatibility is checked for each worker pool. A worker Kubernetes version cannot be ahead of its parent cluster. * Worker pools support KubeVirt and Proxmox, with pool-specific sizing and disk settings. * Rendering is refused when a pool uses a different substrate from its cluster or conflicts with an existing worker pool owned by another release. * The default cluster hostname now includes the `kubernetes-` prefix. * Existing cluster configurations that still include Talos settings receive a warning; those settings are no longer used. * **Documentation** * Updated guidance for cluster and worker-pool settings, storage, upgrades, and version compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
b24a9b4cb9 |
Merge branch 'main' into feat/observability-proxy-exported-namespace
Resolve the overlap with the per-application roots: the namespace root keeps its platform exporter branch, the application root still replaces the whole scope with its own selectors, and the label APIs mark the repeated scope so that replacement reaches match[] as well. Assisted-by: LLM Signed-off-by: Maxim Belyy <maximbel2003@gmail.com> |
||
|
|
4f7eb63447 |
feat(observability-proxy): serve per-application logs and metrics (#5220)
## What this PR does Depends on #5219. This PR is stacked on that branch; the description covers only what it adds on top. Adds the per-application roots to the observability proxy, as described in the design proposals [Tenant application logs](https://github.com/cozystack/community/pull/95) and [Tenant resource-consumption metrics](https://github.com/cozystack/community/pull/94): ```text /apis/apps.cozystack.io/v1alpha1/namespaces/<ns>/<plural>/<name>/log/select/logsql/<endpoint> /apis/apps.cozystack.io/v1alpha1/namespaces/<ns>/<plural>/<name>/metrics/api/v1/<endpoint> ``` This lets the console show the logs and resource consumption of one application rather than of the whole namespace. What is added: - Plural-to-Kind mapping from an informer over `ApplicationDefinitions`. The Kind is looked up only after the `SubjectAccessReview` (`get <plural>/log` or `get <plural>/metrics`), so an unauthenticated caller cannot probe which plurals exist. An unknown plural answers `404`; an unsynced cache or a plural declared by two kinds answers `503`. - Logs: a second `extra_stream_filters` value with the application Kind and name, on top of the unchanged namespace filter. VictoriaLogs ANDs the two, on every endpoint including `tail`. - Metrics: the forced `extra_filters[]` becomes an OR of three branches, each still bound to the namespace: 1. series carrying the application identity labels; 2. series of the application's pods, found through `kube_pod_labels`; 3. series of the application's PVCs, found through `kube_persistentvolumeclaim_labels`. - The pod and PVC lookups cap the number of names (`--metrics-app-max-pods`, `--metrics-app-max-pvcs`); over the cap answers `422`. A failed pod or PVC lookup fails the request (`502`, or `504` on the deadline) rather than answer without the application's series, and so does a lookup that vmselect marks `isPartial`, since a storage node that did not answer leaves names out (a partial list already over the cap still answers `422`); vmselect's series-limit refusal of a lookup is passed through as `422`. A query that reads further back than `--metrics-app-lookback` (default 720h, chart value `observabilityProxy.metrics.appLookback`), or by an unknown amount, and a query whose samples lie at a time the lookup cannot cover answer `422` on the application root; this includes every query with an `@` modifier, `WITH` with a negative offset, and offsets that are not plain durations. The namespace root still serves them. `rollup_candlestick`, a backslash or a `#` comment outside a string, an offset directly followed by a minus (compound durations such as `-1h-30m` or `1h-2h`), and a subquery step that is not a plain duration are refused as well. The lookup reaches past the evaluation time by any negative offset and by two steps per subquery level. - Application routes require read access to the namespace root as well as the application subresource; a grant narrowed with `resourceNames` alone answers `403`. - The proxy's ClusterRole gains `list`/`watch` on `cozystack.io/applicationdefinitions`. No tenant RBAC change is needed: the `view` role already allows `get` on every `apps.cozystack.io` resource and subresource. - `/readyz` now also waits for the `ApplicationDefinitions` cache, so a missing CRD or RBAC rule keeps the whole proxy unready, namespace roots included. #### Data comes from the identity labels The application roots find data only through identity labels added by three PRs that are now in main: - #5215 `feat(monitoring-agents)`: export PVC labels from kube-state-metrics (PVC branch). - #5216 `feat(monitoring)`: stamp application identity on scraped series (identity branch). - #5217 `feat(monitoring-agents)`: keep application identity in container log streams (logs root). Merge after #5219. The pod branch does not depend on them, because `kube_pod_labels` already exports all pod labels. Logs and series written before those changes rolled out carry no identity and are reachable only through the namespace root. #### Security condition: a convenience filter, not an isolation boundary The application roots narrow the namespace roots; they do not isolate applications from each other. Each application route therefore requires two grants: the application subresource (`get <plural>/log` or `get <plural>/metrics`) and read access to the namespace root (`list cozystack.io/logs` or `cozystack.io/metrics` in the namespace). A grant narrowed with `resourceNames` alone is refused. Every tenant role that can read applications already has both. The application scope cannot isolate yet because: 1. The lineage webhook keeps `apps.cozystack.io/application.*` labels that a user sets on a pod or PVC that has no application owner, so such an object can claim another application's identity. 2. The webhook's `objectSelector` skips any object created with `internal.cozystack.io/managed-by-cozystack`, pods included, so forged labels on such an object are never examined. 3. The pod and PVC branches match by name over the lookup window, so an object that reuses the name of another application's recently deleted pod or PVC pulls that object's older series into scope. The proposed fix (a separate change to the lineage webhook) is to strip the identity labels when no owner resolves, and to stop skipping CREATE requests for objects carrying the managed-by label. #### Other known gaps - PVCs created from a StatefulSet's `volumeClaimTemplates` usually get no lineage labels, so their volume series are not in the application scope. - ingress-nginx series intentionally carry no application identity, so they are reachable only through the namespace root. - A request for an application that does not exist answers `200` with an empty result rather than `404`: the proxy checks authorization, not existence. Nothing leaks; whether a `404` is wanted is open for review. #### How it was tested - `go test -race` and `go vet` for the proxy packages, including a narrowed-grant test (access to application `a` only): every application path for `b` answers `403` and no request reaches the store. Name escaping in the pod and PVC branches is covered for regex metacharacters and quotes. - helm-unittest for `observability-proxy` (new RBAC rule). - Verified on a test cluster, with the three identity PRs above applied: the application logs root of a Redis instance returned only that instance's lines and none from a neighbouring pod in the same namespace; its application metrics root returned only the Redis pods' series. ### Screenshots No UI changes. ### Downstream repositories - [ ] 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: Downstream: no trigger matched. Candidate: none affected, because the diff on top of #5219 is confined to the proxy's Go code and its own chart RBAC; it reads `ApplicationDefinitions` but does not change their semantics or the CRD. The security condition above may deserve a note in the design proposals in `cozystack/community`, which is not a trigger-map item. ### Release note ```release-note feat(observability-proxy): add per-application logs and metrics roots under `/apis/apps.cozystack.io/v1alpha1/namespaces/<ns>/<plural>/<name>/{log,metrics}/`, scoped by application identity labels. Data appears for logs and series collected after the application identity changes to Fluent Bit, VMAgent and kube-state-metrics are rolled out. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added a tenant-aware observability proxy for logs and metrics, with namespace and application scoping, access checks, and per-user request limits. * Enabled the proxy in the system package bundle and routed console log and metrics requests through it. * Added live log streaming and health, readiness, and metrics endpoints. * **Bug Fixes** * Invalid or excessive query parameters are rejected; requests with uncertain application-metric scope are refused rather than returning incomplete results. * **Tests** * Added end-to-end and integration coverage for tenant isolation, console routing, access controls, and log streaming. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
526f08e17d |
fix(mariadb): restore the dump a Backup was taken as (#5227)
## What this PR does A RestoreJob that names a MariaDB `Backup` restored the newest dump of the application, not the dump of that `Backup`. The driver created the operator `Restore` with only `backupRef`, and mariadb-operator then restores the dump nearest to the moment the restore starts, from the prefix every run of the app shares. Restoring an older `Backup` brought back the latest data, and when its own dump was already gone it silently restored another one. The `Backup` now records the dump its operator `Backup` wrote, the file name in `k8s.mariadb.com/dump-file` and the timestamp from that name in `k8s.mariadb.com/dump-time`. They come from the ownership-proven match the size probe already makes, and nothing is recorded when ownership is not proven. A restore first checks with a bounded S3 listing of the operator `Backup`'s own storage that the dump still exists, then sets `targetRecoveryTime` on the operator `Restore` to the dump's own timestamp, which mariadb-operator matches exactly. If the dump is gone the RestoreJob fails and names it. If the check cannot be made it waits with `Ready=False/DumpCheckPending` until the restore deadline and then fails with the cause. `Backup`s taken before this stay restorable. The restore makes the same ownership-proven match against their operator `Backup` and pins the dump when it is provable, otherwise it restores the newest dump as before and a `BestEffortDump` warning event on the RestoreJob says so. One case is not covered: the `Backup`'s own dump is gone, a neighbour's dump from within the minute of slack is still there and its operator `Backup` was deleted, so that dump is taken as the match. Nothing in the platform deletes operator `Backup`s, it needs someone to delete one by hand. A `Backup` made of an operator `Backup` whose Job failed (`Complete` with reason `JobFailed`) has no dump, so its RestoreJob now fails instead of restoring another run's dump. Stacked on https://github.com/cozystack/cozystack/pull/5223 and targets its branch until that merges, only the last three commits belong here. Checked on a test cluster with mariadb-operator 25.10.2. An operator `Restore` of an older `Backup` with `targetRecoveryTime` set to its dump timestamp restored exactly that dump (`obtained target backup` names it and a row inserted after it is absent from the target), the same `Restore` without the target restored the newest one. Against the real bucket and operator `Backup`s the recording probe attributed to each `Backup` the dump its backup pod logged, the existence check passed for those dumps and refused a pruned one, legacy `Backup`s with a provable dump got pinned while back-to-back runs fell back with the warning, and the two failed runs on that cluster were refused. The controller itself was not run on the cluster, only its code driven by a test against the real bucket. Fixes https://github.com/cozystack/cozystack/issues/5196 ### Screenshots Not a UI change. ### Downstream repositories The diff is confined to the backup controller's Go code. It changes no CRD or API type (`driverMetadata` is an opaque map), no chart, values, package layout or `hack/` script, so no entry of the trigger map applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(mariadb): a RestoreJob now restores the dump of the Backup it names instead of the newest dump of the application. It fails with a clear message when that dump no longer exists in storage, or when the Backup was made of a failed backup run. Backups taken before this release are restored by the one dump that can be matched to them, or else, as before, by the newest dump, with a BestEffortDump warning event on the RestoreJob. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * MariaDB backups now record the selected dump’s filename and timestamp, allowing restores to target the corresponding recovery time. * For older backups without dump metadata, restores use a uniquely matched dump when possible or fall back to the latest dump with a warning. * Restore processing verifies recorded dumps, retries temporary storage checks, and reports failures for invalid or missing recorded dumps. * **Bug Fixes** * Deleting a MariaDB backup now removes its associated dump and operator backup when ownership is verified and no restore is active. Cleanup avoids deleting artifacts when it cannot safely identify them. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
53078a1d29 |
feat(observability-proxy): publish the proxy on its own host (#5267)
<!-- 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 an optional public endpoint for the observability proxy, so that clients outside the cluster (kubectl, scripts, third-party tools) can call it directly with their Kubernetes bearer token. The existing paths do not deliver the token: kube-apiserver removes the `Authorization` header after it authenticates a request, so the service proxy of kube-apiserver cannot carry it, and the console route goes through the dashboard gatekeeper, which with OIDC enabled answers a client without a session cookie with 401 and exists only where the dashboard is published. The endpoint is off by default. It is published at `observability-proxy.<publishing.host>` once `observability-proxy` is added to `publishing.exposedServices`, in the same two modes the dashboard uses: - `gateway.enabled: false`: an Ingress on the publishing ingress class, with a per-host cert-manager certificate, or the operator's wildcard certificate when `publishing.certificates.wildcardSecretName` is set (the TLS section stays, so HTTP is still redirected to HTTPS). - `gateway.enabled: true`: an HTTPRoute on the publishing tenant's Gateway. The platform now lists `cozy-observability-proxy` in `gateway.attachedNamespaces` so that the Gateway admits the route. A cluster that overrides `gateway.attachedNamespaces` replaces the whole list and has to add the namespace itself. In Ingress mode the request crosses the publishing tenant's egress policies, which deny everything except the `allow-to-*` destinations, so the tenant chart gains `allow-to-observability-proxy`. It matches the whole `cozy-observability-proxy` namespace, as `allow-to-linstor-gui` does, because cert-manager runs the HTTP-01 solver pods for the proxy's certificate there. The route passes the request through unchanged: no path rewrite and no authentication at the edge, so `/apis/...` and the bearer token reach the proxy as sent. The edge limits are set so that they never end a request before the proxy does: - The tenant ingress-nginx reads upstream with a 10s timeout by default, while the proxy allows a non-tail request up to `--request-timeout` (1m) and keeps a log tail open until it has been silent for `--tail-idle-timeout`. Before the first byte of a response, the token and access reviews can add up to another minute. The Ingress sets a 360s read timeout and keeps response buffering off, so tail lines reach the client as they arrive. - The Ingress sets a 1 MiB body limit, the same limit the proxy enforces on a request body. - On an HTTPRoute that sets no timeout, Cilium keeps Envoy's 15s route timeout, which would cut every tail. The route disables it (`timeouts.request: 0s`), because the proxy limits each request itself. Envoy's stream idle timeout (Cilium `envoy.streamIdleTimeoutDurationSeconds`, 300s by default) still applies and cannot be changed from an HTTPRoute, so the chart now runs the proxy with `--tail-idle-timeout=4m30s` instead of the 5m default. A tail that stops sending lines is then ended by the proxy as a complete response, not reset by Envoy. Before the first byte, slow token and access reviews together with a log store that never sends headers can still exceed 300s; that case ends in an error either way. The proxy never reads the client address or `X-Forwarded-*`. All its limits and its logs use the authenticated user, so nothing changes behind an ingress and the client cannot spoof anything through headers. ### Security This adds a new internet-facing entry point when it is enabled. What protects it: - Every request to a tenant root needs a bearer token that kube-apiserver accepts through a TokenReview, and a SubjectAccessReview for the requested namespace. Paths the proxy does not serve return 404 before any review, and a request without a bearer token returns 401 without a review. - Per-user limits apply after authentication: request rate, concurrent requests, concurrent tails per user, and a total cap on open tails. Every request is bounded by the request timeout, and every tail by the idle timeout. - The body is capped at 1 MiB at the edge and in the proxy. - The new tenant egress policy lets every pod of a tenant open a connection to the proxy namespace, whether or not the proxy is published. This gives a tenant workload nothing it cannot already do through the published host, and the proxy asks for a token in both cases. What it does not protect against: an unauthenticated client can make the proxy send one TokenReview per distinct token it invents. Rejected tokens are cached by hash for the auth cache TTL, so a repeated token costs nothing more. This is the same cost a client can already cause by calling the published Kubernetes API (`api` is in `publishing.exposedServices` by default). No per-IP rate limit is added at the edge, because with `publishing.externalIPs` the ingress Service uses `externalTrafficPolicy: Cluster`, which can hide client addresses behind node addresses, so a per-IP limit would throttle all clients together. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> Not a UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: cozystack/website#787 - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The diff changes `packages/core/platform/values.yaml`, which reaches cozystack/website: `content/en/docs/next/operations/configuration/platform-package.md` lists the possible values of `publishing.exposedServices` and the default `gateway.attachedNamespaces` list, and both need the new entries. The observability-proxy documentation is tracked in cozystack/website#787, which does not cover the public endpoint yet; the endpoint and the new list entries will be added there once this PR is accepted. No other repository in the trigger map is reached by this diff. ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note feat(observability-proxy): the observability proxy can be published at observability-proxy.<host> for clients outside the cluster that use a Kubernetes bearer token. It is off by default; add `observability-proxy` to `publishing.exposedServices` to publish it, through an Ingress or, with `gateway.enabled`, an HTTPRoute. Clusters that override `gateway.attachedNamespaces` must add `cozy-observability-proxy` to it for the Gateway mode. Tenants gain an egress policy to the proxy namespace, which the Ingress mode needs. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Tenant workloads can now connect to the observability proxy. * The observability proxy can be published through an Ingress or Gateway route when enabled in the service exposure settings. * Proxy routing supports long-running requests and streams with adjusted timeout handling. * Ingress publishing supports per-host or wildcard certificates and configurable certificate challenge settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
f7ee616f6c |
fix(linstor): rebase the snapshot restore patch on linstor-csi v1.13.2
The import block of pkg/client/linstor.go changed in v1.13.2, so the patch no longer applied and the linstor-csi image failed to build. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io> |
||
|
|
700600ee3c |
chore(cilium): drop externalIPs.enabled and nodePort.enabled
The vendored Cilium chart reads neither key: there is no externalIPs value upstream, and from the nodePort block the templates read only range, addresses, bindProtection, autoProtectPortRange, directRoutingDevice, enableHealthCheck, enableHealthCheckLoadBalancerIP and enableDynamicSourceLookup. Both features follow kubeProxyReplacement, which stays true, so the keys only misled readers into thinking they toggle anything. Fixes #4816 Assisted-by: LLM Signed-off-by: Nimesh Kulkarni <167794819+GitNimay@users.noreply.github.com> |
||
|
|
ba5948ed29 |
Merge branch 'main' into fix/linstor-csi-snapshot-restore-node
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
f61cfdf0b8 |
feat(bucket)!: add publicRead to serve a bucket without credentials (#5252)
<!-- Thank you for making a contribution! Here are some tips for you: - Use Conventional Commits for the PR title: `type(scope): description` - Types: feat, fix, security (a fix that comes through a security advisory), docs, style, refactor, perf, test, build, ci, chore - Scopes are not an exhaustive list — pick the most specific scope for the change and extend the list when a genuinely new area appears. Examples: - System components: dashboard, platform, operator, cilium, kube-ovn, linstor, fluxcd, cluster-api - Managed apps: postgres, mariadb, redis, kafka, clickhouse, virtual-machine, kubernetes - Development and maintenance: api, hack, tests, ci, docs, maintenance - Breaking changes: append `!` after type/scope (`feat(api)!: ...`) or add a `BREAKING CHANGE:` footer - If it's a work in progress, consider creating this PR as a draft. - Don't hesistate to ask for opinion and review in the community chats, even if it's still a draft. - Fixes merged to `main` reach the release lines the backport batch runs for automatically, so do not open backport PRs by hand: https://github.com/cozystack/cozystack/blob/main/docs/release/backports.md --> ## What this PR does Adds `publicRead` to the Bucket application. A bucket cannot serve its objects without a signature today: every BucketAccess issues a key, and those keys grant neither `WriteAcp` nor `PutBucketPolicy`, so `aws s3api put-bucket-acl --acl public-read` is refused and a tenant has no way to serve static assets (images, downloads) straight from a bucket. The only workaround is an operator running `weed shell` `s3.anonymous.set` by hand, which nothing reconciles and which outlives the bucket. With `publicRead: true` the chart renders one more BucketAccess, `<bucket>-public-read`, on a new `-public` BucketAccessClass whose `accessPolicy` is `public-read`. The class is added in the three places that define access classes: the Client topology, the per-storage-pool classes, and the vendored chart (through its existing `cosi-bucket-class-lock-readonly.patch`). The COSI driver handles the policy by adding `Read:<bucket>` to the gateway's `anonymous` identity and, on revoke, removing only that action, so turning the flag off or deleting the bucket closes it again without touching other public buckets. Anonymous callers can `GET`/`HEAD` objects at `<endpoint>/<bucket>/<key>`; listing and writes stay refused. A user named `public-read` would own the same BucketAccess name, so that combination fails to render with an explicit message rather than having two owners fight over one object. The seaweedfs pool name check now also reserves `public` and the `-public` suffix, next to the existing `-lock` and `-readonly`: a pool `<x>-public` would render a readwrite BucketAccessClass with the same name as pool `<x>`'s public-read class, and a pool `public` would take the instance's own `-public` class. This is a breaking change for an instance that already defines a pool with such a name: its seaweedfs release stops rendering with the pool name error. Pool keys are part of the volume server and PVC names, so renaming such a pool moves its data to new volumes; that migration is the operator's to plan before upgrading. **Known limitation until the next driver release.** On v0.5.0, revoking public read (turning `publicRead` off or deleting the bucket) can leave the bucket readable anonymously if an S3 gateway migrates `identity.json` while the revoke is in flight: the migrated `identities/anonymous.json` keeps `Read:<bucket>`, and SeaweedFS loads it over `identity.json` without ever repairing it. The fix is seaweedfs/seaweedfs-cosi-driver#22 (the revoke always writes `anonymous.json`, after the legacy file). The driver release carrying it will be pinned here if it lands before this PR merges, otherwise in a follow-up. Until then, an operator can check `s3.anonymous.list` in `weed shell` after a revoke and clear a leftover with `s3.anonymous.set -bucket <bucket> -access none`. **Driver: pins the upstream seaweedfs-cosi-driver v0.5.0.** The `public-read` policy merged upstream in seaweedfs/seaweedfs-cosi-driver#21 and v0.5.0 is tagged on that merge, so this PR moves the image pin from v0.4.0 (#5284) to v0.5.0 in `packages/system/seaweedfs/values.yaml`, the client-mode `.tag` file and `cosi_image_test.yaml`. An earlier revision of this branch built the driver in-tree while no release carried the policy; that build is gone, and the intermediate commits that added it are undone by the merge of `main`, so squashing leaves only the feature and the pin. v0.5.0 differs from v0.4.0 only by the `public-read` policy (seaweedfs/seaweedfs-cosi-driver#21) and its README note. Upstream documents one `public-read` BucketAccess per bucket as the supported shape, which is what the chart renders. Tested: new helm-unittest suites for the bucket app (default off, class name with and without storage pool, locked bucket, coexistence with users, the name collision), the seaweedfs extra chart (Client and storage-pool classes) and the vendored chart; they fail when the class suffix or the policy is removed. `helm unittest` passes on `packages/apps/bucket`, `packages/extra/seaweedfs`, `packages/system/seaweedfs` and `packages/system/bucket`, as do `test-guard-fail-closed` and `test-image-version`; `cosi_image_test.yaml` pins `ghcr.io/seaweedfs/seaweedfs-cosi-driver:v0.5.0`, which is published for amd64 and arm64. The anonymous-read mechanism itself was checked by hand on SeaweedFS 4.45 (`weed shell` `s3.anonymous.set -access Read`): anonymous `GET` returns 200 on both gateways, `ListObjects`/`ListObjectsV2` and `PUT` return 403, and the identity survives grants and revokes of regular BucketAccesses. The end-to-end path through the new driver has not run on a cluster yet. ### Screenshots No UI change. ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [ ] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [x] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: cozystack/terraform-provider-cozystack#80 - [ ] [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: Walked the trigger map against the diff: the only hit is the new field in `packages/apps/bucket/values.schema.json` (and `api/apps/v1alpha1/bucket/types.go`), which the Terraform provider models by hand. Follow-up filed as cozystack/terraform-provider-cozystack#80. The website's bucket page is hand-written and could mention the flag, but no listed trigger covers an added field, so it is left unticked. ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note feat(bucket): add `publicRead` to serve a bucket's objects without credentials at `<endpoint>/<bucket>/<key>`. Anonymous callers can read objects but cannot list the bucket or write to it. The COSI driver is bumped to seaweedfs-cosi-driver v0.5.0, which adds the `public-read` access policy. The seaweedfs pool names `public` and `*-public` are now reserved: an instance that already defines such a pool fails to render until the pool is renamed, which moves its data to new volumes. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Bucket configurations can enable anonymous reads of objects through the bucket endpoint. Anonymous access does not allow listing buckets or writing objects. * SeaweedFS provides public-read access classes across supported bucket configurations, alongside read-only and read-write access. * Added a retained bucket class with object locking and a 365-day compliance retention period. * **Documentation** * Added guidance for the `publicRead` setting, which is disabled by default. * **Updates** * Updated the SeaweedFS COSI driver to v0.5.0. Pool names `public` and names ending in `-public` are reserved. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
bf24d28fde |
fix(cozy-lib)!: refuse memory below 1Mi instead of rendering a few bytes (#5009)
## What this PR does `cozy-lib.resources.sanitize` now refuses a memory below 1Mi. The render stops with a message that names the value and asks for a unit. ```text memory (8) must be at least 1Mi. A value without a unit is read as bytes, so add the unit, such as 512Mi or 8Gi. ``` A quantity without a unit counts bytes, so `8` typed for 8Gi gave the pods a memory limit and request of 8 bytes, as described in #5004. The app schemas accept a bare number and the dashboard sends the field as typed, so nothing refused it before. Charts size their containers through `sanitize`, directly as etcd does or through `defaultingSanitize`, so the check covers all of them. The smallest preset is `t1.nano` at 128Mi, and 1Mi stays above any bare number someone would type for Mi or Gi. `0` and negative values are refused too. kubelet sets no cgroup memory limit when the limit is zero ([kuberuntime_container_linux.go L359-L374](https://github.com/kubernetes/kubernetes/blob/v1.37.1/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go#L359-L374)), so `memory: 0` removed the limit rather than sizing anything. `flatten`, which renders the tenant ResourceQuota, is not affected. A quota of 0 memory is a valid way to allow none, so `flatten` now calls the conversion part of `sanitize`, renamed `requestsAndLimits`, without the floor. cpu gets no floor, since a bare cpu number is cores and a zero cpu request is pinned by an existing test. This is marked breaking like #4569. A release with a memory below 1Mi, `0` included, rendered before and now fails until the value gets a unit. Fixes #5004 The new suite `packages/tests/cozy-lib-tests/tests/resources_memory_floor_test.yaml` has 16 cases, with a small template for `defaultingSanitize`. It refuses `"8"`, an unquoted `8`, `0`, `"1048575"`, `1023Ki`, `-1Gi` and `"8"` over `t1.nano`, and renders `1Mi`, an unquoted `1048576`, `512Mi`, `8Gi`, a map without memory, `t1.nano`, the legacy `nano`, `8Gi` over `t1.nano` and a tenant quota of 0 memory. - `helm unittest .` in `packages/tests/cozy-lib-tests`, with helm-unittest 1.1.2 as CI pins it, passes 84 of 84 in 9 suites, against 68 of 68 in 8 on main. With the template from main the 7 refusal cases fail and the other 9 pass. - Seven mutations of the change each turn at least one case red (no check, `le` for `lt`, a floor of 1M, `flatten` through the check, strings only, zero exempt, another message). - `hack/helm-unit-tests.sh` passes in all 106 chart directories, 549 suites and 4023 tests, against 547 and 3991 on main. The only difference per chart is cozy-lib-tests, which the sweep runs twice. - `bats` 1.14.0, the version CI pins, over the 34 `hack/*.bats` files that call `helm template` passes 282 of 283 on main and on this branch, with the same result for every test. The one failure, `a malformed package name fails before emitting YAML` in `hack/platform-packages_test.bats`, fails the same way on main on this machine. - A scratch chart calling `sanitize`, `defaultingSanitize` and `flatten` with 22 inputs gives the same results with Helm 3.17.3, 4.2.3 and 4.3.1, and every input that still renders gives the same output as on main. I have not run it on a live cluster. `_resources.tpl` on release-1.6 differs from main only in two `toFloat` suffixes, and that backport is a separate PR. ### Screenshots Not a UI change. ### Downstream repositories One cozy-lib template and its unittest chart. No values key, schema, default, README or package change, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(cozy-lib)!: a memory below 1Mi in an app's resources now fails the render with a message that asks for a unit. A number without a unit is read as bytes, so `8` meant as 8Gi gave the pods an 8 byte memory limit. `0` and negative values are refused as well. Tenant resource quotas are not affected. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Resource memory values below 1Mi now fail validation with a clear error. - Invalid memory overrides are rejected, including when presets provide defaults. - Valid memory values now produce consistent requests and limits, while resources without memory remain unchanged. - Quota configurations can still use a memory value of `0`. - **Tests** - Added coverage for memory validation, unit formats, presets, overrides, and quota behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
29e8522f4b |
fix(cozystack-basics): refuse a direct delete of a tenant namespace (#5011)
## What this PR does Fixes #5002. A DELETE of a tenant namespace is refused unless it comes from the identities that remove it on the normal path, and the denial says to delete the Tenant instead. The new ValidatingAdmissionPolicy in cozystack-basics matches DELETE of core namespaces, and its binding selects namespaces labelled `tenant.cozystack.io/tenant-root`. The tenant chart puts that label on every tenant namespace below tenant-root (`tenant.ancestorTenantLabels`, and migration 49 backfilled older ones). tenant-root itself has no such label and stays with `cozystack-no-delete-guardrail`. The `tenant-*` probe namespaces of the e2e suites carry only `namespace.cozystack.io/host` and are not selected either. Two groups pass. `system:serviceaccounts:cozy-fluxcd`, because helm-controller and its shards run as `flux` there, and a Tenant uninstall is helm-controller deleting the namespace after the pre-delete hook. `system:serviceaccounts:kube-system`, for the garbage collector following the ownerReference of a child namespace once its parent is gone. The namespace controller never sends a DELETE for a namespace, it updates `finalize`, so it is not affected (`pkg/controller/namespace/deletion` and `pkg/registry/core/namespace/storage` at v1.33.12 and v1.34.1). `system:masters` is not exempt, the same as with the no-delete guardrail. This is the denial kube-apiserver 1.35 returns. ``` namespaces "tenant-foo" is forbidden: ValidatingAdmissionPolicy 'cozystack-tenant-namespace-delete-policy' with binding 'cozystack-tenant-namespace-delete-policy' denied request: Namespace tenant-foo belongs to the Tenant foo in tenant-root. Delete the Tenant instead with kubectl delete tenants.apps.cozystack.io foo --namespace tenant-root. Deleting the namespace directly can remove the tenant etcd before the Kubernetes clusters that use it and leave the namespace stuck in Terminating. If the Tenant is already gone, remove the label first with kubectl label namespace tenant-foo tenant.cozystack.io/tenant-root- ``` There are a few limits. - The bypass is removing the label, like with the guardrail. That also takes the namespace out of the tenant-root egress policy and the dashboard tree, which only matters for a namespace that is about to go. - Migration 49 labelled every `tenant-*` namespace that existed when it ran, so a non-tenant namespace with such a name is refused too and needs the same label removal. - Because the garbage collector is exempt, a parent namespace whose label was removed and that is deleted with foreground propagation still cascades into its children directly. - A DELETE of a namespace that is already Terminating is answered before admission, so the policy does not see it. It changes nothing either. - A cluster that made helm-controller impersonate another account (`--default-service-account`, or `spec.serviceAccountName` on Tenant HelmReleases) would need that account allowed. Cozystack sets neither. - It does not change how Kamaji cleans up once the order is broken, which is the second idea in #5002. The helper rename in `external_tls_policy_test.go` (`loadPolicy(t, path)` and `compilePolicy`) is byte for byte the one in #2622, so the two merge in either order. Checked locally. - `go test ./pkg/registry/apps/application/ -run 'TestTenantNamespaceDeletePolicy|TestDatabaseExternalTLSPolicy' -count=1 -v` passes 4 tests, the new `TestTenantNamespaceDeletePolicy_Decisions` with 11 cases. `go test ./pkg/registry/... ./pkg/config/... ./pkg/cmd/server/...` passes in all 11 packages that have tests. - `helm unittest` in `packages/system/cozystack-basics` with helm-unittest 1.1.2 in docker passes 12 suites and 70 tests, against 11 and 66 on main. The new tests on main without the template fail, both Go tests and 4 helm tests in 2 suites. - 12 mutations of the template each fail a test. They exempt `system:masters`, drop either exempt group, select on the no-delete label, add UPDATE, always name tenant-root as the parent, drop the capability gate, label tenant-root, switch to Warn, switch failurePolicy to Ignore, drop the bypass from the message and drop the objectSelector. - The rendered policy, the guardrail and namespaces rendered from the tenant chart were applied to kube-apiserver v1.33.0, v1.35.0 and v1.36.2 from setup-envtest, 16 checks on each. Real and dry-run deletes by a cluster admin, by an OIDC user bound to cluster-admin and by a cozy-system and a tenant ServiceAccount are refused with 403. The flux and garbage collector identities get their delete accepted. tenant-root gets the guardrail's denial, and with the guardrail binding removed a dry-run delete of it goes through, so this policy does not select it. A `tenant-*` namespace without the label and a tenant namespace after its label is removed are accepted for deletion. With this binding removed, a dry-run delete by the cluster admin goes through. That harness is not part of the PR. - `hack/bats-no-negated-assert.bats`, `hack/bats-no-exit-trap.bats`, `hack/bats-runner-coverage.bats`, `hack/helmrelease-readiness.bats` and `hack/route-hostname-policy-version-coverage.bats` pass under `hack/cozytest.sh`. The new e2e case in `hack/e2e-install-cozystack.bats` creates an empty Tenant, checks that a server dry-run delete of its namespace is refused with the message, deletes the Tenant and waits for the namespace to go. It was not run here, there is no Cozystack cluster at hand. Its kubectl steps were run against the envtest apiserver 1.35, the selector and field selector read, the refused dry-run with the exact strings it greps for, and `kubectl wait --for=delete` on a namespace that is gone. The Chainsaw suites that delete Tenants, the gateway inheritance ones among them, go through the uninstall path as well. The release-1.6 backport is #5012. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: The trigger map was walked against the diff. It adds a policy and tests to cozystack-basics and an e2e case, and no entry covers that. The website docs do not tell users to delete a tenant namespace directly, and terraform-provider-cozystack deletes Tenants through the apps API. ### Release note ```release-note fix(cozystack-basics): refuse a direct DELETE of a tenant namespace unless it comes from helm-controller or the garbage collector, and point to deleting the Tenant instead, so a tenant namespace deleted by hand no longer gets stuck Terminating on Kamaji finalizers ``` |
||
|
|
6444b66881 |
fix(tcp-balancer): render the kubernetes and talos Service ports only with kubernetesAndTalos (#4965)
## What this PR does The tcp-balancer Service renders ports 6443 and 50000 inside a second `with .Values.httpAndHttps` block. The Deployment declares the `kubernetes` and `talos` container ports, and the HAProxy config binds the `kubernetes` and `talos` frontends, only under `with .Values.kubernetesAndTalos`. This PR gates those two Service ports on `kubernetesAndTalos` as well, a one-word change in `templates/service.yaml`. So with the default `httpAndHttps` every Service has four ports, two of them point at targetPort names no container declares, and the EndpointSlice has no port for them. With `external: true` the LoadBalancer Service carries them as well. The other way round, a release with `kubernetesAndTalos` and `httpAndHttps: null` gets no Service port for those frontends, while HAProxy listens on them. The block has been like this since the chart was added. Found while testing tcp-balancer on a v1.6.5 cluster. A TCPBalancer with `httpAndHttps` set and no `kubernetesAndTalos` got a ClusterIP Service with the ports `http:80`, `https:443`, `kubernetes:6443` and `talos:50000`, and its EndpointSlice listed only `http:8080` and `https:8443`. `kubernetesAndTalos` is not in `values.yaml`, `values.schema.json` or the README, so before choosing between gating the block and dropping it I checked whether the key can be set at all. The tcp-balancer `openAPISchema` declares no top-level `additionalProperties`, so `patchSpec` in `pkg/cmd/server/openapi.go` publishes `spec` with `x-kubernetes-preserve-unknown-fields`, and `convertApplicationToHelmRelease` passes `app.Spec` to the HelmRelease as its values. So the key reaches the chart through the apps API, and the Deployment, the ConfigMap and the existing `haproxy-config` suite already treat it as an input. Dropping the block would leave HAProxy listening on 6443 and 50000 with no Service port in front of them. Whether to document the key is a separate question and not part of this PR. On upgrade, a release on the default values loses the two ports that had no endpoints, and a release with `kubernetesAndTalos` alone gains them. The Deployment and the ConfigMap render the same as before, so the pods do not roll. A release that sets both keys renders exactly as before. `tests/service_test.yaml` has three cases, and each pins the whole `spec.ports` list of the Service together with the container ports of the Deployment, so every `targetPort` is checked against a port the Deployment declares. The default values give only 80 and 443, `kubernetesAndTalos` with `httpAndHttps: null` gives only 6443 and 50000, and both keys together give all four. Against the template on main the first two cases fail and the third passes, 2 failed and 10 passed in total. Dropping the block instead of gating it fails the second and the third case, and moving the Deployment's kubernetes and talos ports under `httpAndHttps` fails the first two on the Deployment side. `helm unittest` passes 12 of 12 tests in 3 suites, against 9 in 2 suites on main, with helm-unittest 1.1.2 as CI pins it. `helm template` renders the whole chart for the default values, `external: true`, `kubernetesAndTalos` alone and both keys, and the only difference from main is in the Service ports. I have not run the change on a live cluster. The template is the same on release-1.6 and release-1.7. The commit cherry-picks onto release-1.6 without conflicts, and that backport is a separate PR. ### Screenshots Not a UI change. ### Downstream repositories One template line and a test suite in `packages/apps/tcp-balancer`. No values, schema, README, defaults, Service name or `ApplicationDefinition` change, and neither the website nor the Terraform provider mentions `kubernetesAndTalos`, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(tcp-balancer): the Service now publishes ports 6443 and 50000 only when kubernetesAndTalos is set, like the Deployment and the HAProxy config. Before, every tcp-balancer Service carried both ports with no container port behind them, on the LoadBalancer too when external was enabled, and a release with kubernetesAndTalos but without httpAndHttps had no Service port for them. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Kubernetes and Talos service ports are now rendered when their configuration is enabled, independently of the HTTP/HTTPS configuration. * **Tests** * Added coverage for default HTTP/HTTPS ports, Kubernetes/Talos ports configured alone, and all four ports configured together. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
fa09cdc184 |
fix(keycloak, foundationdb): apply operator CRD updates on upgrade (#4946)
## What this PR does The generated HelmReleases leave `spec.upgrade.crds` unset unless the PackageSource sets `upgradeCRDs`, so helm-controller never replaces a CRD that a chart ships in `crds/`. keycloak-operator and foundationdb-operator ship their CRDs that way and set no policy. On a v1.6.4 cluster that came through earlier releases, the CRDs of both operators were older than the ones in the v1.6.4 charts. The v1.25.0 ClusterKeycloakRealm schema has no `spec.sessions`, `spec.login` or `spec.organizationsEnabled`, so the apiserver dropped the session settings keycloak-configure sets and the operator never applied them to the realm. Keycloak also rejected the dashboard KeycloakClient with HTTP 400 on that cluster, and replacing the 17 CRDs from the charts and restarting keycloak-operator cleared it. This opts both PackageSources into `upgradeCRDs: CreateReplace`, the policy mongodb-operator, redis-operator and velero already use, and pins it with a platform test for each. The keycloak-operator change is not purely additive. v1.32.0 drops the `realm`, `targetRealm` and `keycloakOwner` fields that v1.25.0 marked deprecated and requires `realmRef` and `keycloakRef` instead. Every Keycloak object the platform renders already uses the refs, and each of the 14 CRDs keeps its single version, so the replace loses nothing the platform relies on and drops no stored version. A hand-made object that still uses a deprecated field would lose it on its next write, and that write needs the ref. The foundationdb-operator CRDs only add fields from v2.13.0 to v2.30.0, plus a pattern on `perpetual_storage_wiggle_locality`, which the platform does not set. helm-controller applies the policy only when it upgrades a release, and it upgrades only when the release artifact or its values change. A PackageSource edit changes neither. The PR therefore also gives the keycloak-operator package a helm-unittest suite, which pins the realm fields keycloak-configure sets against the ClusterKeycloakRealm CRD the chart ships and changes the keycloak-operator artifact, so the CRDs are replaced on the upgrade that brings this change even where nothing else in the package changes, as on a backport to release-1.6. The platform release writes the new PackageSource in the same apply that moves `cozystack-packages` to the new revision, so the policy should reach the HelmRelease before the new keycloak-operator artifact does. The foundationdb-operator package does not change here, so its CRDs are replaced at the next change to that package, and main already carries one since v1.6.5. Objects written while the CRDs were stale get the pruned fields back only when their chart applies them again. For the cozy realm that is the next keycloak-configure upgrade. On main it comes with the same platform upgrade, since keycloak-configure changed after v1.6.5, and its HelmRelease depends on the keycloak-operator one through the oidc variant. On a branch where keycloak-configure does not change, the realm keeps its current session limits until it does or until that release is forced to upgrade. #4901 adds the same `upgradeCRDs: CreateReplace` to the foundationdb-operator PackageSource as part of the FoundationDB backup work, and it changes the foundationdb-operator package as well. The foundationdb commit here is separate from the keycloak one and does not depend on it, so it can be dropped if #4901 lands first. The other packages that ship CRDs only in `crds/` and set no policy are bootbox, clickhouse-operator, clustersecret-operator, cozystack-scheduler, external-dns, grafana-operator, kafka-operator and snapshot-controller. None of their CRDs changed since v1.0.0, or since the package was added, apart from description text in external-dns, so no cluster is behind on them today. kafka-operator gets CreateReplace with the Strimzi move in #4900. gpu-operator replaces its CRDs with its own pre-upgrade Job, and the remaining packages render their CRDs from templates or leave them to an operator. Each of the eight will need the same review and opt-in the next time its CRDs change. `make -C packages/core/platform test` passes with 58 suites and 287 tests, and `make -C packages/system/keycloak-operator test` passes. With either PackageSource reverted to main, its suite fails with `unknown path spec.variants[0].components[0].install.upgradeCRDs`. With the v1.25.0 ClusterKeycloakRealm CRD in the chart, the keycloak-operator suite fails all four assertions. The full `hack/helm-unit-tests.sh` sweep passes. ### 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: Two PackageSources under `packages/core/platform/sources/` gain an install option, three test suites are new, and `packages/system/keycloak-operator/Makefile` gains the same `test` target other packages have. Platform `values.yaml`, variants, bundles, CRDs, `hack/` and the installer are untouched. The website's `development.md` does not describe per-package test targets, so the Makefile change needs nothing there, and no website page documents a manual CRD replace for these operators. ### Release note ```release-note fix(keycloak, foundationdb): keycloak-operator and foundationdb-operator now replace their CRDs on upgrade. Clusters upgraded from before v1.2.0 kept the v1.25.0 keycloak-operator CRDs, under which the apiserver dropped the Keycloak realm session settings and Keycloak could reject the dashboard client, and clusters upgraded from before v1.6.0 kept the v2.13.0 foundationdb-operator CRDs. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Existing FoundationDB and Keycloak installations can now upgrade their custom resource definitions with replacement behavior, including updates to schemas and removal of deprecated fields. * **Tests** * Added checks for the operator upgrade settings and Keycloak CRD schema fields. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
51282a1243 |
fix(piraeus-operator): keep the LINSTOR error-report alerts quiet when the controller pod moves (#4963)
## What this PR does `linstorSatelliteErrorRate` fires for every node that has any old LINSTOR error report whenever the LINSTOR controller pod moves to another node, and it keeps firing for 15 minutes. `linstor_error_reports_count` is exported by the controller, so its series carry the controller pod's `instance` and `controller_node`, and a moved pod starts new series that hold the existing counts. VictoriaMetrics' [`increase()`](https://docs.victoriametrics.com/victoriametrics/metricsql/#increase) starts from the last sample before the window, and when a series has none, [`rollupDelta`](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/v1.136.0/app/vmselect/promql/rollup.go#L1859-L1901) counts it from zero whenever its first value is below ten times the next change plus one. That is the case the docs describe as `increase` ignoring "the first value in a series if it is too big" under [`increase_pure`](https://docs.victoriametrics.com/victoriametrics/metricsql/#increase_pure), and report counts are never that big, so every new series counts all of its reports as new. The `up` guard from #2265 matches `on(instance, job)`, and the new controller is up, so it lets them through. Seen on a v1.6.5 cluster with VictoriaMetrics v1.136.0. During the upgrade the controller pod moved to another node, and the alert fired for all three nodes with values 1, 1 and 2 for 15 minutes, while `linstor error-reports list --since 1h` was empty and the four reports that exist were weeks old. The day before, it fired the same way for about 15 minutes when only the `cluster` external label of vmagent changed. A satellite coming back to the metric does the same. In LINSTOR v1.33.3 the controller asks every satellite for its reports on each scrape and leaves out any satellite that is not connected ([`prepareErrRequestApi`](https://github.com/LINBIT/linstor-server/blob/v1.33.3/controller/src/main/java/com/linbit/linstor/core/apicallhandler/controller/CtrlErrorListApiCallHandler.java#L240-L259)), so after a node reboot or any other disconnect longer than five minutes the satellite's old count is counted again. Both rules now take the count per `hostname`, hold the last value for an hour with `last_over_time`, and run `increase()` over that as a one-minute [subquery](https://docs.victoriametrics.com/victoriametrics/metricsql/#subqueries), whose inner points VictoriaMetrics aligns to that step. Keyed on `hostname`, a moved controller or a changed label continues the same series, and the hold bridges a disconnect or a slow controller start of up to an hour. The `up` guard matches `on()`, since the aggregated result has no `instance` any more. A new report still fires with the same value and stays for 15 minutes, at most a minute later than before because of the one-minute step. The alerts now carry `hostname` and `severity`, and no longer the controller's `instance`, `job` and `controller_node`, the `module`, or the external labels of the scrape. `linstorControllerErrorRate` gets the same form. Its `hostname` is the controller pod name and the piraeus controller keeps its reports in an [`emptyDir`](https://github.com/piraeusdatastore/piraeus-operator/blob/v2.10.2/pkg/resources/cluster/controller/controller-deployment.yaml#L111-L112), so a new pod starts with no reports and a move alone does not trip it, but a label change does whenever the controller has reports. A gap longer than the hour is not covered. After it the series starts over, and as before the `up` guard holds the alert back only if the controller target recorded failed scrapes during the gap. I checked it against the stored metrics of the cluster above with read-only queries to vmselect. Over the upgrade the current expression returns the three nodes from 15:45:30 to 16:00:00 UTC at a 30-second step, the same interval as vmalert's `ALERTS` series, and over the label change from 20:27:30 to 20:42:00. The new expression returns nothing over both windows, and without `> 0` it returns each of the three nodes with 0 at every step, 88 and 121 points. The same storage has six gaps of 8 to 113 minutes over one night with no failed scrape recorded in them. Replaying vmalert's instant query of the `increase()` part every 30 seconds in the 154 evaluations after those gaps, the current expression returns at least one node in 99, the `hostname` key without the hold in 84, and the new expression in 30, all of them after the 113-minute gap. Retention there does not reach back to a real new report, so the firing side is covered by the tests. `hack/linstor-error-report-alerts.bats` replays both rules through `vmalert-tool` v1.136.0, pinned by digest, which is the VictoriaMetrics release victoria-metrics-operator v0.68.4 [deploys by default](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L38), with 30-second samples and 15-second evaluations like the platform's vmagent and vmalert. The suite needs docker, like the migration suites, and only the image pull touches the network. `hack/testdata/linstor-error-report-alerts/unittest.yaml` has 20 cases in five groups, which cover a controller move followed by a new report, a changed external label for both rules, one satellite away for 40 minutes and one that comes back with a new report, a new report and a first report on a node for both rules, and a controller that cannot be scraped for 70 minutes. Against the rule on main 13 cases fail, 9 of them because old reports fire again after the move, the label change or the disconnect, and the other 4 on the label set alone, since the current alerts carry the controller's labels. Each of seven mutations of the new expressions turns at least one case red, namely no hold, a 15-minute hold, the guard on `instance`, no guard, the key on `hostname` and `instance`, the key on `hostname` and `cluster`, and the controller rule as on main. With Bats 1.14.0 at the commit CI pins, the new suite with `alert-severity-contract`, `bats-strict-setup`, `bats-no-negated-assert`, `bats-no-exit-trap`, `bats-runner-coverage` and `image-pin-consistency` passes 74 of 74, and `helm template` renders the same 15 rules as main. I have not run the new rules in vmalert on a live cluster. The commit cherry-picks onto release-1.7 as is, and the suite passes there. On release-1.6 it applies without conflicts, but that branch runs `hack/*.bats` through `hack/cozytest.sh` and has no `hack/test_helper.bash`, so the suite there has to drop its `load test_helper` line. ### Screenshots Not a UI change. ### Downstream repositories A rule file under `packages/system/piraeus-operator/alerts/`, a new Bats suite under `hack/` and its test data. No values, schema, README, image, make target or `ApplicationDefinition` change, and the website does not mention these rules or the metric, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(piraeus-operator): the LINSTOR error-report alerts no longer fire on old reports when the LINSTOR controller pod moves to another node, when an external label of the scrape changes, or when a satellite reconnects within an hour. They now count reports per node, and their alerts carry the node's hostname instead of the controller pod's instance, job and controller_node labels. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved LINSTOR controller and satellite error alerts to account for recent error reports over a 15-minute window, even when metrics are intermittent or scrape labels change. * Updated alert matching to better handle controller moves between nodes and satellites that disappear from metrics while disconnected. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
ea4968cf46 |
fix(apps): keep Job and CronJob names within the Kubernetes limits (#4945)
## What this PR does The apps API admits release names of up to 53 characters, the release prefix included (less for Kafka and Kubernetes, which cap their own names). Kubernetes copies a Job name into the `job-name` label of its pods, and a label value takes at most 63 characters, so the apiserver refuses a Job with a longer name. A CronJob name is refused over 52 characters, because the controller names each Job it starts `<cronjob>-<timestamp>`. I rendered every Job and CronJob in `packages/apps` and `packages/extra` with the longest release name each application admits, and eight of them go over. | Application | Object | Name | Longest on main | After | | --- | --- | --- | --- | --- | | bucket | post-delete Job | `<release>-cleanup-acme` | 66 | 63 | | qdrant | post-delete Job | `<release>-qdrant-cleanup` | 68 | 63 | | kafka | pre-install and pre-upgrade Job | `<release>-kafka-migration` | 66 (release capped at 50) | 63 | | vm-disk | resize Job, rendered when the disk grows | `<release>-volume-resize-hook` | 72 | 63 | | vm-instance | update Job and the `app` label of its pod | `<release>-update-hook` | 65 | 63 | | mariadb | backup CronJob | `<release>-backup` | 60 | 52 | | clickhouse | legacy backup CronJob | `<release>-backup` | 60 | 52 | | tenant | pre-delete Job in `cozy-system` | `<tenant namespace>-cleanup` | 71 (nested namespace of 63) | 63 | Counted in characters of the application name, a Kafka of 42 to 44 cannot be installed today, a VMDisk of 37 or more cannot grow, and a VMInstance of 40 or 41 cannot take an instance type, profile or external change. Deleting a Bucket of 44 or more or a Qdrant of 42 or more fails in the post-delete hook. With the backup CronJob enabled, a MariaDB of 38 or more and a ClickHouse of 35 or more fail the whole release. A nested tenant whose namespace is longer than 55 characters cannot be deleted. The Jobs of bucket, qdrant, kafka, vm-disk and vm-instance are now named `printf "%s-<suffix>" .Release.Name | trunc 63 | trimSuffix "-"`, and vm-instance uses the same value for the pod label. A release name is never longer than 53, so only the fixed suffix is cut, and a brute-force check over every pair of release name lengths found no two release names that render the same Job name. A plain cut to 52 would reach into the release name of a CronJob, and two 53-character names that differ in the last character would share one. So a CronJob name that does not fit becomes the release name cut to 38 characters, the first six hex characters of its sha256 and `-backup`, the shape #4133 gave the ClickHouse Keeper name. The tenant cleanup Job takes the same form with the namespace cut to 48, because it runs in `cozy-system` next to the cleanup Job of every other tenant. There a plain cut gives a parent and a child named `clea` the same name, and the child's `before-hook-creation` would delete the parent's Job while it runs. Names that fit render exactly as before. The hook documents rendered from main and from this branch with the short release names the tests use are identical in all eight charts. A name that did not fit never produced an object, so nothing is renamed on upgrade. The ServiceAccounts, Roles and RoleBindings of these hooks keep their names, since they have no such limit, so the ones a pre-install hook left behind are replaced rather than orphaned. Helm runs the delete hooks stored with a release, so an existing Bucket, Qdrant or tenant picks up the fix with its next upgrade. Every other Job and CronJob fits at the longest name. The cleanup Jobs of clickhouse, harbor, mariadb and opensearch and the Kafka pre-delete Job reach 61, the Postgres init Job 62, and the Kubernetes and KubernetesNodes Jobs either stay under 63 or already cut their names. The etcd and monitoring modules require their chart name as the release name, and the gateway and seaweedfs cleanup Jobs reach 61. Each of the eight charts gets a new helm-unittest suite. It pins a short name, a name that lands exactly on the limit and the longest admitted name, a cut that would end in a dash wherever one can happen, and for the hooks the unchanged ServiceAccount and RBAC names. The CronJob suites also pin two 53-character names that differ in the last character, and the tenant suite pins the parent and child pair. Against the templates on main, 18 of the 41 new cases fail, every one with a name over the limit. With the hash forms replaced by a plain cut, the tenant parent and child both render `tenant-abcdefghijklmnopqrstuvwxyz-0123456789abcdefghijklmn-clea` and the two MariaDB names both render `mariadb-abcdefghijklmnopqrstuvwxyz0123456789abcdefgh`. `hack/helm-unit-tests.sh` passes over all 106 packages with tests. The Bats files that exercise these hooks and charts (`app-cleanup-hooks_test`, `kafka-migration-hook`, `kafka-pre-delete-hook`, `tenant-pre-delete-hook`, `check-hook-request-timeout`, `pod-label-census_test`, `mariadb-first-boot-waits`, `check-render-matrix`) give 96 ok on main and on this branch. `make generate` with cozyvalues-gen v1.7.0 in the eight packages changes nothing. A local kube-apiserver v1.35.0 refuses the longest name each chart renders on main, with `must be no more than 63 bytes` on the job-name label or `must be no more than 52 characters` on the CronJob, and creates the name from this branch. For vm-disk and vm-instance, whose hooks render only after a live lookup, that check used a Job with the same name and labels. This is related to #4875 but does not depend on it. #4875 adds a cozy-lib cleanup Job and cuts its name to 63 the same way, while this PR covers the Jobs already on main. Neither needs the other, and the two merge cleanly. ### Screenshots Not a UI change. ### Downstream repositories Templates and tests only. No values, schema, README, defaults, `ApplicationDefinition`, Secret or Service name changes, and none of the changed Job or CronJob names appears in the website, the Terraform provider, the Ansible collection or the other repositories on the list. - [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(apps): Job and CronJob names now fit the Kubernetes limits for the longest application names. A Kafka with a name of 42 to 44 characters can now be installed, long VMDisk and VMInstance names no longer fail a resize or an instance type change, long Bucket and Qdrant names and long nested tenant namespaces no longer fail deletion, and long MariaDB and ClickHouse names no longer fail the release with the backup CronJob enabled. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Cleanup, migration, resize, and update Jobs now use names that fit Kubernetes naming limits, including for long release or tenant names. * ClickHouse and MariaDB backup CronJobs now use names within Kubernetes’ length limit. Longer names are shortened with a hash suffix to help distinguish them. * Short names and names at the supported limit retain their existing naming format. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
868b97dbe6 |
fix(kubevirt): let tenant admins upload a VMDisk image with virtctl (#5114)
## What this PR does A VMDisk created with `source: upload` waits in `UploadReady` for an image, but no tenant role can fill it. `virtctl image-upload` reads the disk PVC and CDI's PVC Prime and requests an upload token, and the tenant roles grant neither `get` on persistentvolumeclaims nor `create` on `upload.cdi.kubevirt.io/uploadtokenrequests`, so the command stops on a forbidden PVC read. `cozy:tenant:admin:base` now grants both. Tenant admins and super-admins get them in their own namespaces through the existing RoleBindings, the use and view tiers do not. Reading the DataVolume is already granted for the disk's own name by the vm-disk chart's dashboard role, so no DataVolume rule is added. The vm-disk notes print the command with `--no-create`, because the chart has already created the DataVolume, and the security self-assessment and threat model list the new grants. This is the RBAC part of #3847, split out so tenants can upload while the console upload panel and the upload proxy certificate stay in review there. The rules, their tests, the notes change and the docs lines are from @myasnikovdaniil, who is co-author on the commit. Checked live on a cluster with KubeVirt v1.8.4 and CDI v1.66.1, with virtctl v1.8.4 impersonating a user in the `<tenant>-admin` group. - With the stock roles `virtctl image-upload dv vm-disk-<name> --no-create` fails with `persistentvolumeclaims "vm-disk-<name>" is forbidden`. - With exactly these two rules added as a temporary Role, the same command reads `prime-<uid>`, uploads a 16 MiB image and the DataVolume reaches `Succeeded`. `get` on the DataVolume came from the vm-disk dashboard role. - The upload went through a port-forward to `cdi-uploadproxy` with `--insecure`. A trusted certificate on the published proxy is the other half of #3847 and is not changed here. Unit tests with `helm unittest` 1.1.2, the version CI pins. `packages/system/cozystack-basics` passes 72 of 72, against 66 on main, and `packages/apps/vm-disk` 117 of 117, against 116. Removing the upload token rule fails one case, and dropping `--no-create` from the notes fails one case. Fixes #3759 ### Screenshots Not a UI change. ### Downstream repositories Walked the trigger map in `docs/agents/contributing.md` against the diff. Two tenant RBAC rules, their tests, the vm-disk notes and two docs files. No values key, schema, default, README or package change, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(kubevirt): tenant admins can upload an image into a VMDisk created with source upload using virtctl image-upload. The tenant admin and super-admin roles get get on persistentvolumeclaims and create on upload.cdi.kubevirt.io/uploadtokenrequests, and the vm-disk notes print the command with --no-create. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Tenant administrators can now upload images into existing VM disks. * **Improvements** * The displayed upload command now explicitly targets the release namespace and avoids creating a new disk. * **Documentation** * Security guidance now clarifies the access needed for uploads and notes that persistent-volume permissions remain limited by namespace scope. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
df42104b13 |
fix(seaweedfs, cozy-lib): cap the Go heap so components survive their memory limit (#4234)
<!-- 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 Every SeaweedFS component is a Go binary running under a cgroup memory limit, and none of them set `GOMEMLIMIT`. The collector then works from `GOGC` alone, which is a target relative to the live heap with no absolute ceiling, so a burst of allocation grows the heap past the limit and the kernel kills the container. This is not a leak. On the cluster where it showed up, the S3 gateway held 6.4 GiB of `heap_sys` against an 8 GiB limit while `heap_inuse` was 389 MiB: the container was killed over memory the runtime was holding and not using. Ten kills in seven days, each one an interruption of the object store every tenant writes its backups to. Raising the limit does not help, because nothing bounds the growth; it only moves the ceiling the heap climbs to. This PR adds a `cozy-lib.resources.goMemLimit` helper next to the existing `javaHeap` one and wires it into the master, volume, filer and s3 components and into every volume pool and zone, each sized from the memory limit already computed for it. Pools need their own value because the subchart merges `volume` into every entry of `volumes`: without one, a `t1.nano` pool would inherit the value sized for the default volume's 512Mi limit, above its own 128Mi. The value is 75% of the limit, the same fraction `javaHeap` uses for the JVM; the remaining quarter covers what `GOMEMLIMIT` does not account for, goroutine stacks and mmap'd regions among them. The lifecycle admin and worker run the same binary under limits the parent chart does not set (256Mi and 512Mi in `packages/system/seaweedfs/values.yaml`), so their value is pinned next to those limits at the same 75%: 192MiB and 384MiB. A limit under 4/3 Mi (1398102 bytes) floors to `0MiB`, which Go accepts and then collects almost continuously, so the helper fails the render instead. The upstream chart already supports `extraEnvironmentVars` on every one of these components, so nothing had to change there. No values key is added, so this needs no configuration and changes no public schema. Tested with `helm unittest`: a suite on the seaweedfs package asserts the value tracks the memory limit rather than a fixed string, for the default volume, Simple pools, MultiZone zones and zone pools; the system seaweedfs suite asserts the admin and worker env; and a helper suite in `cozy-lib-tests` pins the unit grammar and the rejection of a zero value. Reverting each fix makes its suite fail. ### Screenshots <!-- REQUIRED for UI changes: attach screenshots or screen recordings demonstrating the visual impact of your changes. PRs with UI changes without screenshots will not be merged. --> ### Downstream repositories <!-- Cozystack is upstream for repositories that are NOT kept in sync with it automatically, and nothing in CI compares the two sides, so a change here can break them silently. Which change forces what, and which file to touch, is the trigger map in docs/agents/contributing.md under "Downstream Repositories". Walk it before you tick anything. IF YOU ARE AN AI AGENT OR AN LLM, THIS IS PART OF THE TASK, NOT A FORM TO FILL IN: 1. Walk the trigger map against the actual diff of this PR, file by file. Do not decide from the PR title or from your memory of what you changed. 2. For every repository you tick, open the follow-up PR there and link it on the same line. A ticked box with no link claims work that does not exist, which is worse than an empty box. Search that repository for an open PR or issue covering it first, and link that instead of filing a duplicate. 3. When the follow-up is out of scope, or needs a decision that is not yours to make, open an issue in that repository instead, link that, and say so in the PR body. Do not push a speculative PR into another repository just to fill a line here. 4. Do not tick "No downstream repository is affected" to make the checklist go away. If you are unsure, leave every box empty and say so in the PR body, so a human decides. --> - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note <!-- Write a release note: - Explain what has changed internally and for users. - Start with the same `type(scope):` prefix as in the PR title - Follow the guidelines at https://github.com/kubernetes/community/blob/master/contributors/guide/release-notes.md. --> ```release-note fix(seaweedfs): set GOMEMLIMIT on master, volume (and each pool and zone), filer, s3 and the lifecycle admin and worker so the Go runtime collects before the container hits its memory limit instead of being OOM-killed ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * SeaweedFS master, volume, pool, zonal volume, filer, and S3 workloads now receive a Go memory limit set to 75% of their configured memory limit. * Pool workloads use their own resource settings when provided, falling back to the default volume preset when needed. * SeaweedFS admin and worker components now have Go memory limits aligned with their configured memory limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
4fa6bfe30b |
feat(monitoring): alert when pods of one workload share a node (#4993)
## What this PR does On three 3-node clusters running v1.6.4 and v1.6.5 we found a tenant etcd with two of its three members on one node, a tenant Redis with two of its three Sentinels on the node that also ran the master, and several VictoriaMetrics and VictoriaLogs pairs (vmstorage, vmselect, vmalertmanager, vlstorage) sharing a node. Nothing alerted. Losing one of those nodes would have cost the etcd or Sentinel quorum, or both copies of a storage tier. Spread constraints keep new pods apart once they are in place (#4986 for etcd, #4989 for monitoring, #4990 for Redis), but a placement that already exists, or that comes from a soft rule or a drain, stays as it is, because the scheduler does not move running pods. This adds `PodReplicasColocated`, a warning in a new `workload-placement` group under `packages/system/monitoring-agents/alerts/`. It fires when two or more running pods of one StatefulSet, ReplicaSet, CNPG `Cluster` or `StrimziPodSet` have been on one node for an hour while the cluster has at least as many schedulable nodes as the workload has running pods, so five replicas on three nodes stay quiet. The alert carries `cluster`, `namespace`, `owner_kind`, `owner_name` and `node`, plus the `severity`, `exported_instance` and `service` labels the other platform alerts set, and its value is the number of pods on that node. DaemonSets, Jobs and every other owner kind are not in the list, so a DaemonSet surge pod next to its predecessor does not count. etcd-operator gives every member pod its own `EtcdMember` as controller owner ([etcdmember_controller.go#L546](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L546)), so grouping by owner would see one pod per group. Members get their names from `GenerateName: <cluster>-` ([etcdcluster_controller.go#L434](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L434), [#L839](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L839)), and members adopted from the old StatefulSet keep names like `etcd-0` ([adopt.go#L103](https://github.com/cozystack/etcd-operator/blob/v0.5.6/internal/migrate/adopt.go#L103)). The rule drops the last dash-separated part of the member name and reports the group as `EtcdCluster <name>`. With the etcd package that is one group per tenant namespace, and two etcd clusters in one namespace would still be told apart. CNPG instance pods carry a controller reference to their `Cluster` ([cluster_create.go#L1580](https://github.com/cloudnative-pg/cloudnative-pg/blob/v1.30.0/internal/controller/cluster_create.go#L1580)), and Strimzi pods one to their `StrimziPodSet` ([StrimziPodSetController.java#L369](https://github.com/strimzi/strimzi-kafka-operator/blob/0.45.1-rc1/cluster-operator/src/main/java/io/strimzi/operator/cluster/operator/assembly/StrimziPodSetController.java#L369)). Owner and node both come from `kube_pod_info`. kube-state-metrics fills `created_by_kind` and `created_by_name` from the controller owner reference and `node` from `spec.nodeName` ([pod.go#L638-L653](https://github.com/kubernetes/kube-state-metrics/blob/v2.15.0/internal/store/pod.go#L638-L653)). `kube_pod_owner` and `kube_pod_status_phase` have no node label of their own, and the kube-state-metrics scrape adds `node` from `__meta_kubernetes_pod_node_name` with `honorLabels: true` (`templates/kube-state-metrics-scrape.yaml`), so on those series `node` is the node of the kube-state-metrics pod. The test data keeps that label on the phase series. A pod counts while `kube_pod_status_phase{phase="Running"}` is 1, so a Failed or Pending pod on the same node does not. `kube_pod_labels` does carry every pod label here (`--metric-labels-allowlist=pods=[*]`), but the rule does not depend on it. A node counts as schedulable unless it has a `NoSchedule` or `NoExecute` taint. A cordon shows up as the `node.kubernetes.io/unschedulable:NoSchedule` taint ([node_lifecycle_controller.go#L549-L555](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/nodelifecycle/node_lifecycle_controller.go#L549-L555)), and not ready and unreachable nodes get theirs from their conditions ([#L87-L99](https://github.com/kubernetes/kubernetes/blob/v1.33.12/pkg/controller/nodelifecycle/node_lifecycle_controller.go#L87-L99)), so one clause covers all three, and a tainted control plane does not count either. Pods that a drain had to put together on the remaining nodes therefore stay quiet while the node is out, and the hour starts once it is back. The alert waits an hour. A replacement pod runs next to its terminating predecessor only for the predecessor's grace period, and node maintenance takes the drained node out of the count, while a placement that has held for an hour does not fix itself. The alert is about a risk rather than an outage, so the wait costs nothing. The VMAlert sets both `remoteWrite` and `remoteRead`, so the pending state survives a vmalert restart ([vmalert docs](https://docs.victoriametrics.com/victoriametrics/vmalert/#alerts-state-on-restarts)). Not covered are workloads that run one pod per owner, such as ClickHouse with one StatefulSet per replica ([patterns.go#L45-L53](https://github.com/Altinity/clickhouse-operator/blob/release-0.25.2/pkg/model/chi/namer/patterns.go#L45-L53)) and the KubeVirt VMs behind a tenant Kubernetes node group. They would need grouping by pod labels, which this rule avoids. The node count is cluster-wide, so a workload that a node selector or affinity restricts to fewer nodes than it has pods fires too. `hack/workload-placement-alerts.bats` takes `.spec` of the VMRule and replays it through `vmalert-tool` v1.136.0 pinned by digest, the release vm-operator v0.68.4 deploys by default ([config.go#L38](https://github.com/VictoriaMetrics/operator/blob/v0.68.4/internal/config/config.go#L38)) and the same image #4963 and #4985 use. `hack/testdata/workload-placement-alerts/unittest.yaml` has 13 cases with 24 checks. Two of three StatefulSet pods on one node fire at 61 minutes and not at 59, with labels and annotations pinned. Spread pods, five ReplicaSet pods on three nodes, a DaemonSet surge pod, two pods of one Job, a Failed pod next to a running one, and one pod each in two clusters that share workload and node names stay quiet. etcd members fire as one `EtcdCluster` per namespace, for generated and adopted member names. A replacement pod next to its terminating predecessor for twenty minutes stays quiet, and the same overlap held past the hour fires and resolves when it ends. A cordoned node keeps the alert quiet until it is uncordoned, and a node with unreachable taints keeps it quiet throughout. ReplicaSet, CNPG `Cluster` and `StrimziPodSet` pods fire with their owner kind. ```console $ bats hack/workload-placement-alerts.bats 1..1 ok 1 workload placement alerts pass their vmalert-tool cases ``` With the expression replaced by one that never fires, the suite prints `not ok 1` and vmalert-tool reports 5 of the 24 checks, which are all the checks that expect an alert. On main, where the rule file does not exist, the suite fails as well. Each of these changes to the rule fails at least one check, with the number of failing checks in brackets. `for: 15m` (5), no phase filter (1), no node count (6), no `cluster` label (6), DaemonSet and Job in the kind list (3), no taint clause (4), `<` instead of `<=` (5), etcd members grouped per member (1). With Bats 1.14.0 at the commit CI pins, the suite passes together with `alert-severity-contract`, `bats-strict-setup`, `bats-no-negated-assert`, `bats-no-exit-trap`, `bats-runner-coverage`, `bats-runner-contract`, `image-pin-consistency` and `check-commit-trailers`, 109 of 109, and the severity contract lists the new alert as `warning`. helm-unittest 1.1.2, the version CI pins, passes the monitoring-agents chart with 19 of 19 tests in 6 suites, and `helm template` with Helm 3.17.3 renders the VMRule the same as the file. Like the migration suites the new suite needs docker, and only the image pull touches the network. I have not run the rule in vmalert on a live cluster. On release-1.6 kube-state-metrics 2.15.0, its scrape config, the alerts template, the VMAlert and vm-operator v0.68.4 are the same, and etcd-operator v0.5.5 and CNPG 1.28.2 set the same owners and member names. The new files apply there without changes. That backport is a separate PR with one more commit that drops the `load test_helper` line, because release-1.6 runs `hack/*.bats` through `hack/cozytest.sh`. ### Screenshots Not a UI change. ### Downstream repositories A new alert file under `packages/system/monitoring-agents/alerts/`, a Bats suite under `hack/` and its test data. No values, schema, README, image or `ApplicationDefinition` change, and the website does not list platform alerts by name, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note feat(monitoring): new warning alert PodReplicasColocated fires when two or more running pods of one StatefulSet, ReplicaSet, CNPG Cluster, StrimziPodSet or etcd cluster have shared a node for an hour while the cluster has a schedulable node for each of them. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added monitoring for workloads whose running pod replicas are colocated on the same node. * Alerts include workload, node, cluster, and severity details, along with quorum-loss guidance. * Coverage includes StatefulSets, ReplicaSets, Clusters, StrimziPodSets, and EtcdMembers. * **Tests** * Added validation for workload-placement alerts across scheduling, availability, cluster-isolation, and pod-replacement scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
5fe356f57e |
fix(postgres): accept a standard five-field backup schedule (#5119)
## What this PR does The postgres app hands `backup.schedule` to a CloudNativePG `ScheduledBackup`, and the field asks for the six-field CloudNativePG cron with leading seconds. The mongodb app takes a standard five-field cron in the same field, and so do backup Plans and the Plan form in the console, so tenants copy a value from one app into the other and support has to explain the difference. CloudNativePG does not reject a five-field value. CloudNativePG 1.30.0, which main pins, parses the schedule with `cron.Parse` from robfig/cron v1.2.0 in both the ScheduledBackup webhook and the controller. That parser takes five or six fields, reads the first one as seconds and makes day-of-week optional, and the webhook only returns a warning when the count is not six. CloudNativePG's own webhook test "warn the user if the schedule has a wrong number of arguments" covers this with `1 2 3 4 5`. So `0 2 * * *`, meant as every day at 02:00, fires every hour at minute 2, and `5 * * * *` fires every minute. The chart now counts the fields. A five-field value gets a leading `0` seconds field, so `0 2 * * *` renders `0 0 2 * * *`. A six-field value and a descriptor such as `@daily` or `@every 6h` render exactly as before. Any other field count fails the render with a message that shows both forms, where before it reached the webhook and was rejected there. An empty schedule still renders no ScheduledBackup. The field description that the dashboard form shows and the README now name both forms. One thing changes on upgrade. A release that already sets a five-field value gets the standard meaning of it, so `0 2 * * *` moves from hourly to daily. Before this change such a value was outside the documented format and drew the webhook warning. `packages/system/keycloak` renders its own CloudNativePG ScheduledBackup from its `backup.schedule`, with a six-field default and a values comment that says so. It is a platform component with its own template, so it is not changed here. The other apps with a backup schedule (mongodb, mariadb, clickhouse) and backup Plans already take five fields. - Ran robfig/cron v1.2.0 `Parse` locally from 10:00:00. `5 * * * *` fires at 10:00:05, 10:01:05 and 10:02:05, and `0 2 * * *` at 10:02:00 and 11:02:00. With the leading `0` they fire at 10:05:00 and 11:05:00, and daily at 02:00. - Rendered the whole chart with helm 3.17.3 and the `configured` render fixture. The output matches main for the defaults, for `0 2 * * * *` and for `@daily`, and for `0 2 * * *` only the `schedule` line differs. Unit tests with `helm unittest` 1.1.2, the version CI pins. `packages/apps/postgres` passes 216 of 216 in 27 suites, against 209 in 26 on main. The new suite has seven cases. With the old template five of them fail. The six-field and descriptor cases pass on both, and they fail when the template prepends to six fields too or drops the descriptor check. ### Screenshots Not a UI change. The dashboard form picks up the new field description from the schema. ### Downstream repositories Walked the trigger map in `docs/agents/contributing.md` against the diff. A chart template, a new test suite, one field description and the README, schema, Go types and cozyrd regenerated from it. No field is added, removed or renamed and no default or enum changes. The terraform provider does not model `backup.schedule`. The website reference page for postgres is generated from this README on a stable tag, and the Go types example there uses a six-field schedule, which keeps working. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(postgres): backup.schedule accepts a standard five-field cron such as 0 2 * * *, and the chart prepends a 0 seconds field before handing it to CloudNativePG, which reads the first field as seconds. Six-field values and descriptors render as before, and any other field count fails the render. A release that already sets five fields gets the standard meaning on upgrade, so 0 2 * * * moves from hourly to daily. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * PostgreSQL backup schedules support standard five-field cron expressions as well as six-field expressions with a leading seconds field. Five-field schedules are converted automatically; six-field schedules and cron descriptors are used as provided. * **Schedule Changes** * After upgrading, `0 2 * * *` runs daily at 02:00 instead of hourly at minute 2. To keep the previous hourly schedule, use `0 2 * * * *`. * Invalid schedule formats produce a rendering error. Empty schedules continue to disable chart-managed backups. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
8a37a70681 |
Merge branch 'main' into fix/mariadb-restore-dump
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
a4537127e7 |
fix(vertical-pod-autoscaler): run two admission controllers spread over nodes (#5098)
## What this PR does The VPA admission controller runs as one replica, and its webhook is registered with `failurePolicy: Ignore`. While that one pod is being rescheduled, every pod created in the cluster is admitted without its VPA recommendation, and with `updateMode: Initial` it keeps those resources until it is recreated. On a v1.6.5 cluster `vmstorage-shortterm-0` was created during a node drain while the admission controller moved to another node. It has no `vpaUpdates` annotation and runs with the vm-operator defaults, requests 250m/500Mi and limits 1/1500Mi, while its VPA recommends 920m and 3.42Gi and the other replica got 5.13Gi through VPA. It was OOMKilled 18 days later. This PR sets `replicaCount: 2`, enables the chart's PodDisruptionBudget with `minAvailable: 1` and spreads the two replicas over nodes with a `ScheduleAnyway` topology spread, so single-node clusters still schedule both. A drain then leaves one controller serving. The controller still deletes and recreates its MutatingWebhookConfiguration on start (`selfRegistration` in `pkg/admission-controller/config.go`, VPA 1.5.1), so a restart leaves only that short gap instead of the whole reschedule. `failurePolicy` stays `Ignore`, a VPA outage should not block pod creation. Two new cases in `tests/vpa_test.yaml` check the replica count, the spread selector against the pod labels and the PDB. `helm unittest .` in `packages/system/vertical-pod-autoscaler` passes 18 of 18 with helm-unittest 1.1.2, and against the values on main the two new cases fail and the other 16 pass. `helm template` renders the Deployment with 2 replicas and the PDB with the admission controller selector. I have not run the change on a live cluster. #4540 is the same trap from the other side, a component that keeps a bad size because Initial never revisits it. ### Screenshots Not a UI change. ### Downstream repositories Values of `packages/system/vertical-pod-autoscaler` and its tests only. No platform values, app schema, default exposed to tenants or package change, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(vertical-pod-autoscaler): the admission controller runs two replicas spread over nodes with a PodDisruptionBudget, so pods created during a drain still get their VPA recommendation. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Improvements** * The VPA admission controller now runs with two replicas, increasing availability. * Its pods are spread across hostnames when scheduling permits, helping reduce the impact of node-level disruptions. * A disruption budget requires at least one admission-controller pod to remain available during voluntary disruptions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
24f2b8009f |
feat(redis): add maxmemory, eviction policy and snapshot toggle (#5310)
## What this PR does Lets a tenant run Redis as a pure cache without giving up the persistent volume. Until now the chart only turned snapshots off together with the volume (when `size` is empty), and offered no way to bound memory: a `CONFIG SET maxmemory` is lost when the pod restarts. On a cache-only instance, RDB snapshots and replica full syncs then filled the volume, and each SIGKILL during a save left an orphaned `temp-*.rdb` behind, so the instance crashlooped. New values: - `maxmemory` (quantity, unset by default): rendered in bytes. Unset renders `maxmemory 0`, the Redis default (no limit). - `maxmemoryPolicy` (enum, default `noeviction`): rendered as `maxmemory-policy`. - `snapshots` (bool, default `true`): `false` renders `save ""` while keeping the volume. Snapshots stay off when `size` is empty, as before. Every directive is rendered with an explicit value, defaults included. The operator applies `customConfig` with `CONFIG SET` on every reconcile and never resets a directive whose line disappears (`service/redis/client.go` in freshworks-oss/redis-operator v3.3.5), so leaving the defaults implicit would turn reverting a setting into a no-op until the next pod restart. As a consequence, existing instances gain `save 3600 1 300 100 60 10000`, `maxmemory 0` and `maxmemory-policy noeviction` on upgrade. These equal the Redis 7 and 8 defaults, but they overwrite any value an operator set by hand with `CONFIG SET`. `maxmemory` is refused at render time above 90% of the Redis memory request: above that threshold (`reservedPodMemoryPercent`, default 10) the operator logs an error and skips the line, which would leave Redis unbounded with nothing visible to the tenant. Not changed here: a replica still writes a temporary RDB to disk during a full sync (`repl-diskless-load` defaults to `disabled`), even with `snapshots: false`. `stop-writes-on-bgsave-error` keeps its default, since no background save runs once snapshots are off. Tests: `tests/cache_config_test.yaml` covers the rendered defaults, the snapshot toggle with and without a volume, byte conversion from presets and explicit resources, and both refusals. `helm unittest packages/apps/redis` passes (93 tests). ### Screenshots Not a UI change. ### Downstream repositories The new fields in `values.schema.json` reach `cozystack/terraform-provider-cozystack`, whose redis schema and expand/flatten pair are hand-written; no follow-up has been opened there yet, so the box is left unticked. The website reference page is regenerated from `README.md` by the release bot. - [ ] 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(redis): add `maxmemory`, `maxmemoryPolicy` and `snapshots` values so Redis can run as a pure cache (bounded memory, eviction, no RDB snapshots) while keeping its persistent volume. Existing instances now render the Redis defaults for these directives explicitly, which resets any value set by hand with `CONFIG SET`. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added configurable Redis memory limits, with a default of unlimited, and eviction policies, defaulting to `noeviction`. Configured limits must be whole-byte quantities and cannot exceed 90% of the pod’s memory request. * Added controls for scheduled Redis snapshots. Snapshots are enabled by default when storage is configured; disabling them does not remove existing snapshot files, and snapshots are off when storage size is empty. * **Documentation** * Documented the new Redis memory and snapshot settings, including defaults, constraints, and effects. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
03a2edf3db |
Merge branch 'main' into feat/observability-proxy-app-scope
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
fe7edffa10 |
Merge branch 'main' into feat/observability-proxy-ingress
Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la> |
||
|
|
4e6ce4655a |
feat(dashboard): add logs and metrics views to the console (#5218)
## What this PR does Adds logs and resource-consumption views to the console, backed by the observability proxy from the design proposals [Tenant application logs](https://github.com/cozystack/community/pull/95) and [Tenant resource-consumption metrics](https://github.com/cozystack/community/pull/94). This PR is useful only together with #5214, which adds the console nginx route to the proxy. The application tabs need #5219 and the per-application roots from its follow-up PR. Until those are installed, each view shows a quiet "not available on this cluster" state instead of an error, so the order of merging does not break the console. What is added: - A "Logs" page at the namespace level, under a new "Observability" sidebar group, reading the namespace logs root. It lives at `/console/-/observability/logs`: every one- or two-segment console path is an application list or detail page, and `-` cannot start an application plural or name, so the page never shadows an application's own pages. - "Logs" and "Metrics" tabs on application pages (every application kind except VMDisk, which runs no containers), reading the per-application roots. - Logs view: - time range, a LogsQL filter, and pod and container pickers that turn into a stream filter; - "Follow" opens a live tail. The status shows "Live" as soon as the stream is open, even before the first line; on a dropped stream or a load refusal (`429`) it reconnects from the newest line seen, with backoff; it stops on `400`/`401`/`403`/`404`; - the reader can scroll up while lines stream; the newest 1000 lines are kept; - while a new range or filter loads, the previous lines stay on screen with a note saying so, or the view says it is loading; it never reports "no lines" for a query it has not read yet. - Metrics view: per-pod CPU and memory charts and application-wide network charts, refreshed every minute, with ranges from 1 hour to 7 days. The `rate` window is at least 5 minutes and four steps, so queries routed to the long-term store (coarser deduplication) still return data. No query names a namespace or kind; the proxy adds the scope. - Error handling by proxy status: scope-wide answers (`401`/`403`/`404`) replace the whole view with one notice; limit answers keep the proxy's own advice. A Kubernetes `Status` body on a proxy path means the request reached kube-apiserver instead of the proxy and is shown as "not available". - Shared UI pieces: an accessible `Select` and a text `Input` matching the console's controls, and an `EmptyState`. - `K8sClient.raw()` for untyped requests over the same credential path as `/apis`; the client now keeps caller headers given in any form. - Charts use uPlot, loaded in a separate lazy chunk, so the main bundle does not grow. #### How it was tested - `pnpm typecheck`, `pnpm test`, `pnpm lint` and `pnpm build` pass. - Screenshots of the views were taken against a mock API and on a test cluster. - Verified on a test cluster through the full browser chain (OIDC login, gatekeeper, gateway, console nginx, proxy), as a user with the `view` role in one tenant: the Logs page works; Follow keeps a single tail open for more than two minutes without reconnecting; Follow on a quiet filter shows "Live"; the Metrics tab of a Redis instance draws its charts; requests from the same session to another tenant's roots answer `403`. - Not verified: a screen reader (roles and names are asserted in tests only) and viewports narrower than 1440px. #### Known limitation The first lines a newly started pod writes can be missing from an already open tail, although a history query shows them. This comes from the log store's live-tail window relative to log collection delay, not from the console. ### Screenshots <img width="1440" height="900" alt="cluster-follow-live" src="https://github.com/user-attachments/assets/6efd9bfb-f05b-4498-bd20-0af4e5cda01f" /> <img width="1440" height="900" alt="cluster-logs-empty" src="https://github.com/user-attachments/assets/673d8295-cd3d-409d-b871-290705d0a6a2" /> <img width="1440" height="900" alt="cluster-logs" src="https://github.com/user-attachments/assets/621c2312-8427-4353-b199-44bdd12b78f7" /> <img width="1440" height="900" alt="cluster-pod-select" src="https://github.com/user-attachments/assets/92ea9c72-4a3c-4562-9c3a-2170730ab085" /> <img width="1400" height="1000" alt="cluster-redis-metrics" src="https://github.com/user-attachments/assets/3533d069-01b9-41de-bba9-70b940d05c6e" /> <img width="1440" height="900" alt="follow-waiting" src="https://github.com/user-attachments/assets/eb318d13-5188-4632-842a-43c0bbbcff5a" /> <img width="1440" height="900" alt="logs-empty" src="https://github.com/user-attachments/assets/c3d89e81-7249-444d-a3fa-9ab44c1ca86e" /> <img width="1440" height="900" alt="logs" src="https://github.com/user-attachments/assets/ec6caa9c-5eda-4361-99ea-359e5d002f04" /> <img width="1440" height="900" alt="metrics-empty" src="https://github.com/user-attachments/assets/db16da15-a618-4dbe-a531-593bc9b916dc" /> ### Downstream repositories - [ ] 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: Downstream: no trigger matched. Candidate: none affected, because the whole diff is inside the vendored console (`packages/system/dashboard/images/console`), which per the trigger map belongs to this repository and has no downstream copy. A user guide page for the new console views on the website would be useful but is not required by the trigger map. ### Release note ```release-note feat(dashboard): the console gains a namespace Logs page and Logs and Metrics tabs on application pages, with live log following, per-pod CPU and memory charts, and application-wide network charts. The views need the observability proxy; without it they show "not available on this cluster". ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added Metrics and Logs tabs to supported application details, plus a tenant-wide Logs page in the sidebar. * View CPU, memory, and network charts over selectable time ranges, with optional sample tables and automatic refresh. * Search logs using pod and container filters, choose a history range, and follow live updates with connection status. * Added distinct loading, empty, and error messages for observability views, including guidance for unavailable services and query limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
17bbca2088 |
feat(observability-proxy): serve tenant namespace metrics (#5219)
## What this PR does Depends on #5214. This PR is stacked on that branch; the description covers only what it adds on top. Backward compatibility: this adds a new package and a new HelmRelease; nothing existing is renamed, removed or changed, so no migration is needed. Adds the namespace metrics root to the observability proxy, as described in the design proposal [Tenant resource-consumption metrics](https://github.com/cozystack/community/pull/94). A tenant user can query the metrics of their own namespace from VictoriaMetrics with their Kubernetes credentials, without seeing other tenants' series. What is added: - Serves `/apis/cozystack.io/v1alpha1/namespaces/<ns>/metrics/api/v1/{query,query_range,series,labels,label/<name>/values}`, GET and POST. Anything else under the root answers `404`. - Authorization by one `SubjectAccessReview` (`list` on `cozystack.io/metrics` in the namespace); the aggregated tenant `view` role gains that rule. - The upstream request is rebuilt from an allowlist (`query`, `start`, `end`, `step`, `time`, `match[]`, `timeout`). The scope is a single forced `extra_filters[]={namespace="<ns>"}`; client-supplied `extra_filters`, `extra_filters[]` and `extra_label` are dropped, because vmselect would OR them with the forced filter. The query itself is not rewritten. - Label endpoints always carry a `match[]` (the namespace scope when the client sent none), so they stay scoped even if vmselect's `-search.ignoreExtraFiltersAtLabelsAPI` is ever enabled. - Cost limits: maximum range (30 days), maximum points (11000), and a clamped `timeout` (30 seconds); query-shape limits answer `422`, the concurrency limit answers `429`. Times are accepted as unix seconds or RFC3339; durations are rounded up to whole milliseconds before limits are checked. - Store selection between the short-term and long-term VictoriaMetrics stores, configured by new chart values (`observabilityProxy.metrics`). #### Store selection: a known limitation and an open question The proxy has to send each query to the short-term store (3 days of retention, finer deduplication) or the long-term store. The choice depends on how far back the query reads, which is not only the request window but also the windows, subquery steps and offsets inside the expression. The current implementation estimates that lookback with a conservative scan of the expression text, not with a parser. It sums every `[...]` window and subquery step, every positive `offset`, and allowances for implicit subqueries and vmselect's default step and latency offset. Anything it cannot read with certainty (`@`, `WITH` templates, step multiples such as `5i`, template variables, unusual duration syntax) goes to the long-term store. The query is forwarded unchanged, so the estimate affects only the store choice, never the scope. This is a heuristic. It is designed to err only towards the long-term store, which holds the same recent data at coarser deduplication, so a wrong guess returns coarser data rather than missing data in most cases. A very short `rate` window sent to the long-term store can still come back empty. Two review rounds each found new expressions the scan underestimated, which were then fixed; there may be more. Open question for reviewers: should the scan be replaced by parsing the expression with `github.com/VictoriaMetrics/metricsql` (the library vmselect itself uses), only for the store choice? That gives an exact lookback at the cost of a new Go dependency. The namespace scope would still be enforced by vmselect through the single `extra_filters[]`, so the isolation design does not change either way. A user-visible consequence of counting the lookback: a range whose start sits right at the short-term retention edge (for example "last 3 days") now goes to the long-term store. #### How it was tested - `go test -race` and `go vet` for the proxy packages; table tests for the lookback estimate, including mutation checks of the `@` and unparseable-window cases. - helm-unittest for `observability-proxy` (new args and the tenant role rule). - Verified on a test cluster: `401` and `403` where expected; results contain only the caller's namespace; a query naming another tenant's namespace and a client-supplied `extra_filters[]` return nothing extra; `query_range`, `label/<name>/values` and `series` are scoped; an admin endpoint answers `404`. - Not verified: the limits under load, and the store choice on windows longer than 3 days (the test cluster had less than an hour of data). #### Known limitations - Relative times (`start=-1h`, `end=now`) are refused with `400`, while the logs root accepts durations. The console sends unix seconds, so it is not affected. - The proxy bounds the evaluation window, the step, the number of points of `query_range` and the timeout, not how far an expression reads: windows and offsets inside the expression (`up[10y]`, `x[30d:1ms]`, `offset 20d`) are bounded only by the store's retention and vmselect's own limits. - Times and durations are sent in a form vmselect parses exactly (RFC3339 with milliseconds for times, durations that truncate to the checked milliseconds); times outside 1970..2262 are refused with `400`. A test repeats vmselect's parsing of the exact strings the proxy sends. - `--metrics-max-range` defaults to 30 days while the longterm store keeps 14, so the older part of a long range comes back empty rather than refused. The two should be aligned or documented. - The store estimate errs towards longterm: deeply nested expressions with a large step can go to longterm although shortterm holds the data, and longterm deduplicates at 5 minutes, so short windows such as `rate(x[1m])` can come back sparse there. - The `namespace` label is only as trustworthy as the writer. Any pod in a child tenant may write to the vminsert of every ancestor tenant (`packages/apps/tenant/templates/networkpolicy.yaml`), and vminsert does not authenticate writers, so a child tenant can write series labelled with another tenant's namespace. Through this proxy the owner of that namespace would see those series as its own, and a flood of them could push its queries over the series limit. Reading another tenant's data is not possible this way. The write path predates this PR and already affects the root tenant's dashboards and alerts; closing it needs the write side to mark untrusted series, for example a vmauth in front of vminsert that forces an `extra_label` the proxy then excludes. ### Screenshots No UI changes. ### Downstream repositories - [ ] 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: Downstream: no trigger matched. Candidate: none affected, because the diff on top of #5214 is confined to the proxy's Go code and its own chart under `packages/system/observability-proxy` (no platform values, no package under `packages/apps/`, no CRD, no `hack/` change). A user-facing page for the metrics API on the website would be useful but is not required by the trigger map. ### Release note ```release-note feat(observability-proxy): let tenant users query their namespace metrics from VictoriaMetrics with their Kubernetes credentials, under `/apis/cozystack.io/v1alpha1/namespaces/<ns>/metrics/api/v1/`. Access requires the tenant `view` role or higher. Ranges are limited to 30 days and 11000 points. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * The observability proxy now supports tenant-scoped metrics queries alongside logs. * Metrics requests are routed to short- or long-term stores based on their time range, with configurable retention and query limits. * Metrics access is subject to tenant authorization, request validation, and concurrency limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
185c5eca72 |
fix(monitoring): route InfoInhibitor to the blackhole receiver (#4948)
## What this PR does `InfoInhibitor` in `packages/system/monitoring-agents/alerts/general.rules.yaml` is the kube-prometheus rule that exists only to feed an Alertmanager inhibit rule, and its own description says it should go to a null receiver. The `update` target that first imported the rules rewrote its `severity: none` to `major`, and the platform Alertmanager config has no inhibit rule, so the alert goes to Alerta one level below critical. Alerta's Telegram and Slack plugins forward it with the default `disabledSeverity: []`, and once email delivery is configured, a `notify_email="true"` label inherited from the info alert gets it emailed as well. It fires whenever an alert with `severity="info"` is active and no warning or critical alert fires in the same namespace and cluster. #3799 moved the last first-party rule off `info`, but rules the platform does not write still use it. CDI v1.66.1 generates `CDIStorageProfilesIncomplete`, KubeVirt v1.9.0 generates `KubeVirtVMGuestMemoryAvailableLow` and `KubeVirtDeprecatedAPIRequested`, all at `info`, and operators add their own. We hit it on a v1.6.4 cluster with one custom `severity: info` rule that is always firing, and Alerta showed a permanent MAJOR `InfoInhibitor`. The info alert itself cannot show up there, because Alerta's default alarm model has no `info`. This puts the label back to `none`, the value kube-prometheus ships. The platform Alertmanager config already routes `severity="none"` to the `blackhole` receiver ahead of every route that delivers, and the Monitoring parameters already document that such alerts never reach email. `hack/alert-severity-contract.bats` refuses `none` on purpose, because an alert carrying it is never delivered, so InfoInhibitor is listed as the one alert for which that is the point. The exemption covers `none` and that name only. The contract now also checks that InfoInhibitor carries `none`, that `none` still fails on any other alert, and that the exemption does not let InfoInhibitor through with a severity Alerta refuses. A new helm-unittest suite in `packages/system/monitoring` pins the route order, so that only the heartbeat route can come ahead of the blackhole, with and without the email routes. There is no inhibit rule here, and the expression still matches `info` only. Wiring the inhibition up would hide every informational alert from Alerta unless a warning fires in the same namespace, which changes behaviour on every cluster and is a separate decision. Dropping InfoInhibitor altogether would be equivalent for delivery, and I can rework the PR that way if you prefer it. v1.6.5 ships the same rule and the same routes, so a backport to `release-1.6` would be appreciated. The commit cherry-picks onto it without conflicts. ### Validation - `bats hack/alert-severity-contract.bats` passes 12 of 12, and so does the same file under `hack/cozytest.sh`. Without the label change the new InfoInhibitor test fails on `[ "$delivered" -eq 0 ]`. With the exemption removed the tree-wide contract fails on `packages/system/monitoring-agents/alerts/general.rules.yaml: InfoInhibitor -> 'none'`. With the exemption widened to any alert, or to any severity, the matching fixture test fails. - `helm unittest` in `packages/system/monitoring` passes 25 suites and 306 tests. Deleting the `severity="none"` route fails both new cases, and an email route placed ahead of it fails the email case. - `helm unittest` in `packages/system/monitoring-agents` passes 6 suites and 19 tests, and the rendered `alerts-general.rules` VMRule carries `severity: none` for InfoInhibitor. - Rendered the Alertmanager config and ran `amtool config routes test` from Alertmanager v0.31.0, the default of VM operator v0.68.4, with InfoInhibitor's labels. `severity=major` routes to `alerta`, and to `alerta,email` once email is configured and `notify_email=true` is inherited. `severity=none` routes to `blackhole` in every case. `amtool check-config` reports 0 inhibit rules. - On `release-1.6` with this commit cherry-picked, the contract and both helm-unittest suites pass. - Not exercised on a live cluster. ### Screenshots Not a UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: Walked the trigger map against the diff. It changes one alert label under `packages/system/monitoring-agents/alerts/`, extends the test in `hack/alert-severity-contract.bats` and adds a test suite under `packages/system/monitoring/tests/`. No package is added or renamed, and no values, schema, CRD, platform values, variant, make target, tool the satellites call, node prerequisite or metric changes. The website already says that `severity="none"` alerts are blackholed and never reach email, and no page mentions InfoInhibitor, so nothing there goes stale. ### Release note ```release-note fix(monitoring): InfoInhibitor no longer reaches Alerta as a major alert. It carries severity none again, which the platform Alertmanager routes to the blackhole, as upstream kube-prometheus intends. Before, any active alert with severity info, from a custom rule or from one CDI or KubeVirt generates, raised a major InfoInhibitor in Alerta and in its Telegram and Slack notifications. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * `InfoInhibitor` alerts are now treated as non-notifying, preventing them from generating alert notifications. Other alerts retain their existing severity handling, and heartbeat alerts continue to follow their configured route. * The non-notifying route takes precedence over email delivery rules that include `InfoInhibitor`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
dd6ff661bd |
fix(monitoring-agents): make a silent Watchdog an alarm in Alerta (#5102)
## What this PR does
The Watchdog is meant to prove the alerting pipeline is alive, and
Alerta turns it into a heartbeat because it carries `event: Heartbeat`.
When the heartbeat goes stale, nothing alarms.
- The Alerta 9.1.0 heartbeat plugin (`alerta/plugins/heartbeat.py`)
stores the alert severity in the heartbeat attributes, and the Watchdog
has `severity: ok`.
- The `alerta/alerta-web:9.1.0` image sets `HEARTBEAT_SEVERITY=major`,
and supervisord runs `alerta heartbeats --alert --severity major` about
every minute. The client it ships, 8.5.3, takes the severity of a stale
heartbeat from the heartbeat attributes ahead of that flag
(`want_severity = b.attributes.pop('severity', severity)` in
`alertaclient/commands/cmd_heartbeats.py`). The HeartbeatFail it raises
for the Watchdog is therefore severity `ok`, a normal alert.
- The Watchdog has no `timeout` label, so the Alerta webhook leaves the
timeout unset and the heartbeat only goes stale after a day (timeout
86400 on three v1.6.5 clusters), while the `event="Heartbeat"` route
resends it every minute. `/api/management/healthcheck` compares against
four timeouts and never reports it.
The Watchdog now has `severity: major`, matching the image's own
`HEARTBEAT_SEVERITY`, and `timeout: "300"`, five missed resends. The
`event="Heartbeat"` route still sends it only to `alerta_no_resolve` and
stops, so the severity reaches no email or other receiver, and the
template has no inhibit rules it could trigger. In the Alertmanager and
vmalert lists the Watchdog now shows as major instead of ok.
A new suite `tests/watchdog_heartbeat_test.yaml` checks the severity,
the timeout and the event label. `helm unittest .` in
`packages/system/monitoring-agents` passes 21 of 21 with helm-unittest
1.1.2, and against the rules on main the two new cases fail and the
other 19 pass. `hack/alert-severity-contract.bats` passes 9 of 9. I have
not run the change on a live cluster, and I have not read a heartbeat
record through the Alerta API, the chain above is from the sources of
the versions the chart pins.
The rule file is the same on release-1.6, and that backport is a
separate PR.
### Screenshots
Not a UI change.
### Downstream repositories
One rule in
`packages/system/monitoring-agents/alerts/general.rules.yaml` and a
test. No values key, schema, default or package change, so no trigger
map entry applies.
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
### Release note
```release-note
fix(monitoring-agents): a Watchdog that stops reaching Alerta now raises a major HeartbeatFail about six minutes later. It used to raise an ok alert after a day.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Monitoring**
* The Watchdog alert now reports a major severity and includes a
300-second timeout.
* The alert identifies heartbeat events.
* **Tests**
* Added checks to verify the Watchdog alert’s severity, timeout, and
event.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
a5c58e5e98 |
fix(vm-disk): refuse a disk smaller than the golden image it clones (#4960)
## What this PR does
A VMDisk created from `source.image` with a `storage` smaller than its
golden image never comes up. CDI v1.66.1 checks a clone against its
source in `validateClone`
(`pkg/controller/datavolume/pvc-clone-controller.go`) before it creates
the target claim. When the source PVC is in `Block` mode and requests
more than the DataVolume, CDI records `CloneValidationFailed` ("target
resources requests storage size is smaller than the source"), creates no
claim and leaves the DataVolume `Pending` for good. The webhook admits
such a DataVolume, so nothing fails at install. Raising `storage`
afterwards does not help either, because the chart renders an existing
DataVolume's spec as it is (CDI does not let it change) and the resize
hook only patches a claim that exists.
This is the default path. Every image in `vm-default-images` is 20Gi on
`replicated`, the StorageProfile CDI builds for the LINSTOR driver puts
`Block` first, and the chart defaults `storage` to 5Gi. Seen on a v1.6.4
cluster with CDI v1.66.1. A 10Gi disk from a 20Gi golden image sat
`Pending` with `CloneValidationFailed` while its release kept timing
out, and raising the disk to 25Gi left the DataVolume at 10Gi. The only
way out is to delete the disk and create it again at 20Gi or more.
The chart now refuses such a disk at render time, before any DataVolume
exists, with a message that names both sizes and the minimum to set, for
example `storage 5Gi is smaller than golden image
"vm-default-images-ubuntu" (20Gi), so CDI refuses to clone it and the
disk would stay pending forever. Set storage to 20Gi or more.` It
compares what CDI compares, the golden PVC's request against the disk's
request in bytes, and first raises the disk's request to the target
StorageProfile's `cdi.kubevirt.io/minimumSupportedPvcSize` the way
`GetEffectiveStorageResources` does. For an empty `storageClass` the
target is the class the check from #4796 already resolves, the default
virt class or else the Kubernetes default.
Nothing is compared, and the disk renders as before, when the golden PVC
cannot be read (under `helm template`, or before CDI created it), when
the golden PVC is in `Filesystem` mode, and for any source other than
`image`. For a `Filesystem` source CDI sizes a `Block` target from the
virtual size of the image inside it and otherwise compares requests
inflated by a per-class filesystem overhead, neither of which the chart
reproduces. An existing disk is exempt, as for the other golden checks,
since its DataVolume spec cannot change anyway.
Not covered here. A `source.disk` clone into a smaller disk goes through
the same CDI check and still renders. The chart default of 5Gi stays
below every default image, so a disk created from one at the default
size is now refused with the message above instead of hanging. Whether
the default should follow the images is a separate decision.
A new helm-unittest suite, `tests/dv_golden_size_test.yaml`, has 15
cases. It pins the refusal at the chart default against a 20Gi `Block`
golden with the whole message, the equal and the larger size, the
comparison in bytes (`21G` is refused against `20Gi`, `20480Mi`
renders), a StorageProfile minimum that covers the golden and one that
stays below it, the minimum read from the default class for an empty
`storageClass`, and the cases that render as before, a `Filesystem`
golden, no cluster, a golden PVC that does not exist yet, a disk without
a size, an existing disk, an `http` and an `upload` source. Against the
template on main the 3 refusal cases fail and the other 12 pass. Six
mutations of the new block each turn at least one case red (any volume
mode compared, the minimum dropped, the minimum read from the requested
class only, no check that `storage` is set, an equal size refused, sizes
compared as strings). `helm unittest` passes 129 of 129 for vm-disk,
against 114 on main, with helm-unittest 1.1.2 as CI pins it. Merged with
the current heads of #4802 or #4955, which touch the same template,
vm-disk passes 137 and 131 cases. `helm template` without a cluster
renders an image disk at 5Gi as before. I have not run it on a live
cluster.
The commit does not cherry-pick onto release-1.6 or release-1.7. Neither
carries the check from #4796 it builds on, and release-1.6 has none of
the golden checks, so a backport would be an adapted change.
### Screenshots
Not a UI change.
### Downstream repositories
Template and tests only. No values, schema, README, defaults or
`ApplicationDefinition` change. The golden images guide on the website
already creates its example disk at the image's 20Gi.
- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:
### Release note
```release-note
fix(vm-disk): a new disk from a golden image is now refused at render time when its storage is smaller than the image, with a message that names both sizes. Before, CDI refused the clone with CloneValidationFailed, the disk stayed pending forever, and raising its storage afterwards did not help. The default images are 20Gi and the default storage is 5Gi, so a disk from one of them needs storage set to 20Gi or more.
```
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Disk sizes are now checked against the size of Block-mode golden
images when cloning. If the requested size is too small, it is increased
to the target storage profile’s minimum supported size when possible;
otherwise, rendering fails with an error that states the required size.
* Size comparisons account for actual byte capacity, so equivalent size
units are handled correctly. Filesystem-mode sources and other disk
sources are unaffected.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
||
|
|
e5ab1d6a7e |
fix(kubernetes): detach volumes when the infra PVC is missing (#5249)
## What this PR does routes an infra PVC `NotFound` in `ControllerUnpublishVolume` through the existing upstream hotplug detach path. a quota-rejected PVC can still have a persistent entry in the VM spec, so returning success before detach leaves a stale volume after the DataVolume is deleted. adds regression coverage for a pending hotplug volume, an already detached volume, and a VMI that outlives its VM. existing NFS unpublish tests still pass. no dependency update is needed. Fixes https://github.com/cozystack/cozystack/issues/5248 validation in the kubevirt-csi-driver module: `go test -count=1 ./...` and `go vet ./...`. the new regression fails without the production change. root `make generate` and `make manifests` also pass without generated-file changes. ### 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 fix(kubernetes): remove stale hotplug volumes when the infra PVC is missing, preventing deleted volumes from blocking subsequent attachments ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Volume unpublish requests now proceed through standard cleanup when the associated PVC is missing, rather than returning success immediately. This allows remaining teardown steps to run for detached volumes and VM-level resources. Other PVC lookup errors continue to be returned directly, without entering the missing-PVC cleanup path. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
e4d059cedd |
fix(etcd): require an even spread of members over nodes by default (#4986)
## What this PR does The tenant etcd chart spreads members with `maxSkew: 1` on `kubernetes.io/hostname` and `whenUnsatisfiable: ScheduleAnyway`, the default since #119. `ScheduleAnyway` only adds to the score of a node and other scores can outweigh it, so two members of one etcd can still start on the same node, where a node-local volume then keeps them. This PR makes the default `DoNotSchedule` with `nodeTaintsPolicy: Ignore`. The branch for `_cluster.scheduling.globalAppTopologySpreadConstraints` is untouched, so a platform that sets its own policy renders exactly as before, and the soft pod anti-affinity from #3962 stays. Seen on a three-node cluster running v1.6.4, whose `etcd-cluster.yaml` and etcd-operator v0.5.5 are the same as in v1.6.5. A new tenant etcd got the Pods of its first two members on one node, created 26 seconds apart, and the third on another node 18 seconds later. The Pods carry the `ScheduleAnyway` constraint and were scheduled by `linstor-scheduler`, whose profile adds the LINSTOR extender's prioritize score to the same sum with weight 5. The data volumes are on a node-local StorageClass with `WaitForFirstConsumer` and `allowRemoteVolumeAccess: "false"`, so the two members cannot leave that node, and losing it takes the quorum. A second tenant etcd created there the next day came up the same way. On a test cluster four tenant etcds created within one week each had two members on one node, and we moved one member of each by hand. `DoNotSchedule` does not stop an etcd with more members than nodes from starting when every node can run its Pods, unlike a required anti-affinity, because the skew is counted between the nodes that exist. kube-scheduler rejects a node only when the matching Pods on it plus the new one exceed the node with the fewest by more than `maxSkew` ([filtering.go](https://github.com/kubernetes/kubernetes/blob/v1.34.1/pkg/scheduler/framework/plugins/podtopologyspread/filtering.go#L334-L352)). One node takes all three members, two nodes take two and one, and three or more nodes take one each. A member whose only allowed node cannot take it, for example because the storage pool there is full, now waits Pending instead of joining another member. `nodeTaintsPolicy: Ignore` is the Kubernetes default and is written out on purpose. A cordoned node carries `node.kubernetes.io/unschedulable`, and `Honor` would take it out of the count ([common.go](https://github.com/kubernetes/kubernetes/blob/v1.34.1/pkg/scheduler/framework/plugins/podtopologyspread/common.go#L50-L54)), so a member created during a drain would start next to another member and stay there on a node-local volume. With `Ignore` it waits Pending until the node is back, while the other two keep quorum. The cost is that a node no member can run on, such as a tainted control plane, counts as an empty node too, so on a cluster with such a node each schedulable node takes at most one member and the members beyond that do not start. #4947 makes the same choice for the SeaweedFS masters and checked both policies in kwok. A platform that wants the old behaviour can set `scheduling.globalAppTopologySpreadConstraints` to `ScheduleAnyway`, which the other charts that read it pick up as well, and a new test case pins that the chart renders such a policy as written. On upgrade nothing is recreated. The etcd-operator adopts a changed `spec.topologySpreadConstraints` into `status.observed` once the cluster has reached its current target, or its progress deadline has passed ([etcdcluster_controller.go#L203-L214](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L203-L214)). It copies the value from there into the spec of an `EtcdMember` only when it creates one, at bootstrap ([#L446](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L446)) and on scale-up ([#L851](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdcluster_controller.go#L851)), and nothing in the operator writes it into an existing `EtcdMember`. The member controller creates a Pod only when it is missing and builds it from that member's own copy ([etcdmember_controller.go#L499-L512](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L499-L512), [#L545-L549](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L545-L549), [#L860](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L860)). So running members keep `ScheduleAnyway`, and so does a member whose Pod is evicted, deleted or replaced after a terminal phase ([#L164-L186](https://github.com/cozystack/etcd-operator/blob/v0.5.6/controllers/etcdmember_controller.go#L164-L186)), since the new Pod is built from the same copy. Only members created after the upgrade get `DoNotSchedule`, which means a scale-up, a crash-loop replacement or a member whose `EtcdMember` was deleted. No member is rolled, neither one at a time nor all at once. This matches the field docs ([etcdcluster_types.go#L542-L549](https://github.com/cozystack/etcd-operator/blob/v0.5.6/api/v1alpha2/etcdcluster_types.go#L542-L549), [etcdmember_types.go#L112-L116](https://github.com/cozystack/etcd-operator/blob/v0.5.6/api/v1alpha2/etcdmember_types.go#L112-L116)). The code paths are the same in v0.5.8, and in v0.5.5, which v1.6.4 and v1.6.5 ship, except that v0.5.5 does not yet replace a Pod left in a terminal phase. Members that already share a node therefore stay there. One of them moves only when a new `EtcdMember` takes its place, and the constraint then sends the replacement to the node without a member. That is how we moved the members on the test cluster, with `DoNotSchedule` set on the `EtcdCluster` by hand. The operator's docs say a scheduling change can be applied by deleting one Pod at a time ([concepts.md#L272](https://github.com/cozystack/etcd-operator/blob/v0.5.6/docs/concepts.md#L272)), but the recreated Pod gets the member's old copy, so that does not move it. The release note now declares two cases from review. In the first, an etcd created while the cluster had fewer nodes than members has two or three members on one node, and once a node is added a recreated Pod of one of them stays Pending, since `maxSkew` rejects its own node and its node-local volume rules out the others. Deleting that member's `EtcdMember` while the other members keep quorum replaces it on a node without a member. In v0.5.5 the member finalizer removes the member from etcd through the remaining members before the object goes ([`handleDeletion`](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdmember_controller.go#L195-L231), [`removeMemberFromEtcd`](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdmember_controller.go#L243-L310)), its Pod and its `data-<member>` PVC are owned by it and deleted with it ([#L403](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdmember_controller.go#L403), [#L490](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdmember_controller.go#L490)), and the cluster controller waits for the deletion, then adds a member under a new name with the constraints from `status.observed` ([etcdcluster_controller.go#L254-L312](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdcluster_controller.go#L254-L312), [`scaleUp`](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdcluster_controller.go#L820-L851)). Its new PVC binds where its Pod lands, and under `DoNotSchedule` only a node without a member passes. The operator documents the same steps for a broken member, along with the limit that `MemberRemove` cannot run without quorum ([operations.md#L208-L231](https://github.com/cozystack/etcd-operator/blob/v0.5.5/docs/operations.md#L208-L231)), and v0.5.6, which main and `release-1.6` ship now, has the same path. The upstream chart of the operator installs a policy that denies `EtcdMember` deletion without the `etcd-operator.cozystack.io/allow-deletion=true` annotation ([member-deletion-policy.yaml](https://github.com/cozystack/etcd-operator/blob/v0.5.5/charts/etcd-operator/templates/member-deletion-policy.yaml)), and the `etcd-operator` package here does not install it. On a three-node cluster running v0.5.5 a tenant etcd had two members on one node with `DoNotSchedule` in effect. We deleted the `EtcdMember` of one of the two while the other members kept quorum. The replacement's Pod and its new node-local PVC were scheduled on the node without a member, the member joined, and the `EtcdCluster` stayed `Available` with quorum the whole time, polled every 5 seconds. In the second case `nodeTaintsPolicy: Ignore` counts a node the Pods cannot tolerate as one with zero members, so on a cluster with such a node and fewer schedulable nodes than members the members beyond the schedulable nodes do not start. The way out is the soft global policy in the platform `Package`, set before the upgrade. ```yaml apiVersion: cozystack.io/v1alpha1 kind: Package metadata: name: cozystack.cozystack-platform spec: components: platform: values: scheduling: globalAppTopologySpreadConstraints: | topologySpreadConstraints: - maxSkew: 1 topologyKey: kubernetes.io/hostname whenUnsatisfiable: ScheduleAnyway ``` The platform chart writes `scheduling` into `_cluster` of the `cozystack-values` Secret ([apps.yaml#L292-L295](https://github.com/cozystack/cozystack/blob/55aad6f91456cb545601a83aaecf39118e943b04/packages/core/platform/templates/apps.yaml#L292-L295)), the tenant chart copies `_cluster` into the Secret of each tenant namespace ([namespace.yaml#L109-L120](https://github.com/cozystack/cozystack/blob/55aad6f91456cb545601a83aaecf39118e943b04/packages/apps/tenant/templates/namespace.yaml#L109-L120)), and this chart renders the value as written, which the new test case pins. Rendering the platform and tenant charts with the value above, on main and on `release-1.6`, gives the same string in both Secrets. The operator adopts a changed spec into `status.observed` only once all members are Ready or the progress deadline has passed ([etcdcluster_controller.go#L196-L213](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdcluster_controller.go#L196-L213)), and it clears the deadline when the cluster converges ([#L1448-L1456](https://github.com/cozystack/etcd-operator/blob/v0.5.5/controllers/etcdcluster_controller.go#L1448-L1456)). A new etcd stuck short of its members adopts the policy once its first deadline passes, and deleting the `EtcdMember` of the Pending member then brings a replacement that starts. An etcd that had converged before one of its replacements went Pending adopts the policy only after the deadline is forced as the operator docs describe ([operations.md#L197-L206](https://github.com/cozystack/etcd-operator/blob/v0.5.5/docs/operations.md#L197-L206)), which is why the release note says to set it before the upgrade. #4817 moves this block into `_etcd.tpl` in cozy-lib without changing it, so whichever of the two lands second has to carry the two lines over. `tests/topology-spread_test.yaml` now pins the whole default constraint, and a new case pins that a `ScheduleAnyway` policy from `globalAppTopologySpreadConstraints` renders as written, without `nodeTaintsPolicy`. The existing zone override case is unchanged. Against the template on main the suite fails only the default case, 1 failed and 25 passed. Switching the default to `Honor`, to `ScheduleAnyway` or to `maxSkew: 2` fails the default case, and adding `nodeTaintsPolicy` to the override branch fails the new case. ```console $ docker run --rm -v "$PWD":/apps -w /apps/packages/extra/etcd helmunittest/helm-unittest:4.2.3-1.1.2 . Charts: 1 passed, 1 total Test Suites: 9 passed, 9 total Tests: 26 passed, 26 total ``` On main the same command gives 25 tests in 9 suites, with helm-unittest 1.1.2 as CI pins it. With default values `helm template` differs from main in the two lines and in the comment above the affinity block, and with a global policy set only in that comment. The docs commit changes the `affinity` description, from which `make generate` rewrites the README, `values.schema.json` and the `ApplicationDefinition` with nothing but that text, and the suite stays at 26 tests. I have not rolled this chart change out on a cluster. The spread block and the test file are the same on release-1.6 and release-1.7. On release-1.6 the template has no affinity block yet, so the fix commit cherry-picks without conflicts and the docs commit has nothing to change there. That backport is a separate PR. ### Screenshots Not a UI change. ### Downstream repositories One changed and one added line in `packages/extra/etcd/templates/etcd-cluster.yaml` and its test suite, and new text for the `affinity` description and the comment above the affinity block. The description reaches `values.schema.json`, the README and the `ApplicationDefinition` as text only, with no key, type or default change, and the website rebuilds the etcd reference page from the README on release. The website mentions `globalAppTopologySpreadConstraints` only as a platform setting, which stays as it is, so no trigger map entry applies. - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(etcd): tenant etcd members now spread over nodes with whenUnsatisfiable DoNotSchedule by default, so two members of one etcd no longer start on the same node while another node has none. Members that exist are not moved, only members created after the upgrade get the new constraint. An etcd created while the cluster had fewer nodes than members puts two or three members on one node. Once a node is added, such a member whose Pod is recreated (drain, eviction, graceful node shutdown) stays Pending, because maxSkew rejects its own node and its node-local volume rules out the others. With two nodes grown to three the etcd runs two of three members and its PodDisruptionBudget blocks draining the other nodes. With one node grown to three a reboot of that node brings back one member of three and quorum is lost. A stranded member is replaced by deleting its EtcdMember while the other members keep quorum. Its Pod and PVC go with it, and the replacement gets a new Pod and PVC on the node without a member. Right after adding nodes, doing this for one co-located member at a time while all members are Ready avoids the case. With nodeTaintsPolicy Ignore a node the etcd Pods cannot tolerate, such as a tainted control plane, counts as a node with zero members, so no node can take a second member. On a cluster with such a node and fewer schedulable nodes than members, a new etcd starts only as many members as there are schedulable nodes, one of three on a single schedulable node. An existing etcd there keeps its members, but a member it replaces stays Pending the same way. Either case is avoided by setting scheduling.globalAppTopologySpreadConstraints in spec.components.platform.values of the cozystack.cozystack-platform Package to a topologySpreadConstraints entry with maxSkew 1, topologyKey kubernetes.io/hostname and whenUnsatisfiable ScheduleAnyway before the upgrade. Every app chart that reads this value applies it, two members of a new etcd can share a node again, and the operator gives it only to members created after it adopts the changed EtcdCluster spec into status.observed. Once status.observed.topologySpreadConstraints of an EtcdCluster shows ScheduleAnyway, a member of it that stays Pending is replaced by deleting its EtcdMember. ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **Bug Fixes** - Default etcd placement now requires even spreading across hosts and ignores node taints when evaluating placement. - Configurable cluster-wide spreading continues to use a flexible scheduling policy when selected. - **Documentation** - Clarified how affinity and topology spreading work together, when required anti-affinity or node-local storage can leave members pending, and that affinity changes take effect as members are replaced. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
76204b10aa |
fix(ingress-nginx): raise client keepalive_time above the 1h default (#5250)
<!-- 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 ingress-nginx exposes no ConfigMap key for the client-side `keepalive_time`, so nginx keeps its built-in 1h default: every client connection older than an hour is closed, and on HTTP/2 that is a `GOAWAY` (`ErrCode=NO_ERROR`). A client that multiplexes a long operation over one connection loses the request in flight. We hit it with a kopia repository maintenance run by Velero against a SeaweedFS S3 endpoint published through this controller: the run opened its connection at 18:57:05, finished the heavy part, and failed at 19:57:38 while listing blobs with `http2: server sent GOAWAY and closed the connection`, because kopia does not retry that listing. A shorter maintenance on the previous day succeeded on the same repository. This sets `keepalive_time 12h` through `http-snippet` in the controller ConfigMap. Idle connections are still closed after `keep-alive` (75s), so only connections that are actually in use live longer. No cozystack template sets `http-snippet` today; the tenant ingress HelmRelease only sets other `controller.config` keys, which Helm merges with this default, and a test covers that merge. Applied by hand on a production cluster before this PR: the controllers reloaded cleanly and S3 traffic was unaffected. ### 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(ingress-nginx): raise the client keepalive_time from the nginx 1h default to 12h, so long-lived HTTP/2 connections (for example kopia maintenance against S3) are no longer cut by a GOAWAY after one hour ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * The ingress controller now configures NGINX to allow HTTP connections to remain open for up to 12 hours, supporting long-running operations such as S3 transfers. * **Tests** * Added checks confirming the setting remains in place when PROXY protocol and whitelist configuration are enabled. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
7ec746a360 |
fix(monitoring): select the vmalert Service the operator creates (#5094)
## What this PR does
`templates/vm/vmalert-scrape.yaml` selects `app.kubernetes.io/instance:
vmalert`. The chart names the VMAlert `vmalert-<first metricsStorages
name>` (`templates/vm/vmalert.yaml` renders only the first storage), and
the operator labels its Service with that name, so with the default
storages the Service `vmalert-vmalert-shortterm` carries
`app.kubernetes.io/instance=vmalert-shortterm`. The VMServiceScrape
matches no Service and the metrics of vmalert itself never reach the
storage.
Seen on three v1.6.5 clusters. The `vmalert` VMServiceScrape in
`tenant-root` selects no Service, `count({__name__=~"vmalert_.*"})` in
vmselect-shortterm returns nothing while
`count(up{job="vmalertmanager-alertmanager"} == 1)` returns 3, and the
`/metrics` endpoint of vmalert does serve those series. No other scrape
object covers it, and no rule under `packages/` uses `vmalert_*`
metrics, so rule evaluation and notifier errors of vmalert are not
visible anywhere in the storage.
The scrape dates from v0.0.1, when the VMAlert was called `vmalert`.
|
||
|
|
900baf2215 |
fix(linstor): update piraeus-operator to v2.12.1 (#5166)
## What this PR does Updates the LINSTOR stack to the current stable piraeus-operator release: operator v2.12.1, LINSTOR server 1.35.3 and LINSTOR CSI v1.13.2, the last two built here with our patches. This started as a fix for the NFS server image hanging up the host console on bare-metal storage nodes (Ubuntu 24.04, Cozystack 1.6.5 and 1.7.0). That needed nfs-server v1.10.6 or later. Operators also asked for per-volume IO limits, which need linstor-csi v1.11.3 or later and piraeus-operator v2.10.8 or later, so the update goes to the current release rather than the minimum. The first commit fixes a problem the update exposed. The operator runs the LINSTOR database migration in a `run-migration` init container, and this package pinned only the main controller container to our build. With the operator update, that init container ran the operator's default LINSTOR 1.35.3 and migrated the database before the controller image changed. The 1.33.3 controller then crash-looped until the linstor release caught up. Both init containers that run the LINSTOR server image (`run-migration` and the satellite's `setup-lvm-configuration`) now use the platform image, with a test pinning it. This protects later upgrades where the operator default is newer than our build. It does not help this upgrade: the pin ships in the linstor release, and Flux reconciles piraeus-operator first. Patches: - linstor-csi: the Protocol C override for dual attach is dropped. Since v1.12 the driver asks LINSTOR to manage dual-primary, and LINSTOR 1.35 sets protocol C on the connections that need it. Upstream closed the same change as superseded (piraeusdatastore/linstor-csi#435). The relocate-after-clone patch is carried forward. - LINSTOR server: six of the nine patches are in upstream by 1.35.3 and are removed. `fix-k8s-create-already-exists`, `retry-adjust-after-stale-bitmap` and `native-protoc` are carried forward. LINSTOR 1.34 requires Java 21, so the image moves from bookworm to trixie. Behaviour that changes for users: - No downgrade. LINSTOR 1.35 migrates the database and drops the `SEC_*` tables, so a cluster that has run this version cannot go back to 1.33. - The LINSTOR controller is down for a short time during this upgrade. piraeus-operator is reconciled before the linstor release, so the database is migrated to 1.35 while the old controller still runs. That controller crash-loops until the linstor release rolls out, and if the rollout fails there is no way back. - A volume on a Protocol A or B resource group that was attached to two nodes while the CSI driver was updated (a live migration in progress) keeps the Protocol C override the old driver set on its resource definition. The new driver does not remove it. Data is not affected, the resource just stays on protocol C. Such resource definitions have the `Aux/csi-protocol-override` property. To remove the override, run `linstor resource-definition set-property <rd> DrbdOptions/Net/protocol` and `linstor resource-definition set-property --aux <rd> csi-protocol-override`. - The CSIDriver moves to `fsGroupPolicy: File`, so `fsGroup` is also applied to ReadWriteMany filesystem volumes. - The operator manages Secrets only in its own namespace, and the CSI controller loses cluster-wide read access to Secrets. Nothing in this repository references snapshotter Secrets. - The csi-health-monitor sidecar is removed. - LINSTOR's default evict timeout goes from 1h to 12h; this package does not set it. - Volume group snapshots turn on only when `groupsnapshot.storage.k8s.io/v1` is served. The snapshot controller here still serves v1alpha1, so they stay off; #5239 changes that. - IO limits can be set through `qos.linbit.com/{rbps,wbps,riops,wiops}` StorageClass parameters. Enforcing them needs NRI enabled on the nodes and the nri-volume-qos plugin, neither of which this PR adds. Tested on a three-node Talos cluster, upgrading from the current main packages to this branch: - LINSTOR database migrated to 1.35.3, no faulty resources, no error reports. - Data written before the upgrade is intact, checked by checksum. - A snapshot taken before the upgrade restores, and all three replicas come up `UpToDate`; cloning and new snapshots work. - KubeVirt live migration works for a ReplicatedBlock volume, including one on a Protocol A resource group: LINSTOR switches the connection to protocol C for the migration and restores A afterwards. - A StorageClass with QoS parameters provisions, and the limits reach the resource definition and the VolumeAttachment metadata. - ZFS userspace in the satellite is now 2.4.4, matching the kernel module. Not tested: an arm64 build. ### Screenshots No UI change. ### Downstream repositories - [x] No downstream repository is affected by this change - [ ] [cozystack/website](https://github.com/cozystack/website) - follow-up: - [ ] [cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack) - follow-up: - [ ] [cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack) - follow-up: - [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up: - [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up: - [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) - follow-up: - [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) - follow-up: - [ ] [cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server) - follow-up: - [ ] [cozystack/external-apps-example](https://github.com/cozystack/external-apps-example) - follow-up: - [ ] [cozystack/examples](https://github.com/cozystack/examples) - follow-up: - [ ] [cozystack/community](https://github.com/cozystack/community) - follow-up: ### Release note ```release-note fix(linstor): update piraeus-operator to v2.12.1, LINSTOR to 1.35.3 and LINSTOR CSI to v1.13.2. Fixes the NFS server breaking console login on storage nodes and adds IO QoS StorageClass parameters. LINSTOR 1.35 migrates its database, and a downgrade to an earlier version is not possible after the upgrade. ``` |