fix: bug: disinto init --backend=nomad — does not bootstrap Forgejo admin user (#1069) #1073
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#1073
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-1069"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1069
Changes
3ce31116acto23e47e3820AI Review
Summary
PR adds
forgejo-bootstrap.shand wires it into bothdeploy.shandbin/disintoto create the Forgejo admin user post-deploy. The idempotency contract and script structure are sound, but three correctness bugs block merge.Blockers
bug
lib/init/nomad/forgejo-bootstrap.sh:98:|| trueis inside the double quotes — it becomes a literal string suffix on the assignment, not a shell error suppressor.token_rawends up as<vault JSON output> || true(a string).jqthen receives malformed input and returns empty,FORGE_TOKENstays unset, and the script dies at line 103: "FORGE_TOKEN not set and not found in Vault". Fix: move|| trueoutside the quotes:bug
lib/init/nomad/deploy.sh:268-271:_run_post_deployis called unconditionally after_wait_job_running, even when the job failed to reach healthy state and was added toFAILED_JOBS. If forgejo never starts, bootstrapping it anyway will fail (or silently succeed against a half-started process). The post-deploy block must be gated on the job being healthy:bug
bin/disinto:1060,1076: Bothdeploy.shandforgejo-bootstrap.share invoked viasudo -nfor non-root users.sudoappliesenv_resetby default, stripping inherited vars.forgejo-bootstrap.shrequiresFORGE_ADMIN_PASS(checked unconditionally at startup, line 90–92) and optionallyFORGE_TOKENandFORGE_URL. Undersudo -nall three are dropped — the script will always die with "FORGE_ADMIN_PASS is not set" on any non-root deployment. Fix: use--preserve-envor pass the required vars explicitly:The same fix is needed transitively: when
deploy.shis called viasudo -n(line 1060), the env vars are already gone beforedeploy.shcan spawnforgejo-bootstrap.shinternally. Sodeploy.shalso needs those vars preserved.Advisory (non-blocking)
info
lib/init/nomad/forgejo-bootstrap.sh:108,130,161: Step labels are inconsistent — "Step 1/2", "Step 2/2", then a later "Step 3/3" section heading. Minor but confusing.info
lib/init/nomad/forgejo-bootstrap.sh:112-127: User existence check uses/api/v1/users/search?q=...which is a substring/prefix search, not an exact match. The code then checks.data[0].idwithout verifying.data[0].login == FORGE_ADMIN_USER. A false-positive match (e.g., a user whose name contains "disinto-admin" as a prefix) would skip creation. On a fresh install this is unlikely to matter, but usingGET /api/v1/users/{username}(returns 404 if absent, 200 with exact user if present) would be more correct.info
bin/disinto:1063-1081+lib/init/nomad/deploy.sh:268-271:forgejo-bootstrap.shis invoked twice for forgejo: once insidedeploy.sh's_run_post_deployand again inbin/disinto's post-deploy block. The second call is a no-op due to idempotency, but the duplication is redundant. Consider removing thebin/disintoblock and relying solely ondeploy.sh's post-deploy hook.Verdict
REQUEST_CHANGES — Three bugs: || true inside quotes corrupts Vault token read; post-deploy runs on failed jobs; sudo -n drops required env vars
Reviewed at
a7bcb96| AGENTS.mdAI Review: REQUEST_CHANGES — Three bugs: || true inside quotes corrupts Vault token read; post-deploy runs on failed jobs; sudo -n drops required env vars
AI Re-review (round 2)
Previous Findings
forgejo-bootstrap.sh:98—|| trueinside quotes corrupted Vault token read → FIXED (|| truemoved outside the quotes)deploy.sh:268-271—_run_post_deploycalled unconditionally on failed jobs → FIXED (call now gated insideelsebranch)bin/disinto:1060,1076—sudo -nstripped required env vars → FIXED (--preserve-env=FORGE_ADMIN_PASS,FORGE_TOKEN,FORGE_URLadded to bothsudocalls)Advisory items from previous review:
GET /api/v1/users/{username})New Issues
forgejo-bootstrap.sh:115:$?check for exit code 7 inside|| { }is misleading. curl exit code 7 is "couldn't connect to host"; a 404 from-freturns exit code 22. Both branches setadmin_user_exists=false, so behavior is identical and correct — only the log message is wrong (404 logs "Forgejo may not be ready yet" instead of "user not found"). No functional impact.Verdict
APPROVE — All three blockers from previous review are fixed; new advisory items are non-blocking
Reviewed at
95bacbb| Previous:a7bcb96| AGENTS.mdAI Re-review (round 2): APPROVE — All three blockers from previous review are fixed; new advisory items are non-blocking