The files deploy's FIRST activation reds at switch-to-configuration status 4: logrotate-checkconf and nextcloud-cron both fail during the activation that introduces nginx/Nextcloud #1020

Closed
opened 2026-08-30 07:14:40 +00:00 by matou-build-agent · 2 comments

Failure

Drive 20260830T065451Z red at deploy-files (sig 03a7ed69caec), 15/16 legs green. The co-host deploy of the files service converged — Nextcloud installed, nginx up, user_oidc configured — but switch-to-configuration exited status 4, so clan reported the node failed and the deploy surfaced a fault frame.

GOTCHAS #126 already records the governing rule: switch-to-configuration exits status 4 when a unit it started failed. Two stock units fail on the FIRST activation that introduces nginx/Nextcloud, and both are pure races that pass seconds later.

Evidence

All cites are test-results/drive-idip/20260830T065451Z/logs/droplet-journal.txt.

1. logrotate-checkconf.service races nginx's own log directory.

  • :1550 07:06:14 Starting Nginx Web Server...
  • :1579 07:06:14 logrotate[9802]: error: stat of /var/log/nginx/*.log failed: Permission denied (logrotate had just dropped to euid 60; the glob never expanded)
  • :1582/:1584 logrotate-checkconf.service: Main process exited, code=exited, status=1/FAILURE → Failed with result 'exit-code'
  • :1614 07:06:14 Started Nginx Web Server. — nginx finished starting AFTER the check had already read its log dir
  • :1910 on the immediate re-switch 25 s later the identical check finds /var/log/nginx/access.log and error.log and Finished Logrotate configuration check

2. nextcloud-cron.service fires before nextcloud-setup.service has ever run.

  • :1527 07:06:13 Started nextcloud-cron.timer.
  • :1598 07:06:14 Started nextcloud-cron.service.
  • :1635 nextcloud-cron.service: Failed with result 'exit-code' — php[9841]: Exception: Not installed in .../lib/base.php:226
  • :1653 07:06:16 Starting nextcloud-setup.service..., :1730 07:06:28 Finished nextcloud-setup.service. — the install completes fourteen seconds after cron already failed on its absence

3. The switch dies on the sum of them.

  • :1830 07:06:37 nixos[9599]: switching to system configuration /nix/store/q3ndwb10...-nixos-system-gateway... failed (status 4)
  • :1831/:1832 clan-switch-gateway-15be7037.service: Main process exited, code=exited, status=4/NOPERMISSION → Failed with result 'exit-code'
  • :1954 07:06:42 idss-control-plane WARN msg="provision deploy failed" device=gateway error="provision: deploy gateway: clan: deploy failed on 1 node(s): gateway"

logs/droplet-units.txt confirms the box itself is fine: systemctl --failed names nothing, nginx is active (running) since 07:06:14 and phpfpm-nextcloud since 07:06:29.

Suspected layer

The rendered NixOS config for the files service — internal/clan/files.go. That file is already the established home for exactly this kind of activation-ordering patch: internal/clan/files.go:482 emits systemd.services.nextcloud-setup.after = [ "postgresql.service" ]; for the same class of first-activation race. Neither logrotate nor nextcloud-cron is mentioned anywhere in the repo today (grep -rn logrotate over all .go/.nix/.ts/.md returns nothing), so both units arrive purely as NixOS stock behaviour that our render never constrains.

What plugging it needs

On the files render, make the first activation unit-clean:

  1. logrotate — guarantee /var/log/nginx exists and is readable by the nginx uid before logrotate-checkconf runs (a systemd.tmpfiles.rules entry), or order logrotate-checkconf after nginx.service, or set services.logrotate.checkConfig = false when we provision nginx. Prefer whichever keeps the check's value on later generations rather than deleting it outright.
  2. nextcloud-cron — gate it on the install having happened: order/require it after nextcloud-setup.service, or give it a ConditionPathExists on the installed config so a pre-install boot tick is skipped rather than failed.

Both are render-string changes with teeth available as internal/clan/files_test.go render assertions (go test ./internal/clan/), matching the nextcloud-setup.after precedent.

Also worth checking while in here (an observation, not a required change): clan re-switched by itself immediately after the failure — clan-switch-gateway-841ae130.service ran 07:06:37→07:06:41 and completed cleanly (:1927 finished switching to system configuration, :1928 Deactivated successfully) — yet the control plane still recorded the deploy as failed one second later (:1954). Worth confirming whether clan's own successful re-switch is meant to clear the node's failure, or whether the aggregate is correctly reporting the first pass. This is secondary; fixing the two units removes the trigger either way.

Add a GOTCHAS entry with the fix (docs/GOTCHAS.md, sibling to #126, which already states the status 4 rule this hazard is a fresh instance of).

drive 20260830T065451Z red at deploy-files: deploy failed (clean-retry): provision: deploy gateway: clan: deploy failed on 1 node(s): gateway
evidence: /home/dev/swarm/Matou/idss/test-results/drive-idip/20260830T065451Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## Failure Drive `20260830T065451Z` red at `deploy-files` (sig 03a7ed69caec), 15/16 legs green. The co-host deploy of the files service converged — Nextcloud installed, nginx up, user_oidc configured — but `switch-to-configuration` exited **status 4**, so clan reported the node failed and the deploy surfaced a fault frame. GOTCHAS #126 already records the governing rule: `switch-to-configuration` exits `status 4` when a unit it started failed. Two stock units fail on the FIRST activation that introduces nginx/Nextcloud, and both are pure races that pass seconds later. ## Evidence All cites are `test-results/drive-idip/20260830T065451Z/logs/droplet-journal.txt`. **1. `logrotate-checkconf.service` races nginx's own log directory.** - `:1550` `07:06:14 Starting Nginx Web Server...` - `:1579` `07:06:14 logrotate[9802]: error: stat of /var/log/nginx/*.log failed: Permission denied` (logrotate had just dropped to euid 60; the glob never expanded) - `:1582`/`:1584` `logrotate-checkconf.service: Main process exited, code=exited, status=1/FAILURE` → `Failed with result 'exit-code'` - `:1614` `07:06:14 Started Nginx Web Server.` — nginx finished starting AFTER the check had already read its log dir - `:1910` on the immediate re-switch 25 s later the identical check finds `/var/log/nginx/access.log` and `error.log` and `Finished Logrotate configuration check` **2. `nextcloud-cron.service` fires before `nextcloud-setup.service` has ever run.** - `:1527` `07:06:13 Started nextcloud-cron.timer.` - `:1598` `07:06:14 Started nextcloud-cron.service.` - `:1635` `nextcloud-cron.service: Failed with result 'exit-code'` — `php[9841]: Exception: Not installed in .../lib/base.php:226` - `:1653` `07:06:16 Starting nextcloud-setup.service...`, `:1730` `07:06:28 Finished nextcloud-setup.service.` — the install completes **fourteen seconds after** cron already failed on its absence **3. The switch dies on the sum of them.** - `:1830` `07:06:37 nixos[9599]: switching to system configuration /nix/store/q3ndwb10...-nixos-system-gateway... failed (status 4)` - `:1831`/`:1832` `clan-switch-gateway-15be7037.service: Main process exited, code=exited, status=4/NOPERMISSION` → `Failed with result 'exit-code'` - `:1954` `07:06:42 idss-control-plane WARN msg="provision deploy failed" device=gateway error="provision: deploy gateway: clan: deploy failed on 1 node(s): gateway"` `logs/droplet-units.txt` confirms the box itself is fine: `systemctl --failed` names nothing, nginx is `active (running)` since 07:06:14 and phpfpm-nextcloud since 07:06:29. ## Suspected layer The rendered NixOS config for the files service — `internal/clan/files.go`. That file is already the established home for exactly this kind of activation-ordering patch: `internal/clan/files.go:482` emits `systemd.services.nextcloud-setup.after = [ "postgresql.service" ];` for the same class of first-activation race. Neither `logrotate` nor `nextcloud-cron` is mentioned anywhere in the repo today (`grep -rn logrotate` over all `.go`/`.nix`/`.ts`/`.md` returns nothing), so both units arrive purely as NixOS stock behaviour that our render never constrains. ## What plugging it needs On the files render, make the first activation unit-clean: 1. **logrotate** — guarantee `/var/log/nginx` exists and is readable by the nginx uid before `logrotate-checkconf` runs (a `systemd.tmpfiles.rules` entry), or order `logrotate-checkconf` after `nginx.service`, or set `services.logrotate.checkConfig = false` when we provision nginx. Prefer whichever keeps the check's value on later generations rather than deleting it outright. 2. **nextcloud-cron** — gate it on the install having happened: order/require it after `nextcloud-setup.service`, or give it a `ConditionPathExists` on the installed config so a pre-install boot tick is skipped rather than failed. Both are render-string changes with teeth available as `internal/clan/files_test.go` render assertions (`go test ./internal/clan/`), matching the `nextcloud-setup.after` precedent. **Also worth checking while in here (an observation, not a required change):** clan re-switched by itself immediately after the failure — `clan-switch-gateway-841ae130.service` ran `07:06:37`→`07:06:41` and completed cleanly (`:1927` `finished switching to system configuration`, `:1928` `Deactivated successfully`) — yet the control plane still recorded the deploy as failed one second later (`:1954`). Worth confirming whether clan's own successful re-switch is meant to clear the node's failure, or whether the aggregate is correctly reporting the first pass. This is secondary; fixing the two units removes the trigger either way. **Add a GOTCHAS entry with the fix** (`docs/GOTCHAS.md`, sibling to #126, which already states the `status 4` rule this hazard is a fresh instance of). drive `20260830T065451Z` red at `deploy-files`: `deploy failed (clean-retry): provision: deploy gateway: clan: deploy failed on 1 node(s): gateway` evidence: `/home/dev/swarm/Matou/idss/test-results/drive-idip/20260830T065451Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 03a7ed69caec -->
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=14369
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=14369 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #1020 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1020,
  "status": "success",
  "commits": [
    "ab977cc"
  ],
  "changed_files": [
    "internal/clan/files.go",
    "internal/clan/files_test.go",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "go test ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/clan/ -run TestRenderFiles_FirstActivation -v",
      "exit_code": 0
    },
    {
      "command": "go vet ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "gofmt -l internal/clan/files.go internal/clan/files_test.go",
      "exit_code": 0
    }
  ],
  "criteria": {
    "logrotate: guarantee /var/log/nginx readable by nginx uid before logrotate-checkconf runs (or order after nginx.service)": "renderFilesFirstActivation emits `systemd.services.logrotate-checkconf.after = [ \"nginx.service\" ];` so nginx creates+opens the log dir before the euid-60 check reads it, keeping the check's value on later generations (internal/clan/files.go); teeth TestRenderFiles_FirstActivationOrdersLogrotateAfterNginx",
    "nextcloud-cron: gate it on the install having happened (order/require after nextcloud-setup.service)": "renderFilesFirstActivation emits `systemd.services.nextcloud-cron` with `after` AND `requires = [ \"nextcloud-setup.service\" ]` — requires (not merely after) pulls setup into the timer's own transaction so cron waits for the install; teeth TestRenderFiles_FirstActivationGatesCronOnSetup",
    "Both are render-string changes with teeth in internal/clan/files_test.go (go test ./internal/clan/)": "Two red-first assertions added; go test ./internal/clan/ exits 0",
    "Add a GOTCHAS entry with the fix (sibling to #126)": "docs/GOTCHAS.md entry #132 added, sibling to #126's status-4 rule, recording symptom/cause/rule/source"
  },
  "summary": "Constrained the two stock units (logrotate-checkconf, nextcloud-cron) that raced nginx/Nextcloud on the files deploy's first activation, so switch-to-configuration no longer exits status 4.",
  "reason": "",
  "blockers": []
}
**close-report** for #1020 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1020, "status": "success", "commits": [ "ab977cc" ], "changed_files": [ "internal/clan/files.go", "internal/clan/files_test.go", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "go test ./internal/clan/", "exit_code": 0 }, { "command": "go test ./internal/clan/ -run TestRenderFiles_FirstActivation -v", "exit_code": 0 }, { "command": "go vet ./internal/clan/", "exit_code": 0 }, { "command": "gofmt -l internal/clan/files.go internal/clan/files_test.go", "exit_code": 0 } ], "criteria": { "logrotate: guarantee /var/log/nginx readable by nginx uid before logrotate-checkconf runs (or order after nginx.service)": "renderFilesFirstActivation emits `systemd.services.logrotate-checkconf.after = [ \"nginx.service\" ];` so nginx creates+opens the log dir before the euid-60 check reads it, keeping the check's value on later generations (internal/clan/files.go); teeth TestRenderFiles_FirstActivationOrdersLogrotateAfterNginx", "nextcloud-cron: gate it on the install having happened (order/require after nextcloud-setup.service)": "renderFilesFirstActivation emits `systemd.services.nextcloud-cron` with `after` AND `requires = [ \"nextcloud-setup.service\" ]` — requires (not merely after) pulls setup into the timer's own transaction so cron waits for the install; teeth TestRenderFiles_FirstActivationGatesCronOnSetup", "Both are render-string changes with teeth in internal/clan/files_test.go (go test ./internal/clan/)": "Two red-first assertions added; go test ./internal/clan/ exits 0", "Add a GOTCHAS entry with the fix (sibling to #126)": "docs/GOTCHAS.md entry #132 added, sibling to #126's status-4 rule, recording symptom/cause/rule/source" }, "summary": "Constrained the two stock units (logrotate-checkconf, nextcloud-cron) that raced nginx/Nextcloud on the files deploy's first activation, so switch-to-configuration no longer exits status 4.", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
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.

Reference
Matou/idss#1020
No description provided.