Commit Graph
6538 Commits
Author SHA1 Message Date
Aleksei Sviridkin 7d53f7af22 fix(dashboard): raise the console nginx header buffers for large OIDC tokens
The nginx config baked into the console image kept the nginx defaults for
client_header_buffer_size (1k) and large_client_header_buffers (4 8k). An
OIDC access token carrying many group claims arrives as a single Cookie
header of several kilobytes, which no longer fits into one buffer, so
nginx answered 400 "request header or cookie too large" before the
request reached the /apis, /api or /k8s/ upstream.

Raise both to 16k, at the top level of that config rather than inside the
server block: a header field read before the Host header has selected the
virtual server is measured against the default server's buffers, so the
same lines inside a server block cover that server only while it stays
the default one. Measured against the pinned nginx base image, a 12 KB
cookie gets 400 on the old config and 200 on the new one. The ceiling
moves rather than disappears: a 20 KB cookie is still rejected.

This is the console hop alone. The platform ingress-nginx controller in
front of it runs on the same defaults, so where the dashboard is published
through an Ingress a token large enough to exceed them is still rejected
at the edge; where it is published through the gateway, whose edge has no
per-header ceiling of this kind, the console was the hop returning the
400. Raising the controller is a separate change in a separate package.

The accompanying check extracts the config from the Containerfile heredoc
and fails if either directive is missing, below 16k, or no longer ahead of
the first server block: the config lives inside an image build, where no
chart template and no helm-unittest case can reach it.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-09-22 21:43:23 +03:00
Aleksei Sviridkin 12e64a99cd fix(rabbitmq): right-size the default resources preset to s1.nano (#3936)
## What this PR does

Raises the RabbitMQ default resource preset from `t1.nano` (128Mi
memory) to `s1.nano` (250m CPU / 512Mi memory).

A default-sized RabbitMQ 4.2 broker on Cozystack 1.6.1 was OOMKilled
with exit 137, reached 10 restarts, and never became Ready. A canary on
a larger preset reached 3/3 Ready with zero restarts; its working set
peaked at 125.8Mi. Against the 128Mi `t1.nano` ceiling that is 98% of
the limit in steady state, and cgroup accounting (working set plus page
cache) crosses it under load. The canary and its storage were removed
after validation.

### Sizing

`s1.nano` keeps the CPU of `t1.nano` (250m) and quadruples memory to
512Mi — a 4x margin over the observed 125.8Mi peak.

An earlier revision of this PR proposed `u1.nano` (1Gi). Review
correctly objected that 1Gi reserves 8x the observed working set with no
measured peak to justify it, and asked to either report that peak or
right-size the default. The peak is reported above, and the default is
right-sized to the smallest preset that clears the ceiling with a real
margin rather than to the first one that is comfortably large.

### Upgrade impact

cozystack-api applies OpenAPI schema defaults on the read path and
stores what the client sent: `Get` runs `applySpecDefaults` on its way
out (`pkg/registry/apps/application/rest.go:1232`) and the write puts
`app.Spec` into `HelmRelease.spec.values` (`rest.go:1652`). That splits
existing brokers in two.

**Brokers with no stored `resourcesPreset`** pick up the new chart
default on the next Helm reconcile. For them this upgrade is:

- a rolling restart of every replica, and
- a rise in guaranteed memory reservation from 128Mi to 512Mi per
replica, because the sanitize helper sets memory request equal to limit
— roughly 1.1Gi extra reserved per 3-replica instance.

**Brokers whose values went through a read-modify-write keep `t1.nano`
and are not resized.** `Update` opens with `r.Get` (`rest.go:489`), so a
GET-then-PUT — `kubectl edit` is the unambiguous case, and any client
that reads before writing behaves the same — freezes the schema default
of the moment into the stored values, and a stored value beats the chart
default. Those brokers are not restarted, not resized, and keep hitting
the ceiling this PR raises.

Nothing downstream can separate a deliberate `t1.nano` from one a round
trip baked in, so this is documented rather than migrated. After the
upgrade the affected brokers are the ones that still report the old
preset:

```
kubectl get rabbitmq -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,PRESET:.spec.resourcesPreset
```

The same command before the upgrade tells you nothing: the cozyrd
default is still `t1.nano` then, so the read path fills it in for both
groups. Afterwards, anything reading `t1.nano` carries a stored value;
setting `resourcesPreset: s1.nano` explicitly on the ones that should
move is the fix.

PVCs are untouched, so there is no data loss, but node headroom should
be checked before upgrading.

Also worth knowing when reading the parameter table: the preset does not
only apply to a fully omitted `resources`.
`cozy-lib.resources.defaultingSanitize` merges it key by key, so a
broker pinned to `resources: {cpu: 700m}` keeps its CPU and moves from
128Mi to 512Mi with everyone else. The field descriptions now say so,
and a test pins it.

The values, generated schema, ApplicationDefinition, typed API, and
README all carry the same default. Tests cover the new default, an
explicit legacy override, explicit resources, and a partially set
`resources` map inheriting the preset for what it leaves out.

Validation:

- `helm template` with the chart's `cozy-lib` dependency renders `limits
250m / 512Mi` and `requests 0.025 / 536870912` for the default; an
explicit `t1.nano` renders `128Mi / 134217728`; explicit `700m / 2Gi`
renders `0.07 / 2147483648`. The unit test asserts exactly these values.
- Provider counterpart: cozystack/terraform-provider-cozystack#34.

### Screenshots

Not a UI change.

### Downstream repositories

The default is restated by the Terraform provider, so the linked
provider PR updates it and documents the state-plan implication. No
other trigger-map entry matches this diff.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [x]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
https://github.com/cozystack/terraform-provider-cozystack/pull/34
- [ ]
[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:

### Release note

```release-note
fix(rabbitmq): raise the default resource preset from t1.nano to s1.nano so default-sized brokers are no longer OOMKilled. Brokers with no stored `resourcesPreset` are restarted on upgrade and their guaranteed memory reservation grows from 128Mi to 512Mi per replica; check node headroom before upgrading. Brokers whose values already pin `resourcesPreset`, including ones where a read-modify-write through the API froze the old default into them, keep their old size: list them after the upgrade with `kubectl get rabbitmq -A -o custom-columns=NAME:.metadata.name,PRESET:.spec.resourcesPreset` and set `resourcesPreset: s1.nano` explicitly on the ones that should move. The preset also fills any resource a partially set `resources` leaves out, so a broker pinned to cpu alone moves too. A tenant that opted into `resourceQuotas` and sits near its memory ceiling has the extra reservation rejected by quota admission, which shows up as a StatefulSet that never scales rather than as pods left Pending.
```
2026-09-22 21:53:02 +04:00
scooby87 7d07bbe3ce [kafka] Migrate from ZooKeeper to KRaft mode (#2352)
## Summary

- Replace ZooKeeper-based Kafka deployments with KRaft (Kafka Raft)
metadata mode
- Existing ZooKeeper instances migrate automatically and in place via a
Helm `pre-install,pre-upgrade` hook Job that drives Strimzi's
ZK-to-KRaft migration state machine
- New instances deploy directly in KRaft mode with broker and controller
`KafkaNodePool`s
- The node pools are owned by the migration hook, not by regular chart
manifests (see "Why the pools are hook-managed")
- Kafka version is user-configurable (v3.9 default, v3.8 available)
- Strimzi operator is unchanged in this PR (stays at 0.45.1-rc1); 0.45.x
is the last line that supports ZooKeeper→KRaft migration
- ZooKeeper removed from the dashboard UI (ApplicationDefinition)

## Migration strategy

Both fresh installs and ZooKeeper→KRaft migrations are driven by a
single Helm hook Job (`templates/migration-hook.yaml`,
`pre-install,pre-upgrade`) that owns the `KafkaNodePool`s. On every
install and upgrade the Job:

1. Ensures both node pools exist (idempotent): a broker pool named
exactly `kafka` for a migrating cluster — so Strimzi adopts the existing
`<cluster>-kafka-N` brokers and their PVCs in place — or `b-<hash>` for
a fresh cluster, plus a controller pool `c-<hash>`. The controller pool
pins `strimzi.io/next-node-ids` above the broker range so the broker
pool keeps node IDs `[0..N-1]` and Strimzi cannot hand the existing
broker IDs to the fresh controllers. The shared `kafka` name is claimed
atomically (via `kubectl create`) so only one migration per namespace
can win it.
2. Inspects the Kafka CR: no CR → fresh install (pools ensured; the main
apply then creates the KRaft Kafka CR, nothing to migrate); already
`strimzi.io/kraft=enabled` or `status.kafkaMetadataState: KRaft` → done;
any other read error → fail closed. Otherwise (a ZooKeeper cluster) it
migrates.
3. Annotates `strimzi.io/node-pools=enabled` then
`strimzi.io/kraft=migration`, polls `status.kafkaMetadataState` through
`ZooKeeper → KRaftMigration → KRaftDualWriting → KRaftPostMigration →
PreKRaft → KRaft`, and only once a safe state is reached flips
`strimzi.io/kraft=enabled`. If it times out in an intermediate state it
aborts without finalising, so Helm fails the upgrade and the next
reconcile retries from where it left off.

Data is migrated in place: brokers keep their node IDs and reuse their
existing PVCs, nothing is copied. Migration is one-way — Strimzi has no
supported KRaft→ZooKeeper rollback once complete, so lowering the
`version` field or rolling the app back to a pre-KRaft chart is
unsupported (take a backup first).

### Why the pools are hook-managed

The hook must create the pools and walk the migration state machine
*before* the main release apply. A resource a hook creates cannot also
be a regular chart manifest across the ZK→KRaft boundary: Helm's main
apply finds the pool live in the cluster but absent from the previous
(ZooKeeper) release revision and aborts with `original object
KafkaNodePool ... not found`, leaving the release `failed` even though
the cluster migrated fine (reproduced under server-side apply, the
helm-controller default). Managing the pools only from the hook avoids
that, so `templates/kafkanodepools.yaml` and the deployed-version gate
ConfigMap (`templates/version.yaml`) are removed and the pools are
applied idempotently by the Job on every install and upgrade.

## Bug fixes included

- ZooKeeper `metricsConfig` referenced wrong ConfigMap key
(`kafka-metrics-config.yml` instead of `zookeeper-metrics-config.yml`)
- ZooKeeper `storageClass` used `kafka.storageClass` instead of
`zookeeper.storageClass`
- WorkloadMonitor used `.Values.replicas` instead of
`.Values.kafka.replicas`
- `validateNameLength` now caps a Kafka app name at the KRaft controller
pod-hostname budget (`<release>-c-<hash>-<id>` must fit 63 chars),
instead of admitting names that later fail the chart render forever

## What's next

A follow-up PR will upgrade Strimzi to 0.51.0 and Kafka to 4.2 once all
instances are confirmed migrated to KRaft. That PR is already prepared
on branch `KRaft-upgrade-strimzi-051`.

## Test plan

- [x] `helm template` renders correctly for new KRaft instances (no
ZooKeeper refs)
- [x] `helm template` with custom values (1 replica, external, topics,
v3.8)
- [x] Version validation rejects unsupported versions via JSON schema
- [x] helm-unittest: 86/86 across 9 suites
- [x] `hack/kafka-migration-hook.bats`: 12/12 — the real hook script
executed against a stub kubectl (resolution branches, fail-closed reads,
atomic collision guard, finalize guard)
- [x] Operator template renders with the unchanged Strimzi 0.45.1-rc1
- [x] Live migration on a disposable cluster under server-side apply:
fresh install → healthy KRaft, release `deployed`; in-place migration of
a 20000-message ZooKeeper cluster → release `deployed`, broker PVCs
adopted in place (same UIDs), and the KRaft data byte-for-byte identical
to the pre-migration ZooKeeper data (matching sha256 over every
`partition:offset:key:value`)

### Release note
```release-note
[kafka] Enable KRaft metadata mode with automatic, in-place ZooKeeper-to-KRaft migration. Kafka version is now configurable (v3.9, v3.8). The Strimzi operator is unchanged (0.45.1-rc1).
```

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

* **New Features**
* Added chart-level Kafka version selector (default v3.9) and
KRaft-aware node pool rendering with controller storage sizing.

* **Updates**
* Default Kafka appVersion updated to 3.9.0; operator and image tag
defaults aligned to 0.45.0.
* Templates now omit ZooKeeper resources and metrics when KRaft is in
use.

* **Tests**
* New Helm unit tests for Kafka CR, node pools, metrics, topics,
dashboard mappings, and workload monitors.

* **Documentation**
* Values, schema, and README updated to document new version and
controller storage options.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 19:19:21 +03:00
Aleksei Sviridkin ad4ea5c937 feat(keycloak): publish only the named realms on the login host (#4363)
## What this PR does

`ingress.adminHost` moves the admin console and Administration REST API
onto
their own hostname and narrows the public login route to `/realms`,
`/resources` and `/.well-known`. That `/realms` prefix publishes every
realm
the deployment has, `master` among them, so the super-admin login page
and
token endpoint stay reachable from the internet on the login hostname —
a
brute-force target the admin split was meant to remove. The Keycloak
reverse
proxy guide marks `/realms/master/` as internal-only.

The login route now enumerates the realms that are meant to be public:
the
platform realm (`authentication.oidc.realmName`, default `cozy`), which
every
component's issuer URL points at and which is therefore always
published, plus
whatever a deployment adds in the new `ingress.exposedRealms`.

Each realm is published as an exact path plus a prefix carrying the
trailing
slash. ingress-nginx renders `pathType: Prefix` as a plain nginx prefix
location rather than the element-wise match the Ingress API specifies,
so a
lone `/realms/cozy` would also serve `/realms/cozy-admin` there; the
pair
bounds the match on the segment and is equivalent to element-wise
matching on
a conformant controller and on Gateway API.

`master` is refused outright — both in `ingress.exposedRealms` and as
`authentication.oidc.realmName`, where the guard sits next to the
existing
realm-name checks so it applies whether or not a separate admin hostname
is
configured. Naming that realm puts the platform clients, the
cluster-admin
roles and every end user inside the realm that holds the Keycloak
super-admin.

This is a path boundary, not a network one. `KC_HOSTNAME_ADMIN` never
was a
security boundary, `expose-ingress-admin` defaults to the public
Gateway/ingressClass, and with `adminHost` unset the login route still
serves
`/`. Which hostnames the edge accepts and where the admin route attaches
decide the rest.

**Behavior change**, confined to deployments that already set
`ingress.adminHost`: a realm published on the login hostname beyond the
platform one now answers 404 until it is listed in
`ingress.exposedRealms`.
The `master` guard on `authentication.oidc.realmName` breaks nobody,
since
that parameter has not shipped in a release yet.

### Screenshots

Not applicable — 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:

Walked the trigger map against the diff: it touches
`packages/system/keycloak`
and the realm-name guard in
`packages/core/platform/templates/apps.yaml`. No
app package, no `packages/core/platform/values.yaml` key the Ansible
role
sets, no platform variant or component, no `ApplicationDefinition`, no
`hack/`
layout, no telemetry metric, no vendored chart contract.

### Release note

```release-note
feat(keycloak): with `ingress.adminHost` set, the login hostname publishes only
the platform realm and any realm listed in the new `ingress.exposedRealms`,
keeping the `master` realm login page and token endpoint off the public route.
A deployment that serves additional realms on that hostname must list them.
`authentication.oidc.realmName` no longer accepts `master`.
```


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

## Summary by CodeRabbit

- **New Features**
- Added `ingress.exposedRealms` to control which additional identity
realms are reachable through the login hostname.
- Login routes now target the platform realm and configured exposed
realms with precise realm-specific paths.
  - Duplicate realm names are handled automatically.

- **Bug Fixes**
  - Prevented publishing the privileged `master` realm.
  - Added validation for invalid realm names and configurations.
- Enforced the gateway route limit, supporting up to 31 published
realms.

- **Documentation**
- Updated configuration guidance for realm exposure and security
restrictions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 19:47:53 +04:00
scooby87 176dd78c1a feat(dashboard): serve console branding without kube-api access (#4256)
## What this PR does

Part of #4217. The SPA fetched its branding (title, logo) only by
reading the `cozy-dashboard-console-config` ConfigMap through the
kube-api. That read already works for any signed-in user —
`console-rbac.yaml` binds `get` on it to `system:authenticated` — but it
still depends on the kube-api being reachable and on the apiserver
authenticating the session's token. A dashboard login whose token the
apiserver rejects (an OIDC session the kube-api does not accept) gets no
branding at all. (The unauthenticated login page is a separate surface,
branded in #4255.)

This mounts that ConfigMap read-only under the nginx web root and serves
it at `/branding/config.json`, and reads that static asset first in
`loadConfig`, falling back to the kube-api ConfigMap for charts that
predate the mount (their static path serves the SPA `index.html`, whose
non-JSON body trips the fallback). Branding then resolves with no
kube-api call at all, so it renders regardless of whether the apiserver
authenticates the session and without the `console-config-reader` RBAC.

Because `config.json` is now a static asset reachable by anyone past the
proxy, it is restricted to the documented white-labeling keys: the
branding map also carries Keycloak-only keys, including
`loginThemeImage`, which can point at a private registry. Keycloak reads
those from `_cluster.branding` directly. The mount uses an `items`
selector so only `config.json` is exposed under the web root.

Verified with `pnpm typecheck`, `pnpm test` (7 `loadConfig` cases),
`eslint`, and `helm unittest` (mount + `items`, the `config.json` key
the mount serves, white-label keys kept incl. `tenantText`,
Keycloak-only keys absent). Also validated live on a dev cluster:
`console-rbac.yaml` binds the ConfigMap read to `system:authenticated`
(`kubectl auth can-i get` this CM as an unbound user → yes; another CM →
no), and a throwaway pod on the real console image serving the mounted
ConfigMap returns `200 application/json` at `/branding/config.json`
while an `items`-excluded key falls through to `index.html`.

### Screenshots

No visual regression to show in a static render: this changes where the
branding config is fetched from, not how it is displayed.

### Downstream repositories

The diff touches only `packages/system/dashboard` (the in-repo console
image and its chart). No app is added, renamed or removed, no
`values.schema.json` / enum / default changes, no CRD or namespace
changes, and the branding keys the SPA reads are unchanged — only the
transport (static asset vs kube-api) and a narrowing of which keys are
served. Nothing in 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
feat(dashboard): the console serves its branding as a static asset (`/branding/config.json`) read with no kube-api call, so branding renders even when the apiserver does not authenticate the session and without the console-config-reader RBAC; the served file is narrowed to the documented white-labeling keys.
```
2026-09-22 18:36:47 +03:00
Aleksei Sviridkin 9efe78ce44 test(e2e): hold the tenant-cluster install wait to an ordering rule (#3802)
A test that creates a tenant `Kubernetes` cluster must not end while
that release is still installing. The kind drops the install wait on its
main resources, but the chart's blocking post-install hook still holds
the install open, so a test that asserts and ends hands the rest of it
to teardown. Teardown then reds on a step that tests nothing. Reading
the cluster mid-install is fine. Ending mid-install is not.

`hack/e2e-chainsaw/_lib/run-kubernetes.sh` already waits for the parent
release before its tenant-cluster assertions, and that wait is older
than this change. Nothing held it there. This adds the guard that does.

The guard reads the script, not Chainsaw fixtures: the cluster comes
from a heredoc, so a guard walking `apply.file` would find nothing to
check and pass. It requires the CR, then a readiness wait on the parent
release, then the assertions the test ends on. The wait has to block,
and it has to be unconditional in the body that holds it. One more case
holds this script to being the only creator of that kind, since a second
one would be governed by no rule here.

The ordering is read within one function body, so splitting
`run_kubernetes_test` reds the unit lane until the rule is pointed at
the new shape.

Timeout length stays with review. The floor depends on where the wait
sits, and the script text does not carry that.

Which spellings each matcher takes, which rewrites it refuses instead of
judging, and the blind spots it names are written in the guard's header
next to the code, each with its mechanism and whether it fails loudly or
quietly. Fixtures mark their own lines, so a probe resolves by name
instead of by a line number that drifts.

No runtime code here: the guard, its fixtures, and the conventions that
state the rule.

```release-note
NONE
```
2026-09-22 19:00:52 +04:00
myasnikovdaniil 41ef4a6437 fix(ci): teach the overlay to repair an unstamped images/*.tag ref (#4362)
## What

`hack/overlay-main-images.sh` walks `images/*.tag`, but every branch of
its line classifier needs either a YAML key or an `@sha256:`. A `.tag`
file holds one bare reference and nothing else, so until a build stamps
it the line has neither, the drift guard reads it as a non-ref change,
and the committed reference survives.

For a package onboarded with the `:v0.0.0` placeholder this repo already
uses for a new image, that surviving reference is one no registry
serves. The overlay is the only thing that would replace it for a PR
that does not rebuild the package, so once such a package is on main
every full-suite run that skips its build keeps the placeholder. The
same placeholder inside a `values.yaml` repairs itself, because there it
sits under an `image:` key the classifier recognises. The difference is
the file shape, not the placeholder.

## Reproduction

A fixture holding a committed bare tag against an artifact copy carrying
a stamped one:

```
$ cd fixture/fakerepo && sh ../../hack/overlay-main-images.sh ../mainpkgs '[]' ''
overlay: packages/system/x/values.yaml -> current-main
drift (non-ref change) in packages/apps/x/images/x.tag -> keeping committed ref
```

Both files differ only in their reference. The `values.yaml` one is
repaired; the `.tag` one is not. Adding any digest to the same
placeholder makes it pass, which is what narrows this to the classifier
rather than the file.

## Why it has not bitten yet

17 of the 19 `.tag` files in the tree carry `@sha256:` and pass on that
branch alone. The only other digest-less one is
`packages/extra/seaweedfs/images/seaweedfs-cosi-driver.tag`, and it
survives only because it is third-party: `build-main` never rebuilds it,
the artifact copy is byte-identical, and the classifier is never
reached. The first digest-less first-party `.tag` is what turns the gap
live, and one is coming in #3426.

## The fix

`hack/promote-rewrite-tags.sh` already carries a second match branch for
exactly this shape, with a comment saying why ("the second branch is
what catches a bare `.tag` file, whose content has no YAML key at all").
This gives the overlay the same one, scoped to `*.tag` so an unkeyed
line in a `values.yaml` still counts as drift, because only in a `.tag`
file is a whole line known to be a reference and nothing else.

Two tests in `hack/overlay-main-images_test.bats`: the unstamped
placeholder is overlaid, and a `.tag` whose non-reference line differs
still counts as drift, so the rule cannot quietly widen into "every line
in a `.tag` file is a reference". Removing the fix fails the first one.

```release-note
NONE
```


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

- **Bug Fixes**
- Fixed image overlay handling for `.tag` files containing bare image
references, allowing current references to be applied correctly.
- Preserved drift detection when `.tag` files also contain unrelated,
non-reference changes.

- **Documentation**
- Clarified how image-reference tooling handles bare references and
package-tree processing.

- **Tests**
- Added coverage for bare-reference overlays and mixed reference/comment
changes.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 18:53:28 +05:00
Yan Bondarenko 78f01d5542 docs(rabbitmq): point the preset section at the shared size matrix
The preset table in this README listed the seven legacy aliases only, and
its CPU column disagreed with cozy-lib on every row, so a reader looking up
what the new s1.nano default buys them found neither the name nor a correct
number. Nine app READMEs already replaced that table with the two paragraphs
that describe the <series>.<size> convention and link the full matrix in
docs/operations/resource-presets.md; this README now carries the same text.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-09-22 17:47:55 +04:00
Yan Bondarenko 6d5666f7e6 fix(rabbitmq): describe the preset as filling what resources leaves unset
cozy-lib merges the preset under resources key by key, so a partially set
resources map still takes the preset for everything it omits: with
resources.cpu=700m alone the broker renders 700m of CPU against the
preset's 512Mi of memory, and this upgrade moves that broker from 128Mi to
512Mi as well. The description said the preset applies when resources is
omitted, and cozyvalues-gen copies it verbatim into values.schema.json, the
README parameter table and the cozyrd openAPISchema the dashboard renders,
so one sentence made the claim on three surfaces.

The suite covered a fully omitted resources map and one that sets both cpu
and memory, which is the one shape that does not exercise the merge. The
new case pins it: reverting defaultingSanitize to replace the preset
instead of merging over it turns that case red and leaves the other three
green.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-09-22 17:47:55 +04:00
Yan Bondarenko 03394bd5fe chore(rabbitmq): drop the test target the rebase duplicated
main already carries a test target at the bottom of the Makefile; the rebase
kept the earlier copy at the top and GNU make warns about the override. The
Makefile matches main again.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
2026-09-22 17:47:55 +04:00
Yan Bondarenko cf749988a4 fix(rabbitmq): right-size the default resources preset to s1.nano
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
Assisted-by: LLM
2026-09-22 17:47:55 +04:00
Aleksei Sviridkin c0ff783026 fix(hack): make bats unit tests pass on a BSD/macOS checkout (#4284)
## What this PR does

Refs #4272 (Defects 1 and 2). On a clean checkout of `main`, `make
unit-tests` is red out of the box on macOS for reasons that have nothing
to do with the change under test: the BSD userland shipped with macOS
differs from the GNU tools on the Linux CI runners, and CI never sees
any of it. This PR closes the two worst of those, both scoped to
`hack/`.

**Defect 1 — the runner cannot parse a non-ASCII `@test` title.**
`hack/cozytest.sh` rebuilds each test's function name by walking its
title one character at a time with awk `substr()`. BSD awk aborts that
walk on the first multibyte byte (`towc: multibyte conversion failure`)
rather than returning it, so a file carrying a non-ASCII `@test` title
never parses and not one of its tests runs — silently, because the suite
only reports that the runner errored. Four `hack/*.bats` files carry
such a title today. The fix pins `LC_ALL=C` on all three awk passes
(title parse, run selection, and the exit-code scan of the captured log)
so each reads the input byte-wise; the parse and selection passes must
share the ctype or they would derive mismatched function names for one
title. A new regression test, `hack/cozytest-nonascii-title.bats`,
builds a multibyte-titled fixture at runtime and asserts the runner
actually runs it; it is red against the pre-fix runner
(mutation-verified) and green after.

**Defect 2 — GNU-only `sed -i`.** `hack/nightly-mirror.sh`,
`hack/promote-rewrite-tags.sh`, and the fixture builder in
`hack/promote-rewrite-tags_test.bats` edit files in place with `sed -i`.
BSD sed reads the argument after `-i` as a mandatory backup suffix, so
`sed -i -e` and `sed -i -E` swallow the following flag as that suffix
and the edit either errors or silently no-ops. Each is rerouted through
a temp file, portable to both seds. The `nightly-mirror.sh` rewrite
additionally relied on the GNU `\?` optional quantifier, which BSD BRE
reads as a literal `?` so a bare host was never matched; it is replaced
with the POSIX `\{0,1\}`, equivalent on both. All three suites are green
on macOS after the change, and behaviour on GNU sed is unchanged.

### Scope

This PR is deliberately scoped to Defects 1 and 2. Defect 3 from the
issue — a GNU-only `date -d` in `hack/seaweedfs-naming-audit.sh` — is
tracked separately as #4273 and is left untouched here.

For transparency: with Defect 1 fixed, several `hack/*.bats` suites that
previously never ran now run, and a handful still fail on macOS because
they depend on GNU coreutils `timeout`, which base macOS lacks
(`capture-dataplane`, `cozytest-capture-gate`,
`run-kubernetes-join-timing_test`, `run-kubernetes-runner-cpu_test`,
`runner-identity`). Those failures are pre-existing — identical before
and after this change when the runner is swapped in place — and are a
distinct defect from the two fixed here, so they are out of this PR's
scope. A fully green `make unit-tests` on macOS additionally depends on
#4273 and on that separate `timeout` gap.

### Verification

All fixes were verified on a genuine macOS host (Darwin, BSD awk
20200816 / BSD sed). `hack/cozytest-nonascii-title.bats`,
`hack/nightly-mirror_test.bats` (5 tests), and
`hack/promote-rewrite-tags_test.bats` (17 tests) are green; the two
files the issue reports as running zero tests
(`overlay-main-images_test.bats`, `promote-gate-contract.bats`) now
yield 13 and 15 `Test OK`, matching the issue's numbers. Each fix is
mutation-proven: reverting it turns the corresponding suite red again.

### Downstream repositories

The diff touches only internal `hack/` tooling — the bats test runner
and two release scripts. No downstream repository vendors or restates
these: `cozystack/ccp` and `cozystack/external-apps-example` gate on
`hack/package.mk`, `hack/common-envs.mk` and `hack/update-crd.sh`, none
of which this PR changes, and nothing renames or moves a file or alters
what a make target does.

- [x] No downstream repository is affected by this change

### Release note

```release-note
fix(hack): make the bats unit-test runner parse non-ASCII `@test` titles under BSD awk, and route the in-place edits in `nightly-mirror.sh` and `promote-rewrite-tags.sh` through a temp file so they work under BSD sed — closing two of the host-tool gaps that make `make unit-tests` red on a clean macOS checkout
```


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

* **Bug Fixes**
* Improved test runner compatibility with non-ASCII test titles and
output.
* Improved text-processing and file-rewrite behavior across BSD and GNU
environments.
  * Preserved file permissions and metadata during automated rewrites.
* Improved handling of host values and release tags across supported
platforms.

* **Tests**
  * Added coverage for non-ASCII test titles.
  * Updated rewrite tests for portable BSD and GNU tooling.

* **Documentation**
  * Clarified supported BSD and GNU command-line tool compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 17:37:41 +04:00
Alexey Artamonov bad152443e fix(kafka): correct the stale co-namespaced migration render error
The brokerPoolName render guard still told operators to "migrate one at a time
or use separate namespaces" when a sibling cluster owned the shared "kafka"
pool. That predates automatic name freeing: the migration hook now drains the
first cluster off the shared pool with a Cruise Control rebalance and releases
the name, and the waiting cluster's HelmRelease retries into it — every
co-namespaced Kafka reaches KRaft, no manual action required. Reword the fail
message and the helper comment to describe the transient wait-and-retry, and
update the unit test's error pattern to match.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-22 16:05:44 +03:00
Alexey Artamonov 0b9332877e test(kafka): drop the false-green ZK->KRaft migration chainsaw suite
The kafka-zk-to-kraft-migration suite did not exercise the pre-upgrade hook,
it reimplemented a simplified flow beside it: a controller pool named
"controller" instead of the hashed c-<hash>, no strimzi.io/next-node-ids pin,
and a single broker so the controller-vs-broker node-id collision could never
occur. That is exactly the defect the hook exists to prevent, so the suite
stayed green on a revision whose in-place migration lost every message —
reproduced by hand 2/2 on a live cluster. A suite that cannot fail on this
code is worse than no suite: it reads as migration coverage and invites trust
it has not earned, while costing ~380s on every Kafka PR and asserting only
that a PVC object exists, never reading a record back. The migration hook's
bats suite and the live upgrade runs are the real coverage; the Strimzi bump
would delete this suite regardless.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-22 16:05:44 +03:00
Aleksei Sviridkin 1c88014661 fix(installer): keep node_modules out of the packages artifact (#4290)
## What this PR does

`flux push artifact` walks the whole `packages/` tree and reads neither
`.gitignore` nor `.sourceignore`, so a working copy where somebody ran
`pnpm install` under the vendored console ships the console's dependency
tree inside the bundle. Helm then refuses the dashboard chart on every
cluster that pulls it, because one dependency file sits above the 5MB
per-file limit, and the build itself reports nothing:

```text
Could not load chart: decompressed chart file "dashboard/images/console/node_modules/.pnpm/@rolldown+binding-darwin-arm64@1.0.0-rc.15/node_modules/@rolldown/binding-darwin-arm64/rolldown-binding.darwin-arm64.node" is larger than the maximum file size 5242880
```

Passing `--ignore-paths` replaces flux's built-in list rather than
extending it, so the defaults are restated alongside `node_modules/`.
`hack/check-packages-artifact-ignores.bats` holds both halves: dropping
`node_modules/`, dropping one of the defaults, or declaring the variable
without passing it to the recipe each turn the test red. Its second case
re-reads the defaults out of the installed flux, so an upstream addition
surfaces as a failure rather than as a pattern quietly missing from the
artifact.

Measured on a tree with the console's dependencies installed: the
artifact goes from 80MB carrying 32397 `node_modules` entries to 6.7MB
carrying none, with the dashboard chart still in it.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change

The two workflows that push the same artifact themselves
(`e2e-fork.yaml`, `nightly.yaml`) run from a clean CI checkout, where
the tree has no `node_modules` to pick up.

### Release note

```release-note
fix(installer): the packages OCI artifact no longer picks up node_modules from a developer's working copy, which made the dashboard chart unloadable on every cluster that pulled the bundle.
```


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

* **Bug Fixes**
* Package artifacts now exclude unnecessary files, including
version-control metadata, common media and archive formats, and
dependency directories.
* This helps prevent oversized files from exceeding Helm’s per-file size
limit.

* **Tests**
* Added validation to ensure package artifact ignore patterns remain
complete and aligned with the packaging tool’s defaults.
* Optional checks report when the packaging tool is unavailable without
failing the test suite.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 16:17:52 +04:00
Aleksei Sviridkin b18281ef0c feat(dashboard): serial console for virtual machines, and paste into the VNC console (#4356)
## What this PR does

Adds a serial console tab to the VM detail page, and makes the VNC
console accept a paste.

Moving text into a VM was the starting point, and the two consoles
answer it very differently. The VNC console carries pixels and key
events and nothing else, so a paste there has to be typed, one emulated
key press per character. The serial console carries text, so a paste is
a single write and the guest's output is real text the user can select
and copy.

Measured on a running VM, 1000 characters, checked by piping the pasted
string through `md5sum` in the guest and comparing with the digest
computed locally:

| | time | integrity |
| --- | --- | --- |
| serial console | **0.87 s** | digest matched |
| VNC, 25 ms per key event | 56.6 s | digest matched |
| VNC, no pacing | 10.3 s | **characters dropped and reordered** |

The VNC rows were taken by driving the typing loop directly rather than
through a real keypress, so they measure the typing and not the
shortcut. The pacing is the measured floor either way: with none, the
guest loses and reorders characters.

### Serial console

New tab backed by KubeVirt's `virtualmachineinstances/console`
subresource and xterm.js. A VM's tabs now lead with its two consoles —
serial first, labelled Console, with VNC beside it — because reaching a
console is why people open a VM. VNC keeps its place: the serial port
does not reach a desktop session, a bootloader, or a Windows guest, and
Windows guests are supported here, down to their own scheduling in the
VM charts.

Copy stays on the terminal's own chord, Ctrl+Shift+C or Cmd+C, so a
plain Ctrl+C still interrupts the foreground process. Paste needed one
thing handled, and only off a Mac: xterm turns Ctrl with a letter into a
control byte and cancels the keydown, so Ctrl+V never reached the
browser's paste and the guest received SYN (0x16) instead. Reproduced on
a real terminal, where the shortcut put a single `0x16` on the wire and
nothing else. The key handler now returns that chord to the browser, at
the cost of the terminal's quoted-insert. On a Mac the browser pastes on
Cmd+V, so there the terminal keeps the key.

One detail worth knowing before touching this code: virt-api negotiates
the `plain.kubevirt.io` subprotocol and reads **binary frames only**. A
text frame is accepted by the socket and then silently dropped, which is
indistinguishable from a dead console. That is why the stream is a small
module of its own with its own tests, rather than xterm's stock attach
addon, which sends text.

### Paste in the VNC console

The graphical console still matters where the serial port cannot reach —
a desktop session, a bootloader, Windows — so a paste works there too,
typed key by key.

**The shortcut is the platform's own: Cmd+V on macOS, Ctrl+V everywhere
else.** That means Ctrl+V no longer reaches the guest on Linux and
Windows, where it is visual block in vim or the guest's own clipboard.
Taking both chords bought nothing, because no browser pastes on Ctrl+V
on a Mac, and cost the guest a key it has its own use for.

Nothing is added to the interface: the toolbar's existing status line
reports `Pasting 12/270` while the text goes in, then returns to the
connection state.

Four constraints shaped the rest, each found by running it rather than
by reading:

- `navigator.clipboard.readText()` puts a permission prompt in front of
**every** paste. Instead the shortcut moves the focus to a hidden field
and lets the browser paste into it, which costs nothing and asks
nothing.
- noVNC calls `preventDefault()` on keydown. Letting the shortcut reach
it would cancel the browser's paste outright, so the shortcut is taken
on the capture phase and only its propagation is stopped. If no paste
follows, the focus returns to the console instead of being parked in an
invisible box.
- The paste starts while the user is still holding the chord, and noVNC
told the guest that modifier is down the moment it was pressed. Typing
into that state sends chords rather than characters — under Ctrl an `m`
is Return — so the host's modifiers are released before the first
character. On Windows noVNC sits on the first Ctrl for 100 ms and
delivers it on a timer, after that release has already happened, so the
release is sent once more when the pacing has covered that window.
- A character the keymap cannot produce changes what the rest means, and
the newline after it still submits: `rm -rf /srv/данные` would become
`rm -rf /srv`. Nothing is sent unless the whole paste can be typed, and
the toolbar says how many characters were in the way.

The keymap covers US only. A guest in another layout is the case the
serial console answers, where text travels as bytes and no layout is
involved.

### Screenshots

The serial console on a running VM: the tabs lead with it, the terminal
is live, and the middle line was pasted from the browser clipboard.

<img width="2252" height="1606" alt="cozystack-serial-console"
src="https://github.com/user-attachments/assets/6fac5f95-c142-405b-9b54-8ed040d65167"
/>

### Downstream repositories

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

<!-- The diff touches only packages/system/dashboard/images/console.
Walked the trigger map in
docs/agents/contributing.md file by file: no entry matches a
console-only change, and the map
states outright that UI changes belong in this repository, in the same
PR. -->

### Notes for the reviewer

- New dependencies: `@xterm/xterm` and `@xterm/addon-fit`. The tab is
split at the route with `React.lazy`, the way the YAML editor already
is, so both land in a 347 KB chunk fetched when a console is opened.
Built both revisions with the same `node_modules`: the entry chunk every
dashboard page loads goes 935.91 KB → 896.39 KB, so it ends up smaller
than before this branch.
- The serial console needs a getty on `ttyS0` in the guest. Cloud images
enable it by default; a Windows guest or a graphical desktop is the VNC
console's job.
- The serial console opens with the user's own identity — nginx forwards
the session's `Authorization` untouched — and
`virtualmachineinstances/console` is already granted next to `/vnc` in
`cozy:tenant:use:base`, so no RBAC change is owed.
- Verified against a live VM on a dev cluster: connection, typing, a
1000-character paste round-tripped through `md5sum` on the serial
console, text typed before the serial socket opens (held and flushed), a
real Ctrl+V on the VNC console arriving intact, and two pastes in quick
succession (the second is refused rather than interleaved).
- The Windows modifier path is read from the pinned noVNC in
`node_modules`, not run: there is no Windows host here. The test fake
models that delivery, so the behaviour is at least held by a test.
- There is no cancel affordance for a paste in progress. It stops on its
own when the session drops or the tab is left, and the toolbar then says
how far it got; Reconnect is the manual way out. A length cap is worth
adding separately — at 25 ms per character a large clipboard types for a
long time.
- 418 tests pass; build and typecheck are clean. `eslint .` reports 54
pre-existing problems across twenty files, none of them in the files
this PR touches.

### Release note

```release-note
feat(dashboard): virtual machines gain a serial console tab, where pasting is instant and the output can be selected and copied. The VNC console now pastes the host clipboard on the platform's own shortcut — Cmd+V on macOS, Ctrl+V elsewhere — typing it into the guest on a US keyboard layout; Ctrl+V no longer reaches the guest on Linux and Windows.
```


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

- **New Features**
- Added a serial console for running virtual machines, including
terminal input, output, resizing, reconnection, and connection status.
- Added clipboard paste support to the VNC console with keyboard-layout
handling, progress feedback, and unsupported-character reporting.
  - Added platform-aware paste shortcuts for macOS and Windows/Linux.

- **Improvements**
  - Console content now loads on demand with a loading indicator.
  - Added handling for stopped and unsupported virtual machine states.

- **Documentation**
  - Documented keyboard, clipboard, and console testing behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-22 12:39:03 +04:00
Kirill Ilin 938595afe3 fix(keycloak): validate the realm list wherever it is set
The list was read only inside the adminHost branch, so a value the chart
would refuse — master, a scalar, a name that splits the path — sat in the
values unnoticed until someone turned the admin hostname on, and the refusal
then landed on the change of authentication topology rather than on the edit
that caused it. Build the list on every render and let the branches use the
result.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:54:28 +05:00
Kirill Ilin 13a4029b8b fix(keycloak): count the realms the route budget rejects
The over-budget message derived the realm count from the path list, which
also carries the two static paths, so it named one realm more than the
deployment has — the one number an operator acts on. Keep the realm list in
its own template and count it there, and derive the budget from the static
paths rather than restating 31.

The shape guard also let a falsy scalar through, so `exposedRealms: false`
reached range and failed with a Go template error instead of the message that
says what to write.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:44:08 +05:00
Kirill Ilin 714ced9bab fix(keycloak): refuse more realms than a route rule can match
A Gateway API route rule takes 64 path matches and each published realm takes
two of them, so past 31 realms the apiserver rejects the whole HTTPRoute and
the login hostname stops answering. Fail while rendering, naming the
parameter to shorten, instead of leaving the limit in a comment. The Ingress
path has no such cap, so the check lives with the route.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:35:37 +05:00
Kirill Ilin c96fe3d3ef fix(platform): refuse master as the OIDC realm name
The realm named here is where keycloak-configure creates every platform
client and the cluster-admin role, and where dashboard users sign in. Naming
master puts all of that inside the realm that holds the Keycloak super-admin,
and publishes its login page wherever the platform realm is published — and
the guard belongs where the value is set, since the Keycloak chart only reads
it once a separate admin hostname is configured.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:35:31 +05:00
Kirill Ilin e87232b822 fix(keycloak): always publish the platform realm and never master
exposedRealms replaced the published realm instead of adding to it, so a
deployment naming only its back-office realm took its own login off the
public route: every component's issuer URL points at the platform realm, and
they would all have met a 404. Publish the platform realm unconditionally and
deduplicate, which is also what the parameter's description promised.

Refuse master in either position rather than warning about it in a comment —
publishing it is exactly what the realm enumeration exists to prevent.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:24:58 +05:00
IvanHunters 0b8296d689 fix(dashboard): release the held modifier before the first character, not after some
The window this had been measuring started before the paste did. noVNC
arms its timer on the keydown, and the modifier is delivered once — by
that timer or by the next keyup, whichever comes first, and the V keyup
is not intercepted. Both land within 100 ms of the keydown, which at the
default pace is somewhere inside the opening releases.

Counting from the end of those releases therefore started the clock
again and let three characters through while the guest still held Ctrl,
where an m is Return. The second release now waits out whatever is left
of the window, measured from the keydown itself, and happens before any
character goes in.

The test that was written for this pinned the wrong placement: it handed
the modifier over after the first character, later than noVNC can, and
the fake's method was the immediate one under a second name. The fake
now delivers on its own schedule, partway through the opening releases,
so a test cannot choose the moment.

The component's own typing pace had no test at all once every existing
one passed its own value, so setting the default to zero left the suite
green. One test renders without the prop and holds it.

The lifecycle tests key on characters typed rather than on a count of
sleeps, which is what let them drift past their code when the opening
releases changed shape.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-22 08:21:56 +03:00
Kirill Ilin 64229b154e fix(keycloak): bound each published realm path to a path segment
ingress-nginx renders `pathType: Prefix` as a plain nginx prefix location
instead of the element-wise match the Ingress API specifies, so a lone
/realms/cozy also served /realms/cozy-admin — a realm the chart claims is
unpublished. Publish each realm as an exact path plus a trailing-slash
prefix, which bounds the match on every controller and on Gateway API.

While here, reject a scalar in place of the realm list instead of failing
inside range, and point a malformed platform realm name at the parameter
that carries it rather than at exposedRealms.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:17:00 +05:00
Kirill Ilin 5149e67dd7 feat(keycloak): publish only the named realms on the login host
The narrowed login route carried a bare /realms prefix, so it also published
realm master: its token endpoint accepted super-admin credentials from the
internet. Enumerate the published realms instead — the platform realm by
default, ingress.exposedRealms when a deployment serves more than one.

Behavior changes only where ingress.adminHost is already set.

Assisted-By: LLM
Signed-off-by: Kirill Ilin <stitch14@yandex.ru>
2026-09-22 10:08:07 +05:00
Aleksei Sviridkin cd91627c78 feat(marketplace): register a tapped repository's apps on connect (#4308)
## Problem

Connecting a marketplace repository materialized its `PackageSource` but
created no `Package`, so its `ApplicationDefinition`s never rendered and
its apps never appeared in the dashboard catalog until a manual `cozypkg
add`. The dashboard cannot drive that step: the package list it shows is
computed from the `ApplicationDefinition`s, which do not exist yet, a
chicken-and-egg that leaves a connected repository unbrowsable.

## Fix

The tap materializer creates a tap-managed registration `Package` for
each materialized `PackageSource` that has a `default` variant, the same
way the platform ships a `Package` per built-in app. Its install-marked
components (the `ApplicationDefinition` registrations) deploy on
connect, so the apps become browsable; the app components carry no
`install` block and are still instantiated per user resource, so
registration deploys no user workload.

Privileged install components are not installed without confirmation.
The check is at the install site: the Package reconciler skips a
privileged install component of a Package that still carries the
marketplace-tap label (a tap auto-registration the operator has not
confirmed) and reports `Ready=False PrivilegedNotConfirmed`, and
`resolvePrivilegedNamespaces` gates the PodSecurity label on the same
predicate. `cozypkg add --allow-privileged` sheds the label (an explicit
ownership handover), which is the confirmation; a platform Package never
carries the label. Putting the check where the install happens closes
the window a materializer-side guard would race, so the earlier
install-safety de-register machinery is removed.

Two further best-effort layers close the paths a lingering artifact or
release could take when a source revision flips a previously benign
component to privileged: `cleanupOrphanedHelmReleases` treats an
unconfirmed privileged component as not-desired and removes a
HelmRelease left from an earlier benign revision, and the PackageSource
reconciler withholds a privileged component's `ExternalArtifact` until
confirmed (re-running on confirmation through a Package watch), so the
helm-controller has no privileged content to upgrade to. A component
flipped to privileged in a new revision can still be materialized by
source-watcher before any reconciler observes the flip; closing that
race fully requires decoupling the catalog registration from install,
tracked in #4359.

`cozypkg untap` and the dashboard disconnect remove the registration
`Package` too, so the apps de-register (its registration HelmReleases
and their `ApplicationDefinition`s are garbage-collected); running
instances are left in place but unmanaged until re-tapped, the same
outcome as `cozypkg del`. Teardown deletes the Package under a UID +
ResourceVersion precondition with a re-classify-on-conflict retry, so it
never clobbers a Package a concurrent `cozypkg add` handover has just
confirmed. `cozypkg add` re-opens a tap auto-registration for variant
selection and hands it over to the user.

## Verification

- The install-site privileged gate is covered by a Package-reconciler
test (a managed registration with a privileged default variant creates
no privileged HelmRelease and does not raise the namespace; a confirmed
Package installs) and is mutation-verified.
- The two best-effort layers each have a mutation-verified test: cleanup
of a HelmRelease left when a benign component flips to privileged, and
withholding of a privileged component's `ExternalArtifact` while the
registration is unconfirmed (a non-tap platform source is never gated).
- The `cozypkg add` handover is covered by a test asserting the tap
label, the source annotation and the PackageSource ownerRef are shed and
the variant pinned.
- The teardown delete precondition is covered by a test in which a
handover lands between the read and the delete; the precondition makes
the delete conflict and the retry re-classifies and spares the user's
Package.

Earlier end-to-end on a dev cluster (predates the install-site refactor
and the layers above) with a real public demo repository
`oci://docker.io/999669/cozy-gitea:v1.0.0` confirmed the
connect→auto-register→instance→disconnect flow: `cozypkg tap` alone
registered the app within ~10s; a `Gitea` instance reached Ready and
served `/api/healthz`; `cozypkg untap` de-registered it and left the
running instance. etcd healthy, `cozystack-platform` untouched.

```release-note
Tapping a marketplace repository now registers its applications in the catalog on connect, without a manual `cozypkg add`.
```
2026-09-22 01:41:34 +04:00
IvanHunters 92b8df076c fix(dashboard): a paste could still type chords on a Windows host
Windows is the platform where noVNC holds the modifier back: the first
Ctrl keydown tells the guest nothing, arms AltGr detection and starts a
100 ms timer, and Ctrl reaches the guest when that timer fires. Taking
the shortcut on the capture phase hides the V from noVNC, so the timer
is what delivers — after the paste released a modifier the guest had not
yet been told about. Everything typed between the two goes in as chords.

The release is now sent a second time, once the pacing has covered that
window. It happens once rather than per character, and it leaves Shift
alone, because that one is held deliberately for capitals.

Two tests had drifted past the code they are named for. Both dropped the
session on the first sleep, which since the prelude lands before
anything is pressed, so they held whatever the typing loop did: removing
the session check from the loop left them green. They drop it after a
character now, and a third covers the closing release, which no test
reached at all.

The fake learns the Windows path it could not express, and decodes
function keysyms: Enter is 0xff0d, and treating it as a Unicode offset
produced a negative code point, so the first test to paste a newline
would have thrown instead of failing an assertion.

The typing pace is injectable, so tests no longer run at the speed of a
real keyboard and stop crowding their neighbours out on timeouts.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 23:48:25 +03:00
IvanHunters 6209a0b8d3 refactor(dashboard): code-split the serial console at the route
The tab pulled xterm through a dynamic import inside its own effect,
which split the chunk but left the stylesheet on a fragile path: the dev
server failed to fetch it once after a dependency rebuild, and the tab
came up with the terminal missing.

Splitting at the route instead is what the YAML editor next door already
does. The imports go back to plain ones, React.lazy gives the tab its
own chunk, and the stylesheet travels with it rather than through an
import() of a CSS file.

The entry chunk every dashboard page loads ends up smaller than before
this branch: 935.91 KB at the merge base, 895.99 KB here, with the tab
and xterm in a 347 KB chunk fetched when a console is opened.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 23:09:44 +03:00
IvanHunters 4a10497d3d fix(dashboard): a VNC paste typed chords, and could run a command nobody pasted
Three defects on the same surface, all of them where this code meets
noVNC, the platform and the guest — and all of them invisible to every
test here, because the fake had no keyboard.

A paste began while the user was still holding the chord. noVNC tells
the guest a modifier is down the moment it is pressed and releases it
only on keyup, so the pasted text arrived as chords: under Ctrl an m is
Return, and on macOS, where noVNC maps Cmd to Alt, the same under Alt.
The host's modifiers are now released before the first character.

A character the keymap cannot produce was dropped and the rest was typed
anyway, newline included, with the notice arriving after the line had
run: rm -rf /srv/данные became rm -rf /srv. Nothing is sent now unless
the whole paste can be typed.

The shortcut was taken on every platform, so the guest lost a key it has
its own use for — visual block in vim, its own clipboard on Windows —
and on macOS gained nothing, because no browser pastes on Ctrl+V there.
Each platform's own chord only.

The fake now models the guest's keyboard: which modifiers it believes
are down, and what it received with chords marked. That is what makes
the first defect expressible as a test rather than something only a
person at a keyboard could notice.

Also pins three behaviours the suite was not holding: a frame arriving
after cleanup, a real close reason behind a synthetic 1006, and the
25 ms pacing the description calls measured.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters d113d02e03 feat(dashboard): lead a VM's tabs with its consoles, serial first
Reaching a console is why people open a virtual machine, so the two
consoles now sit directly after Overview instead of below the resource
tabs. Serial leads and is labelled Console: text goes in and out of it
directly, at a speed the emulated-keyboard path cannot reach.

VNC keeps its place beside it, because the serial port does not reach a
desktop session, a bootloader, or a Windows guest — and Windows guests
are a supported case here, with their own scheduling in the VM charts.

The order is pinned by a test: it was ordinary prose in a push() call
before, so the next edit to this list could reorder it in silence.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 25cd86c560 fix(dashboard): Ctrl+V pasted nothing in the serial console
xterm turns Ctrl with a letter into a control byte and cancels the
keydown, so on Windows and Linux Ctrl+V never reached the browser's
paste and the guest received SYN (0x16) instead. Cmd+V and Shift+Insert
were unaffected, which is why testing on a Mac missed it: reproduced on
a real terminal, where the shortcut put a single 0x16 byte on the wire
and nothing else.

The key handler now returns the event to the browser, at the cost of the
terminal's quoted-insert on that chord — the same trade the VNC console
already makes for the same shortcut. The test stub keeps the handler now
instead of dropping it, so the chord is reachable from a test at all.

Three smaller repairs in the same paths:

A frame arriving after cleanup was written into a disposed terminal,
because the message handler never consulted the stream's own state.

onerror synthesised a 1006 and the real onclose behind it was swallowed
by the already-closed latch, so a close carrying 1008 Forbidden reached
the user as connection error. The error is recorded and the close
reports what the server actually said.

navigator.clipboard is SecureContext-only and absent over plain http,
which the console's own URL builder supports; copying threw there
instead of falling back to the selection the user can copy by hand.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 58d0c90e0b test(dashboard): pin the console behaviours nothing was holding
Three behaviours the code promises had no test: the refusal of a second
paste while one is still typing, the focus-restore timer, and the serial
console's copy chord. The chord was untestable by construction — the
Terminal stub accepted the handler and dropped it, so nothing could ever
call it. The stub keeps it now.

Each test was checked by reverting the behaviour it covers and watching
that one test, and only that one, go red.

The VNC paste also acts on how typeKeystrokes ended instead of
discarding it. A paste cut short by a dropped session used to leave the
toolbar reading as though the text had all arrived.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 71bdad69ae fix(dashboard): console input state across a session's lifetime
Five repairs, all on state that outlives a single interaction.

The serial stream marked itself writable before the socket opened, so a
keystroke typed while the pill still said Connecting reached
WebSocket.send() during CONNECTING, which throws. Input is now held and
flushed on open, and discarded if the socket closes first.

A paste in the VNC console outlived the tab. The effect cleanup dropped
the RFB reference but not the sender, and noVNC's disconnect event
arrives too late to clear it, so the typing loop kept running against a
dead session. Cleanup now aborts the paste and clears the sender.

Clipboard blocked had a renderer and no producer: the state survived the
move from the panel to the shortcut, while the only thing that used to
set it did not. The sink timeout sets it now, which is the case the
message was written for — an empty or refused clipboard raises no paste
event at all.

The shortcut matched the physical KeyV position only, so on Dvorak
Ctrl+V reached noVNC instead and was cancelled there.

A clean server-side close left the status pill on amber Connecting,
because the tab tracked a boolean where it needed three states.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 3d026ff611 refactor(dashboard): keep only the US keymap for VNC paste
The layout was never selectable — the tab picks one and nothing offers
the others — so the German, French and Russian tables, and the AltGr
handling that only they needed, were data and code with no reader.

What remains states its assumption plainly: US, the layout a default
cloud image boots with. A guest in another layout is the case the serial
console answers, where text travels as bytes and no layout is involved.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 2f6ec92a20 feat(dashboard): paste into the VNC console with Ctrl+V
The graphical console still matters for guests the serial port cannot
reach — a desktop session, a bootloader, Windows. There a paste has to
be typed, so this maps the clipboard text to key presses for the layout
the guest has active and paces them: without the pacing the guest drops
and reorders characters, which was measured rather than assumed.

The shortcut is taken before noVNC sees it. noVNC calls preventDefault()
on keydown, which would cancel the browser's own paste and hand the
guest a Ctrl+V it cannot use; instead the focus moves to a hidden field
and the browser pastes into it. Reading the clipboard through
navigator.clipboard would have put a permission prompt in front of every
paste. The focus returns to the console even when no paste follows.

Nothing is added to the interface: the toolbar's existing status line
reports progress while the text is typed.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters 27d7b0ee03 feat(dashboard): serial console tab for virtual machines
The VNC console carries pixels and key events, so moving text through it
means emulating a keypress per character: measured at 57 seconds for a
1000-character paste, and the text corrupts if the pacing is dropped.

KubeVirt also exposes the guest's serial port as a websocket, and that
one carries text. The same 1000 characters land in under a second, the
guest's output is real text the user can select and copy, and tabs,
newlines and non-Latin characters travel as bytes instead of depending
on the keyboard layout the guest happens to have active.

virt-api negotiates the plain.kubevirt.io subprotocol and reads binary
frames only — a text frame is accepted by the socket and then dropped,
which is indistinguishable from a dead console, so the stream is kept
deliberately narrow and tested on its own.

Copy stays on the terminal's own chord (Ctrl+Shift+C, or Cmd+C) so a
plain Ctrl+C still interrupts the foreground process.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 22:45:15 +03:00
IvanHunters aa20495df3 feat(marketplace): register a tapped repository's apps on connect
Connecting a marketplace repository materialized its PackageSource but created no Package, so its ApplicationDefinitions never rendered and its apps never appeared in the dashboard catalog until a manual `cozypkg add` the dashboard cannot drive (the package list is computed from the ApplicationDefinitions, which do not exist yet).

The tap materializer now creates a tap-managed registration Package for each materialized PackageSource, the way the platform ships a Package per built-in app, so the ApplicationDefinition registrations deploy on connect and the apps become browsable; the app components carry no install block and are still instantiated per user resource.

Privileged install components of an unconfirmed tap auto-registration (a Package that still carries the marketplace-tap label) are refused on several best-effort layers: the Package reconciler skips their HelmRelease and prunes a lingering one at the install site, and the PackageSource reconciler withholds their ExternalArtifact so the helm-controller has no privileged content to deploy, re-running on confirmation via a Package watch. `cozypkg add --allow-privileged` sheds the label as an explicit ownership handover, which is the confirmation; a platform Package never carries the label. A benign component flipped to privileged in a new revision can still be materialized by source-watcher before these layers observe the flip; closing that race fully requires decoupling the catalog registration from install and is tracked in issue #4359.

`cozypkg untap` and the dashboard disconnect remove the registration Package (de-registering the apps) under a UID + ResourceVersion precondition, so a concurrent `cozypkg add` handover is never clobbered; running instances are left but unmanaged. `cozypkg add` re-opens a tap auto-registration for variant selection and hands it over. The cozystack-api ClusterRole gains delete on packages for the disconnect path.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 21:57:04 +03:00
Aleksei Sviridkin 92d2eede52 test(opensearch): separate the mount-plan rewrite from the roll onto it (#4279)
## What this is

`Refs #4259`. A diagnosis of the opensearch suite timeout plus the one
in-repo change it warrants: making the failing step say which of its two
candidates actually happened. It does **not** claim to fix the root
cause — see "What this does not do".

## What the run actually showed

The `verify-statefulset-rolled-onto-the-new-mount-plan` assert erred
with exactly two field failures, both under `status`: `(currentRevision
== updateRevision): false` and `updatedReplicas: field not found`. No
volume field appears in the error list, and `readyReplicas: 1` shows as
an unchanged line, so the pod was Ready at the deadline and nothing had
replaced it. Per e2e-testing.md ("Reading a failure diff: the actual
side is a projection"), the real cause is the error line, not the diff —
and a Chainsaw diff projects the live object onto the expected fields,
so the three `http-ca` / `http-cert` / `http-key` lines showing in the
diff are the expected tree, not proof the volumes are absent. Read that
way, the volume assertions matched: the three volumes were present on
the live template. The "volumes missing" reading is the projection trap
the doc warns against.

## Which candidate

Candidate (b): the template was rewritten onto the subPath mount plan,
and the operator has not restarted the pod onto it. This is consistent
with the source, traced against opensearch-k8s-operator v2.8.0 as
vendored:

- The chart renders the CR correctly — `generate` dropped, `secret` and
`caSecret` named — proven by
`packages/apps/opensearch/tests/tls_upgrade_test.yaml`.
- Given that CR, `pkg/reconcilers/tls.go` `handleHttp` appends exactly
the three volumes the step asserts (`http-ca` from
`opensearch-test.http-ca`, `http-key` and `http-cert` from
`opensearch-test-http-server`), and `pkg/reconcilers/cluster.go`
`reconcileNodeStatefulSet` writes that template onto the StatefulSet.
Three branches return ahead of that write — no node-pool config hash,
the `opensearch.role` recreate, and parallel recovery — but the
parallel-recovery gate is `ReadyReplicas < replicas-1`, unreachable at
one replica, so the write happens. The reconcilers that run ahead of the
cluster reconciler do not stop it either: the TLS reconciler runs first
and returns the admin-certificate path's result, empty in the ordinary
case, and `securityconfig.Reconcile` short-circuits to nil when the
security-config checksum is unchanged, which the move does not change.
So the operator does write the volumes.
- The nodePool StatefulSet is `OnDelete` (`pkg/builders/cluster.go` sets
`UpdateStrategy.Type: OnDelete` alongside `PodManagementPolicy:
OrderedReady`), so the StatefulSet controller never deletes the pod to
apply a template change: `podManagementPolicy` orders creation and
deletion during scaling, `updateStrategy` decides the update. The roll
is the operator's rolling-restart reconciler's to drive
(`pkg/reconcilers/rollingRestart.go`) — it deletes the pod itself. It
needs `status.Initialized`, it needs `ReadyReplicas == replicas` (a
Ready pod is a precondition, not the blocker), then it opens a client to
the OpenSearch API and calls `CheckClusterStatusForRestart`, which holds
the restart while the cluster is red; on yellow the gate now enables
shard allocation, waits for every data node to join, waits for shard
activity to settle, then proceeds (#4317 deleted the old
`.opensearch-observability` carve-out, and this suite builds the
operator with that patch). Any of those gates can sit indefinitely.
`status.currentRevision` never advances by itself under `OnDelete`; the
operator patches it once `updatedReplicas == replicas`, so the second
assert's own condition cannot go true unless that reconciler ran to the
end.
- The pod's startup probe is a TCP check on 9200
(`builders/cluster.go`), so "connection refused" is OpenSearch not
listening, not a probe-scheme mismatch. The plaintext `GET / HTTP/1.1`
from `curl/8.5.0` on the TLS listener is neither the startup/liveness
probe (TCP) nor the readiness probe (`curl -k https://localhost:9200`,
localhost, HTTPS) — it is external traffic to the LoadBalancer address,
a red herring for the stall.

## What this changes

The step now runs two asserts instead of one. The first waits for the
operator to rewrite the template onto the three volumes, on a
reconcile-scale budget (6m) — a failure here is the operator not writing
them (candidate a). The second waits for the roll to complete onto that
template, on the pod-lifetime budget (12m) — a failure here with the
first green is the roll not completing (candidate b): the operator never
restarting the pod, which the rolling-restart reconciler holds while
`CheckClusterStatusForRestart` reports the cluster red — on yellow the
gate enables shard allocation, waits for every data node to join, waits
for shard activity to settle, then proceeds — or a replacement that was
deleted but never came Ready. The second assert carries the three volume
projections and `observedGeneration == metadata.generation` as well, so
the roll is pinned to the template the first assert checked rather than
to whatever revision is current when the status converges. The suite
`catch` also captures the StatefulSet as YAML and as a describe, and the
operator's own log, because `updateRevision`, `currentRevision`,
`generation` and `updatedReplicas` are what separate the two halves —
describe alone omits them — and the restart decision is logged in the
operator, not in the cluster pods. The reconciler logs `Starting rolling
restart of the StatefulSet` (`rollingRestart.go:155`) once its early
gates (`Initialized`, ready-replica, update-pending) pass; it builds its
OpenSearch client just before, at `:138`, and that client pings the
cluster — so a run whose log lacks `Starting rolling restart` either had
an earlier gate hold it silently or had the client ping fail loudly, not
only the former, while that line present followed by a `Couldn't proceed
with rolling restart ... because <reason>` line names a health-stage
hold (the health gate is `CheckClusterStatusForRestart`, and it is not
the last: `PreparePodForDelete` follows it). The operator-log `tail` was
raised so it spans the whole assert window rather than a third of it.

## What this does not do

It does not fix the stall; #4317 does, and is already merged. The run
that captured this (`Run E2E tests`, job 104576486900) shows the
rolling-restart reconciler holding on health: the manager logged
`Starting rolling restart of the StatefulSet opensearch-test-nodes`
(`rollingRestart.go:155`, printed only after the `Initialized` and
ready-replica gates passed) and then, every ten seconds to the deadline,
`Couldn't proceed with rolling restart ... waiting for health to be
green` (`os_data_service.go:180`), which is reached only after
`GetFlatClusterSettings` returned 2xx (`os_client.go:224` makes anything
else an error). So the operator reached the cluster and the cluster
answered; health held the restart. #4259 established why, and the CA
move plays no part: on a single data node the bootstrap node leaving is
audited into a fresh `security-auditlog-*` index with one replica, that
replica has nowhere to go, the cluster stays yellow for good, and the
v2.8.0 restart gate opens only on green (or on a yellow
`.opensearch-observability`) so it never opens. #4317 backports
opensearch-project/opensearch-k8s-operator#1569 to fix that gate; this
PR is only the diagnostic split that names which half of the roll a
failure is. The split content itself is not the failure: on `49f3f059f`
both asserts passed, the second after 1m47s, and this change touches
only the step's comments and the operator-log tail, not the assertions.
With this change in place, a future occurrence names the half, and the
catch carries the roll's own fields and the operator log, so the
crust-gather can be read against a specific claim rather than an
ambiguous one.

### Release note

```release-note
NONE
```

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

* **Tests**
* Improved OpenSearch StatefulSet failure diagnostics by capturing YAML,
detailed resource descriptions, and the latest operator pod logs.
* Expanded rolling-restart verification to check volume projections,
template updates, rollout readiness, observed and metadata generations,
and revision consistency.
* Separated template validation from rollout completion checks with
dedicated six- and twelve-minute time limits.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-21 20:44:23 +04:00
IvanHunters c4f72325a6 fix(test): pass over the flux defaults check instead of aborting the suite
hack/cozytest.sh is not bats and defines no `skip`, so the guard for a
missing flux killed the whole file with `skip: not found` and kept the unit
job red. A red checks job also cancels finalize and e2e, so the recipe this
suite exists to hold never ran in CI at all.

The form the rest of the suite already uses returns 0 instead, as
hack/release-changelog-behaviour.bats does for a missing node. Verified by
mutation: with flux installed, dropping a pattern from FLUX_DEFAULT_IGNORES
still turns the test red, so the early return does not make it vacuous.

Assisted-by: LLM
Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-21 19:20:48 +03:00
Timur Tukaev e32353e839 docs(agents): correct the labeler's trigger list (#4090)
## What this PR does

The PR Title Auto-Labeling section still lists `edited` among the events
`.github/workflows/pr-labeler.yaml` runs on. That trigger was dropped in
#3211 — the workflow carries the note at the top of its `on:` block, and
the v1.6.0 changelog records the change — so the document and the
workflow have disagreed since.

I hit it the way the document's intended reader would. Three PRs opened
with GitHub's branch-derived titles, corrected afterwards to
Conventional Commits, and the labels did not follow:
`area/uncategorized` on all three and no `kind/feature`, because nothing
re-ran. The second paragraph this PR adds is that consequence, which is
the part a contributor actually needs: a corrected title does not
re-label until the next push or a reopen, and since the labeler only
ever adds, the `area/uncategorized` left by the first title stays until
a human removes it.

### Screenshots

Not applicable — no UI change.

### Downstream repositories

I walked the trigger map in `docs/agents/contributing.md` against this
diff. The only file it touches is that document, and the two triggers
pointing at it are narrower than this change: `cozystack/community`
restates the **commit convention** from it (types, scopes, sign-off, the
`Assisted-by: LLM` trailer) and the **PR template and downstream
checklist**, and `cozystack/ccp` gates its `package-bump` skill on the
same commit convention. Neither restates the labeler's event list, which
is what changes here. Nothing else in the map reaches a docs-only
change.

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

### Release note

```release-note
NONE
```


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

## Summary by CodeRabbit

- **Documentation**
  - Clarified when pull request title auto-labeling runs.
  - Documented that title edits do not trigger relabeling.
- Explained that existing labels remain until a push or reopen, while
additional uncategorized labels require manual removal.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-21 17:25:03 +03:00
scooby87 6cd78b0e30 feat(platform): make the Keycloak realm name configurable (#4237)
## What this PR does

Fixes #4216. The Keycloak realm name `cozy` was hardcoded across every
SSO component, so operators could not rename the realm without patching
vendored templates that `make update` reverts. The kube-apiserver OIDC
issuer is already configurable out-of-band via talm `oidcIssuerUrl`,
which made the mismatch worse: pointing the apiserver at a custom realm
left the dashboard, linstor-gui and the generated kubeconfig on `cozy`,
so SSO broke with an issuer mismatch.

This adds a single `authentication.oidc.realmName` (default `cozy`) to
the platform Package values and threads it through the `_cluster`
channel so every consumer resolves the same realm: keycloak-configure
(realm, clients and `cozystack-cluster-admin` roles), the dashboard and
linstor-gui gatekeepers (issuer/login/logout URLs), the info kubeconfig,
and — beyond the components listed in the issue — the Grafana and
managed-Kubernetes apiserver OIDC issuers, which carried the same
hardcoded `/realms/cozy` in their `_helpers.tpl` and would otherwise
have left SSO half-broken.

`keycloakInternalUrl` is now derived from `realmName` when left unset,
so the realm is named in one place. Its default changed from the literal
in-cluster URL to `null` with a documented tri-state: `null` derives
`http://keycloak-http.cozy-keycloak.svc:8080/realms/<realmName>`; `""`
keeps the existing escape hatch that restores external OIDC discovery;
any explicit value is used verbatim. A stock cluster renders the
byte-identical `keycloak-internal-url` it did before, so existing
clusters are unaffected on upgrade.

The Kubernetes CR object names (`keycloakrealm-cozy`, `keycloak-cozy`)
and the `realmRef` that clients point at are internal resource names,
not the realm's technical name, and stay fixed — the EDP operator
resolves clients into the renamed realm through the unchanged
`realmRef`.

Covered by helm-unittest across all seven affected packages, written
test-first (red → green, mutation-verified): default stays `cozy`, a
custom realm reaches every URL, the derived internal URL follows
`realmName`, the `""` escape hatch survives a custom realm, and a
numeric/reserved realm name stays a string. `packages/extra/info` had no
unit-test target, so one was added.

### Downstream repositories

`cozystack/website` needs a follow-up:
`content/en/docs/next/operations/configuration/platform-package.md` is a
hand-written table of the `spec.components.platform.values.*` keys and
does not yet list `authentication.oidc.realmName`. Leaving the box
unticked for a maintainer to action rather than filing a speculative PR.

- [ ] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up: document `authentication.oidc.realmName` in
`platform-package.md`
- [ ]
[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): the Keycloak realm name is now configurable via `authentication.oidc.realmName` (default `cozy`), threaded consistently through the apiserver OIDC issuer, dashboard, linstor-gui, Grafana, the managed-Kubernetes apiserver and the generated kubeconfig. Set it to the same realm as the talm `oidcIssuerUrl`. The `authentication.oidc.keycloakInternalUrl` default changed from the literal in-cluster URL to `null`, which now derives `http://keycloak-http.cozy-keycloak.svc:8080/realms/<realmName>`; clusters that leave it unset render the identical URL as before, and `""` still selects external OIDC discovery.
```



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

* **New Features**
* Added configurable Keycloak realm support across OIDC integrations,
including Kubernetes, dashboards, monitoring, kubeconfig, and
authentication services.
* The realm defaults to `cozy` and can be customized through platform
authentication settings.
* Internal Keycloak URLs are derived from the configured realm when not
explicitly provided.
* Added realm-name validation and support for explicitly disabling
derived internal URLs.

* **Documentation**
* Updated OIDC guidance to describe configurable realm behavior and
defaults.

* **Tests**
* Added coverage for custom realms, defaults, validation, and generated
OIDC URLs.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-21 17:05:34 +03:00
scooby87 6677c24beb fix(ci): fail the trailer check on an empty commit range (#4278)
## What

`hack/check-commit-trailers.sh` printed `Commit trailers OK: 0 commit(s)
checked.` and exited 0 when the range it was given resolved to zero
commits, so a run that examined nothing was indistinguishable from a
clean run. An empty range now prints a message naming the empty case and
exits 1.

## Why

The documented pre-push recipe in `docs/agents/contributing.md` is
`hack/check-commit-trailers.sh origin/main..HEAD`. The range is resolved
in the process working directory, so an agent whose shell sits in a
different checkout than the branch resolves it against the wrong `HEAD`
and gets nothing — and the old green there was a green nobody could tell
from a real one, defeating the check precisely when the checkout is
misconfigured. The CI path is unaffected:
`.github/workflows/pre-commit.yml` builds the range from a pull
request's merge base and head SHA, which GitHub refuses to open with no
commits between the two, and which goes empty only once the base has
absorbed the head's commits and there is nothing left to merge, where a
red trailer check is harmless.

## Test

TDD, bats: the previously buggy `accepts an empty range` test is
inverted into `fails on an empty range instead of reporting OK`, which
asserts a non-zero exit, that the message names the empty case, and that
the `Commit trailers OK` line is absent. Mutation-verified — removing
the guard turns it RED, restoring it turns it GREEN. Full suite: 28
passing, 0 failing.

## Release note

```release-note
Local runs of `hack/check-commit-trailers.sh` now fail on an empty commit range instead of reporting OK, so the documented pre-push check no longer passes silently when it examined nothing.
```

Fixes #4263


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

## Summary by CodeRabbit

- **Bug Fixes**
- Commit trailer checks now fail when the specified commit range
contains no commits.
  - Empty ranges no longer report a misleading successful validation.
  - Error output clearly indicates that no commits were checked.

- **Tests**
- Added coverage confirming empty commit ranges return a failure status
and appropriate diagnostic output.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-21 16:12:39 +03:00
myasnikovdaniil a1b32f2e5a ci(workflows): build Talos only when its sources changed (#4021)
Stacked on #4020, not independently mergeable.

Nothing on the same-repo PR path consumes either half of what
`build-talos` produces. `image-talos` pushes
`${REGISTRY}/talos:pr-N-sha`, which no chart in the tree references and
which is not even version-tagged here (`PUBLISH_VERSIONED` and
`PUBLISH_FLOATING` are both 0). `image-matchbox` stamps
`packages/extra/bootbox/images/matchbox.tag`, and that one line is the
whole content of `pr-patch-fragment-talos` - checked against the
artifact from a real run - but bootbox is opt-in and the E2E platform
Package does not enable it, so no run pulls the image. Unstamped tag
leaves installer artifact pointing at released matchbox, which is a
valid ref nothing on this path resolves.

So the job ran a privileged siderolabs imager build on every PR for two
artifacts with no reader. Now it runs when the PR touched
`packages/core/talos`, and `finalize` accepts a skipped result as well
as a successful one. Without that second half skipping it would block
finalize, and therefore e2e, on nearly every PR.

Forks keep the unconditional build, and the reason is not about talos.
`e2e-fork.yaml` publish job requires at least one OCI archive to exist,
an invariant that holds today only because this job always ran, so a
fork PR touching nothing under `packages/` would arrive with an empty
export and fail a legitimate run. Teaching that guard what `plan`
expected to build is work in the fork allowlist path and belongs in its
own change.

Saving is about 1.5-2 min of critical path. Main point is removing a
privileged image build that nobody reads from every pull request.


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

## Summary by CodeRabbit

- **CI Improvements**
- Pull request validation now runs Talos builds only when relevant
changes require them, while retaining full validation for fork-based
contributions.
- Finalization correctly handles skipped Talos builds and preserves
generated boot artifacts when builds succeed.
- Changed-file detection now accounts for renames, deletions, and shared
build inputs.

- **Documentation**
- Updated testing and build guidance to reflect the current validation
behavior.

- **Tests**
- Added comprehensive coverage for build classification, workflow
outputs, skipped jobs, and artifact handling.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-09-21 14:52:53 +05:00
Myasnikov Daniil 1118b340a7 fix(ci): teach the overlay to repair an unstamped images/*.tag ref
hack/overlay-main-images.sh walks images/*.tag, but every branch of its
line classifier needs either a YAML key or an @sha256:. A .tag file holds
one bare reference and nothing else, so until a build stamps it the line
has neither, the drift guard reads it as a non-ref change, and the
committed reference survives.

For a package onboarded with the :v0.0.0 placeholder this repo already
uses for a new image, that surviving reference is one no registry
serves. The overlay is the only thing that would replace it for a PR
that does not rebuild the package, so once such a package is on main
every full-suite run that skips its build keeps the placeholder. The
same placeholder inside a values.yaml repairs itself, because there it
sits under an `image:` key the classifier recognises: the difference is
the file shape, not the placeholder.

The gap is latent rather than new. 17 of the 19 .tag files in the tree
carry @sha256: and pass on that branch alone; the only other digest-less
one, extra/seaweedfs/images/seaweedfs-cosi-driver.tag, is third-party,
so build-main never rebuilds it, the artifact copy is byte-identical and
the classifier is never reached. The first digest-less first-party .tag
is what turns it live.

hack/promote-rewrite-tags.sh already carries a second match branch for
this shape and states why. This is that branch, scoped to *.tag so an
unkeyed line in a values.yaml still counts as drift.

Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
2026-09-21 14:42:41 +05:00
Alexey Artamonov 7fd8376ccb fix(ci): fail the trailer check on an empty commit range
The pre-push recipe resolves origin/main..HEAD in the process working
directory, so an agent whose shell sits in a checkout at or behind the
base resolves it to zero commits and the check printed "Commit trailers
OK" with exit 0. A run that examined nothing was indistinguishable from
a clean one, defeating the recipe exactly when the checkout is wrong.
Treat an empty range as a named failure so the misconfiguration is loud;
the CI path is unaffected because it builds the range from a pull
request's merge base and head, which is empty only once nothing is left
to merge.

Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:20:22 +03:00
Alexey Artamonov 142a14cb69 fix(platform): reject an empty realm name instead of coercing it to cozy
realmName resolved through `| default "cozy"`, which fires on both null
and "". Unset (null) legitimately means the default, but an explicit ""
is a meaningless value and coercing it hid the mistake. Split the two:
null falls back to cozy, an empty string reaches the charset guard and is
rejected — the same null-vs-"" distinction keycloakInternalUrl already
draws a few lines below.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00
Alexey Artamonov ff637ed9a2 fix(platform): validate the realm-name charset and regenerate kubernetes artifacts
The realm-name guard checked only the type and echoed the parsed value
back, so its hint told an operator who wrote `on` to set realmName:
"true" — the token YAML had already discarded. Drop the echo and add a
slug-charset check: the name is spliced verbatim into URL path segments
and a shell token, so a "/" or a space must be rejected at the source
rather than split a URL or the hook script downstream.

The description edit in the previous commit was hand-applied to the
generated kubernetes README and never reached the Go types, leaving
pre-commit red; regenerate both with cozyvalues-gen. Finish the
oidc-tenant System-mode prose that still read cozy as a fixed name.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00
Alexey Artamonov 949096694b fix(platform): reject non-string realm names and shell-quote the hook realm
A realmName that YAML resolves to an int or a bool (a bare 123, or a
reserved word like on/off) was coerced with toString, silently renaming
the realm to something the operator never typed (on -> "true"). Fail the
render with a quoting hint at the source instead of surfacing it later as
a broken issuer URL.

The update-email hook Job interpolated the realm into its shell script
unquoted, so a name carrying a space or a shell metacharacter could break
or inject into the script; single-quote it. The Grafana and managed-cluster
issuer helpers build the URL with printf %s straight off the channel value,
so guard them with toString for the same non-string reason.

Name the configured realm in the tenant kube-apiserver oidc.mode
description and the Grafana identity-mode comment, which still read cozy as
if it were fixed.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00
Alexey Artamonov a3df02df23 fix(kubernetes): name the configured realm in the OIDC denial message
The claimValidationRules message in the System-mode AuthenticationConfiguration
hardcoded "in the cozy realm", so on a renamed realm it told a rejected user to
look in a realm that no longer exists. Build it from the same realm the issuer
uses (toString-guarded, as the derived issuer URL already is).

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00
Alexey Artamonov 80d32b3ab7 fix(keycloak): complete realm-name coverage and guard non-string names
The enable-update-email hook Job in keycloak-configure still pinned
REALM=cozy, so on a custom realmName it waited on a realm the chart never
provisions and the cold install timed out — the one seventh consumer left
behind, and the only value nobody could set without breaking the install.

A bare-integer or YAML-reserved realm name reached the printf %s that
builds the derived keycloakInternalUrl as a Go int, rendering a
"%!s(...)" format error into the URL; coerce the name to a string once
at the source.

Document that renaming the realm on a running cluster provisions a fresh
empty realm and orphans the accounts in the old one, and note in the OIDC
tenant and grafana guides that the realm name is now the configurable
default. info/Makefile carried NAME=etcd, so cozyhr drove the wrong
release from that package; correct it while touching the file.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00
Alexey Artamonov 44a9a8e735 feat(platform): make the Keycloak realm name configurable
The realm name "cozy" was hardcoded in keycloak-configure (which owns
the realm, its clients and the cozystack-cluster-admin roles), in the
dashboard and linstor-gui gatekeepers, in the info kubeconfig, and in the
Grafana and managed-Kubernetes apiserver OIDC issuers. Operators could
not rename the realm without patching vendored templates, which
`make update` reverts. The apiserver OIDC issuer is already configurable
via talm oidcIssuerUrl, so pointing it at a custom realm left every SSO
component on "cozy" and broke login with an issuer mismatch.

authentication.oidc.realmName (default "cozy") now rides the _cluster
channel so every consumer resolves the same realm, and the default
keycloakInternalUrl is derived from it so the realm is named in one place.

Assisted-by: LLM
Signed-off-by: Alexey Artamonov <aleksei.artamonov@aenix.io>
2026-09-21 12:15:10 +03:00