Skip to content

Download a redacted support bundle of a chosen log window from the dashboard #4036

Closed

Description

@pithead-architect

What's the problem

An appliance owner has no shell and no SSH, so there is no way to get logs off an appliance after an incident. pithead support-bundle is a host-CLI command a shell-less box cannot run (#786), and the planned live log viewer (#3978, v2.1.0) shows current logs only, not a past window. Child issue of #4032: the owner needs a dashboard action that produces a redacted bundle of the past log window (default last 72 hours) and streams it to the browser.

What it impacts

Every appliance owner who sees an outage, a stalled miner or a failed update; the project, which cannot diagnose user reports without logs (#3375); and monitoring triage, where a real outage and a failed health ping are indistinguishable without the box's own logs.

How I found it

From the parent issue #4032: the owner's production appliance Healthchecks went DOWN 2026-11-11 for 2 h 37 min and again 49 min, and the cause could not be confirmed because the appliance could not be read. Code facts verified in this checkout: dashboard/mining_dashboard/web/views/download_views.py carries the file-streaming route family and its module docstring states "The support-bundle download joins this module rather than server.py"; control_backup writes {rid}.tar.gz.enc into the control results spool and handle_backup_download streams it after checking the result is applied; the host control loop dispatches read-only asks (diag-doctor, diag-logs) in lib/pithead/49-control-request-loop.sh with host-side clamps in lib/pithead/46a-control-diagnostics.sh; bundle_redact_log (lib/pithead/07-support-bundle.sh) is the single redactor by ruling (#1585, #1750 — extend it, never a second list).

How important is it

High. The owner asked for it after a production incident; it is the prerequisite for supporting appliance users at all (parent #4032).

Acceptance criteria

  • A new read-only request kind on the host control loop (e.g. support-bundle) accepts an optional hours window; unset, non-numeric or out-of-range values fall back to 72, and the cap is clamped host-side exactly like control_diag_logs clamps lines (a bound the client asks for is not a bound).
  • The bundle contains, for the window: journalctl --since entries for every Pithead unit and container on the appliance (dashboard, caddy, tor, monerod, tari, p2pool, xmrig-proxy, docker-proxy, docker-control, the built-in miner, pithead-boot, update/RAUC units, address watch); the dashboard's health/status history; Tor bootstrap and circuit state; versions, the active RAUC slot, and the config shape keys-only (masked via render_masked_config + bundle_mask_config, values never included).
  • Every log line written into the archive passes through bundle_redact_log; if the journal surfaces a new leak class, bundle_redact_log grows and tests/integration/selftest/selftest-bundle-redact-log.sh gains the rows — no second redactor.
  • The archive is chmod 600, has a host-enforced total size cap, lands in the control results spool, and its result document carries status: "applied" plus an archive name, mirroring the backup kind so the existing poll (GET /api/control/result) works unchanged.
  • Dashboard: a POST spools the request behind the X-Pithead-Control CSRF header pattern used by diagnostics_views.py, and a new GET route in download_views.py streams the spool file in handle_backup_download's shape (UUID id, anything not applied 404s). Auth is Caddy's existing owner session (X-Auth-User); every request is recorded in the control audit log like the other control kinds.
  • A dashboard UI action lets the owner trigger the collection and download the archive once ready, with the default stated as the last 72 hours.
  • A tier-1 tests/stack case seeds a Monero payout address, an --rpc-login value, a 56-char .onion and an --http-access-token into the fixture inputs and asserts none of them appears anywhere in the produced archive; the same case asserts the default window, the host-side cap, and unit membership of the collected set.
  • Docs: docs/dashboard.md and docs/operations.md say how an owner downloads a bundle and how to send it with a bug report (cross-link Add a 'Report a bug' link (bugs@pitheadmining.com) to the shell and Maintenance #3746).

Possible solutions

Collect host-side in a new slice beside 46a-control-diagnostics.sh (or beside stack_support_bundle in 07-support-bundle.sh — one collector, since the recovery-state sibling issue reuses it); dispatch in 49-control-request-loop.sh; stream via download_views.py like backup-download. Note #3978's redactor is not merged (that issue is open for v2.1.0), so the shared redactor today is bundle_redact_log; the new code must call that function, not a copy.

Parent: #4032

Worker brief: Test tier: tier-1 tests/stack (plus GitHub tiers 1-3 green) and tier4-e2e targeted — the change touches the control channel and a deploy-served path, so an e2e job on the head must show the bundle action working against a deployed branch; quote the bench-ci evidence block in the PR.

Implement the dashboard side of the appliance support bundle for parent issue #4032, per the acceptance criteria on the issue. Ground rules from the code you will touch: read lib/pithead/49-control-request-loop.sh (dispatch case), lib/pithead/46a-control-diagnostics.sh (the read-only-ask pattern: audit lines, host-side clamps, redact-before-cap), lib/pithead/07-support-bundle.sh (bundle_redact_log is the only redactor; stack_support_bundle shows the masked-config and tar pattern), and dashboard/mining_dashboard/web/views/{diagnostics_views,download_views}.py plus server.py route registration (the module docstrings name this download's intended home and shape). Reuse control_service.submit/result and the existing poll; do not add a second polling route. Run make lint-file-budget and make lint-pithead-build before pushing, run the generated-CLI build (scripts/build-pithead.sh / make) since lib/pithead changes, and add a failing-first tests/stack selftest with a seeded secret that must never appear in the archive. Keep each edited file inside its line budget. Do not implement the notifier ping-failure logging, the recovery-state CLI bundle, or journald config changes — those are sibling child issues.

Activity

  1. added this to the v2.0.4 milestone on Nov 11, 2026
  2. added
    dashboard
    appliance
    P1-user-facing
    needs-triage
    size:M
    on Nov 11, 2026
  3. pithead-developer commented on Nov 12, 2026

    @pithead-developer
    Contributor

    Needs an operator action (do it, then remove the operator-action label):

    Required human action, a prerequisite BEFORE this PR can merge: draft PR #4053 (head 734f2cb, MERGEABLE) must be approved, marked ready for review — a draft cannot merge — and merged; per contributor rules the agent never merges, and on merge the PR's verified closing references close #4036, #4037 and #4038 (re-checked this round: closingIssuesReferences = [4036, 4037, 4038], restored after the unclosed-fence defect that had suppressed them). Candidate evidence at that head: all 43 required checks pass with only the 2 pre-existing CVE-sweep skips and nothing pending; both reviewer findings fixed at root cause (GNU-bash hour clamp; prune result-archive pairing; recovery-bundle declared in both verb locks with its honest ledger missing row owned by filed #4054); tier4-e2e bench evidence published unedited — job 878 success (324 pass/0 fail) and job 879 success (319 pass/0 fail, baseline verified, rig restored). No code, bench or CI work remains open and nothing waits on the action's status; only the owner's review-and-merge stands between this and closure of all three grouped issues.

  4. added
    operator-action
    on Nov 12, 2026
  5. pithead-developer commented on Nov 13, 2026

    @pithead-developer
    Contributor

    Operator, 2026-11-13: the agent review of PR #4053 at head 734f2cb never ran. All four attempts on 2026-11-12, the last at 17:03Z, failed in about 3 s while the Claude plan was capped, so there is no agent PASS at this head yet. The rule is an agent PASS first, then the owner's approval. I removed operator-action so the runner can re-run the review now that the plan has reset. The owner approves once that PASS lands.

  6. removed
    operator-action
    on Nov 13, 2026
  7. pithead-developer commented on Nov 13, 2026

    @pithead-developer
    Contributor

    Merged in #4053.

  8. added a commit that references this issue on Nov 13, 2026
    cddb359
  9. added a commit that references this issue on Nov 21, 2026
    ae97bda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-user-facingappliancedashboardneeds-triagesize:M

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions