fix(web-arm): onecli-db-password oneshot — LoadCredential + setup ordering #341

Merged
dominik.polakovics merged 1 commit from lab/20260814-1419 into main 2026-08-14 19:40:46 +02:00

First activation of #339 on web-arm failed: the oneshot runs as User=postgres but the sops secret is root-owned 0400 — cat: /run/secrets/onecli-db-password: Permission denied — so podman-onecli went down with result 'dependency'.

Two changes to the oneshot:

  • LoadCredential hands the root-owned secret to the service uid (the keycloak module's pattern); the script reads $CREDENTIALS_DIRECTORY/db-password. Changing the unit also means switch-to-configuration restarts it on deploy, so the failed unit heals on its own.
  • after = postgresql-setup.service added alongside postgresql.target: the target ordering protects a cold boot, but on a live switch the target is already active and the oneshot can race the role creation (PR #339 review CONCERN 1's residual case).

Deploy note: podman-onecli.service itself is unchanged, so after the switch it stays dead until started once — systemctl start podman-onecli (or the next reboot).

Closes #340

First activation of #339 on web-arm failed: the oneshot runs as `User=postgres` but the sops secret is root-owned 0400 — `cat: /run/secrets/onecli-db-password: Permission denied` — so `podman-onecli` went down with `result 'dependency'`. Two changes to the oneshot: - **LoadCredential** hands the root-owned secret to the service uid (the keycloak module's pattern); the script reads `$CREDENTIALS_DIRECTORY/db-password`. Changing the unit also means switch-to-configuration restarts it on deploy, so the failed unit heals on its own. - **`after = postgresql-setup.service`** added alongside `postgresql.target`: the target ordering protects a cold boot, but on a live switch the target is already active and the oneshot can race the role creation (PR #339 review CONCERN 1's residual case). Deploy note: `podman-onecli.service` itself is unchanged, so after the switch it stays dead until started once — `systemctl start podman-onecli` (or the next reboot). Closes #340
The unit runs as postgres but the sops secret is root-owned 0400, so the
first activation died on Permission denied and took podman-onecli down as
a dependency. Also order the oneshot after postgresql-setup.service
explicitly: postgresql.target covers a cold boot, but on a live switch it
is already active and the role-creation race is real.

Closes #340
dominik.polakovics deleted branch lab/20260814-1419 2026-08-14 19:40:46 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Cloonar/nixos!341
No description provided.