Files
seaweedfs/seaweed-block/docs/design/log-collect.md
T
pingqiuandClaude Opus 5.5 241f7981b1 log.collect: any declared source not read whole makes redaction unproven
A declared log file refused before discovery (not a regular file, changed,
over 4 MiB, not text, unreadable), a process whose arguments could not be
read, and a failed or truncated unit command each make the bundle
manifest-only, not only a unit cut by the time budget. A missing file or a
gone process holds nothing to discover and stays only unavailable. In an
unproven bundle every artifact error is replaced by a fixed one, and the
skipped names are printed sanitized. A known credential used as a JSON
object key is redacted too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 04:40:32 -08:00

7.5 KiB

Collect a support bundle

log.collect collects read-only diagnostics in a new directory. Run it on the volume host: the holder status pages, process arguments and daemon logs are local. It starts no service and writes no volume, HEAD, snapshot or configuration.

For systemd:

sw-block shell -master 127.0.0.1:9000 -filer 127.0.0.1:18888 \
  -server-id host-a -status-addr 127.0.0.1:9090 -timeout 30s \
  -c 'log.collect -out ./support -since 15m -unit sw-blockmaster.service -unit sw-blockvolume.service'

For sw-block mini or another foreground deployment, select the daemon log files and the running process IDs. Each -pid reads only that Linux process's startup arguments, never its environment or the files named by its arguments. The following uses mini's default ports; replace the sample PIDs with its printed blockmaster and blockvolume PIDs:

sw-block shell -master 127.0.0.1:9180 -filer 127.0.0.1:18888 \
  -server-id s1 -status-addr 127.0.0.1:9203 \
  -c 'log.collect -out ./support -since 15m -log-file ./swb-mini/blockmaster.log -log-file ./swb-mini/blockvolume.log -pid 1234 -pid 1235 -o json'

The output directory must not exist, and its parent must exist. No existing bundle is overwritten. Directory and file modes are 0700 and 0600 on Unix. The command's -o json result reports whether the directory was written and whether collection was complete; it does not print raw diagnostic errors.

Contents and missing observations

manifest.json names each artifact and marks it collected or unavailable, with a reason for unavailable or bounded-out data. Filenames are generated ordinals, never copied source paths, volume names or unit names.

Artifact Observation
versions.json Client build and master's reported revision
cluster.json Existing master evidence, including host and volume identity
cluster-check.json The same typed checks as cluster.check
volume-NNN-status.json, -durable.json, -nvme.json Local holder status pages
volume-NNN-head.json Existing read-only store.show HEAD and VOLUME summary
unit-NNN-flags.txt, process-NNN-flags.json Unit ExecStart or Linux process startup arguments
unit-NNN.log, file-NNN.log Selected daemon logs in the requested time window

The filer is required for HEAD summaries. The local server ID must match the master's primary host before a status page is read. Off-host status is marked unavailable with the host to use; no unauthenticated external listener is enabled. These are separate observations, not an atomic snapshot.

With no -log-file or -unit, collection selects sw-blockmaster.service and discovers the host's loaded holder units with systemctl list-units --all, including active and inactive sw-blockvolume@<volume>.service instances from volume start, and any plain or ublk holder unit. Discovery is recorded in unit-discovery.json. Only when none are found does it try the legacy plain sw-blockvolume.service; failed discovery or sources remain incomplete. At most 31 discovered holder units accompany the master unit. Explicit file/unit selections keep exactly the supplied sources. Each selected unit uses read-only systemctl show and journalctl; missing programs, permission errors, unavailable pages and old builds remain explicit. With file sources but no unit or PID, startup arguments are unavailable.

Exit 0 means all selected sources were collected, not that the cluster is healthy. A collected check may report a failure. Exit 3 means some sources were unavailable; inspect the manifest. Exit 2 is invalid input or existing output, and exit 1 is a bundle write failure. A write failure can leave a partial, already sanitized directory; a missing manifest is not a completed bundle.

Time and size bounds

-since defaults to 15 minutes and accepts a positive duration up to 24 hours. The window ends when collection starts. Local file logs are read before remote observations, so an unresponsive master does not consume their collection budget. Journal requests carry both endpoints, UTC output and no pager. Files accept the daemons' UTC Go timestamps (including microseconds) or ISO timestamps. Continuation lines follow their preceding dated record; undated leading text is omitted. A file with no dated records is unavailable.

At most 32 explicit file/unit/PID selections and 32 volumes are collected. Sources and sanitized artifacts are limited to 4 MiB each, with 32 MiB aggregate artifact budgets and 1 MiB log records. A file larger than 4 MiB is refused rather than starting inside an unrecognized multiline credential; rotate it or select a bounded journal window. Links, pipes and non-UTF-8 log files are refused. Linux acquisition is nonblocking and does not follow links, including if the path changes after inspection. Local file acquisition is supported on Linux and Windows; other platforms mark selected files unavailable. Structured JSON keeps exact integer values. The shell timeout bounds status and journal collection; the reused store command's name resolution and reads share the same deadline. No unbounded subprocess output is buffered. Each -log-file is read whole for credential discovery whatever the timeout has left (each is bounded at 4 MiB, at most 32 sources); a missing file is only unavailable.

Credential handling

All retained source data stays in bounded memory until credential discovery finishes. Bounded log inputs are scanned before the time filter; credentials in sources omitted by the aggregate artifact budget still teach redaction of their repeats. A discovery scan that exhausts its match bound refuses all output. Redaction not proven: when a declared source (-log-file, -unit, -pid) was not read whole for discovery (cut by the timeout, over its bound, not text, a link or pipe, unreadable, a failed or truncated command), the bundle holds only manifest.json ("redaction": "not_proven", the sources named in skipped, fixed diagnostics only), and the command prints incomplete: redaction not proven and exits 3. Only sanitized artifacts are written; raw sources are never staged in the bundle. The same boundary sanitizes structured status, startup arguments, logs and manifest errors. Sensitive key/value and flag names include password, token, credential, authorization, API/access/private/TLS/control/client/signing key, JWT and HMAC. Bearer and Basic authorization, URL user information and private-key PEM blocks are masked. Explicitly identified credential values, including short passwords and JSON/URL-escaped forms, are also removed from other collected text. Empty values, true/false/yes/no/null and digits-only values shorter than eight bytes do not seed global replacement. Bare whitespace prose never teaches global replacement rules; ordinary words, dates and generation numbers must remain readable. These ordinary values are still masked in their keyed/flag context. Unknown fields under a credential container are removed.

Claim IDs remain support identifiers; they are not credentials. Ordinary diagnostic lines and typed observations remain useful. No configuration tree, environment, private-key file or guest data directory is swept. Use daemon logs, not arbitrary application files: an opaque value with no credential label or known source cannot be classified reliably. The planted-credential tests scan every emitted artifact and command output; a disabled-redaction mutation must fail them.

Log text is evidence for an operator. Runner decisions still use typed product answers; bundle log text is not a health, durability or exact-generation verdict.