Skip to content

fix(debug): make top and logs work without root or a ps binary - #8

Merged
chxmxii merged 1 commit into
mainfrom
fix/logs-top-unprivileged
Aug 23, 2026
Merged

chxmxii merged 1 commit into
mainfrom
fix/logs-top-unprivileged

Conversation

@chxmxii

@chxmxii chxmxii commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Fixes the dashboard/CLI top and logs failures reported on rootless setups ("check /proc" placeholder, nsenter permission text shown as logs).

Why it broke:

  • top tries ps aux inside the container (absent from slim/distroless images), then nsenter (needs root). The last resort just printed "use /proc/N/root/proc for detailed listing".
  • logs only accepted non-empty native log output, so quiet containers fell through to an nsenter tail fallback — and its stderr (nsenter: cannot open /proc/...: Permission denied) was returned as log content.

Fixes:

  • top: new unprivileged last resort walks the host /proc process tree rooted at the container's init PID (status/cmdline are world-readable). Verified live rootless against a pause container (no shell, no ps): lists /pause correctly.
  • logs: a successful native log API call is authoritative — quiet containers show (no log output); the nsenter fallback never returns its own stderr as logs, and failures name both errors with a needs-root hint.
  • README install snippet bumped to v0.1.2 (to be tagged after merge).

Verification: go vet + go test -race green (new unit tests for the /proc walker); live E2E via tmux against rootless Podman 5.8.4: logs overlay shows (no log output) for a quiet container and real content for a logging one; top overlay lists processes for a ps-less image.

🤖 Generated with Claude Code

top: the last-resort fallback printed a useless "use /proc/N/root/proc"
placeholder when the image has no ps and nsenter fails (it needs root —
the common case for rootless Podman). It now walks the host /proc process
tree rooted at the container's init PID, which needs no privileges since
/proc/<pid>/status and cmdline are world-readable.

logs: a successful native log API call is now authoritative — a container
that simply hasn't written anything shows "(no log output)" instead of
cascading into fallbacks. The nsenter fallback also no longer returns its
own stderr ("nsenter: cannot open /proc/...: Permission denied") as if it
were log content.

README: bump install snippet to v0.1.2.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chxmxii
chxmxii merged commit 258c712 into main Aug 23, 2026
1 check passed
Sign up for free to 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.

1 participant