Skip to content

fix(#432): setup_log_file temp fallback so prepare-host never bare-fails on an NFS home - #512

Merged
shujaatTracebloc merged 2 commits into
developfrom
fix/432-nfs-guard-ordering
Jul 31, 2026
Merged

fix(#432): setup_log_file temp fallback so prepare-host never bare-fails on an NFS home#512
shujaatTracebloc merged 2 commits into
developfrom
fix/432-nfs-guard-ordering

Conversation

@shujaatTracebloc

@shujaatTraceblocshujaatTracebloc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

#432 — network-FS guard runs before the log dir is created

Most of #432 already shipped in #441 (commit dacba26, "run the network-FS guard before the log dir is created"): early_data_dir_guard now runs before setup_log_file in the full install, and validate_config (before it) only validates — it never mkdirs. That path is done, with a #432 ordering test already in preflight.bats.

This PR closes the one path #441 didn't cover: prepare-host.main() calls setup_log_file on the prepare-host branch before any guard, and setup_log_file did a bare mkdir -p "$HOST_DATA_DIR" + tee. On an NFS home under sudo + root_squash — the exact scenario #432 names — that failed with a cryptic mkdir/tee error before any friendly message (or landed the log nobody-owned).

Fix:setup_log_file now picks its path via a small, testable _choose_log_fileHOST_DATA_DIR when it's creatable and writable, else a temp file (the scope's "start logging in a temp location" option). No install path dies on a bare mkdir/tee anymore. The full install's early_data_dir_guard still refuses a network data dir before this runs, unchanged. (The temp template uses trailing X's — BSD mktemp on macOS rejects a suffix after XXXXXX.)

Acceptance

Tests

_choose_log_file: returns a path under a writable HOST_DATA_DIR; falls back to a temp path (never a bare failure) when the dir is uncreatable/unwritable. shellcheck --severity=error + check-style + check-drift clean; scripts/manifest.sha256 regenerated (R8).

Note: two suites carry a pre-existing macOS-only failure on clean develop (validate_config: valid config passes, early bailout: healthy tracebloc doctor) — unrelated to this change (they pass on the Linux CI leg).

Closes#432


Note

Low Risk
Small, defensive change to installer logging path selection with unit tests; no change to full-install guard ordering or cluster/data semantics.

Overview
setup_log_file no longer assumes HOST_DATA_DIR is creatable. A new _choose_log_file helper tries mkdir -p plus a write probe under HOST_DATA_DIR; if that fails, it uses mktemp with a BSD-safe XXXXXX suffix (no .log after the X’s), or /dev/null as last resort. setup_log_file only sets LOG_FILE from that helper and then tees as before.

This closes the prepare-host gap left after #441: that path calls setup_log_file before any network-FS guard, so NFS home + sudo + root_squash used to die with a cryptic mkdir/tee error (or mis-owned logs) instead of continuing to user-facing errors. The full install’s early_data_dir_guard ordering is unchanged.

Bats cover writable vs uncreatable HOST_DATA_DIR; scripts/manifest.sha256 is updated for common.sh.

Reviewed by Cursor Bugbot for commit 0ca5bf2. Bugbot is set up for automated code reviews on this repo. Configure here.

…isn't writable
#432's documented core — running the network-FS guard before the log dir is created
in the FULL install — already shipped in #441 (early_data_dir_guard runs before
setup_log_file; validate_config before it only validates, never mkdirs). This closes
the remaining path #441 didn't cover: prepare-host calls setup_log_file BEFORE any
guard, and setup_log_file did a bare `mkdir -p "$HOST_DATA_DIR"` + tee — so on an NFS
home under sudo + root_squash (the exact scenario #432 names) it failed with a cryptic
error before any friendly message.
setup_log_file now chooses its path via _choose_log_file: HOST_DATA_DIR when it's
creatable AND writable, else a temp file (the scope's "start logging in a temp
location" option) — so no install path dies on a bare mkdir/tee. The full install's
early_data_dir_guard still refuses a network DATA dir before this runs, unchanged.
(Also: the temp template uses trailing X's — BSD mktemp on macOS rejects a suffix
after XXXXXX.)
Tests: _choose_log_file returns a path under a writable HOST_DATA_DIR, and falls back
to a temp path (never a bare failure) when the dir is uncreatable/unwritable.
Closes#432
@shujaatTraceblocshujaatTracebloc self-assigned this Jul 31, 2026
@shujaatTracebloc
shujaatTracebloc marked this pull request as ready for review July 31, 2026 09:24
…ordering
# Conflicts:
#	scripts/manifest.sha256
@shujaatTracebloc
shujaatTracebloc merged commit 4116d38 into developJul 31, 2026
37 checks passed
@LukasWodka

Copy link
Copy Markdown
Contributor

/fr-pass

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@shujaatTracebloc@LukasWodka@saadqbal@divyasinghds