Skip to content

1.3 Step | SetupLogDir

Omisen edited this page Aug 14, 2026 · 2 revisions

Creates the directory for the Odoo log file, only if ODOO_LOGFILE is configured. Reversible. It lives in src/steps/setup_log_dir.rs. A port of setup_log_dir from lib/system.sh.

It runs after 1.2 CreateOdooUser, so the odoo user already exists and the log directory can be chowned to it.


Default: disabled → no-op

By design Odoo logs to journal/stdout through systemd, so ODOO_LOGFILE is empty and there is no directory to create. In that case the step is entirely Untracked: snapshot, run and undo are clean no-ops. No surprises, no artifacts.

The log file is resolved through the configuration cascade (.env key ODOO_LOGFILE, flag --logfile) and reaches the step as ctx.odoo_logfile: Option<PathBuf>.


Life cycle (with ODOO_LOGFILE set)

Phase Behaviour
snapshot does the log file's parent directory already exist? → Preexisting/Untracked
run Preexisting → skip (not ours); absent → mkdir + chown odoo:odoo + chmod 0750, then CreatedByUs. dry_run → log only
undo CreatedByUs and the directory is empty → rmdir. Non-empty (logs already written) → warning, no removal. Preexisting → no-op

Why the undo is cautious

  • Never delete logs that were already written. If the directory holds files, undo does not remove it (best-effort, no rm -rf) — those logs may be needed for the post-mortem.
  • A Preexisting directory is never removed: it is not ours.
  • Idempotent and best-effort, like every undo.

Like 1.2 CreateOdooUser, it goes through the testable SystemOps boundary (mkdir/chown/chmod/rmdir): the tests verify creation and removal without root and without touching the real filesystem.


Design notes

  • The step is almost always a no-op (the log file is disabled by default): all its complexity sits in the optional branch, handled with the same three PreStates as every other step.
  • Guaranteed ordering: it runs after CreateOdooUser, so the chown odoo:odoo has a valid user to point at.
  • Tests: disabled (total no-op), CreatedByUs (creates and removes), Preexisting (untouched), non-empty directory (the undo does not remove).

Clone this wiki locally