Files
seaweedfs/seaweed-block/docs/design/inspection-shell.md
T

77 lines
4.9 KiB
Markdown

# Inspection shell
`sw-block shell -master 127.0.0.1:9000` reads commands from stdin; `-c` runs one
command. This is a client over the existing evidence, workspace-query and filer
interfaces. It adds no server state, control RPC or authority decision. Existing
`ops` commands retain their flags and output.
```sh
sw-block shell -master 127.0.0.1:9000 -c 'volume.list -o json'
printf 'cluster.status\nvolume.status v1 -o json\nquit\n' | sw-block shell -master 127.0.0.1:9000
sw-block shell -master 127.0.0.1:9000 -filer 127.0.0.1:18888 -server-id host1 -status-addr 127.0.0.1:9090 -c 'cluster.check v1'
```
The inspection commands are `cluster.status`, `cluster.check [volume]`,
`volume.list`, `volume.status <volume>`, `volume.explain <volume>`,
`snapshot.list <volume>`, `store.show <volume>`, `store.usage <volume>` and
`volume.verify <volume>`. `log.collect -out DIR` creates a local support bundle;
see [Log collection](log-collect.md). `-o json` selects JSON. Store commands reuse the
existing chunk commands' JSON bodies in either output mode. Mutations are not
inspection commands; use the existing admitted `ops` paths.
Shell flags supply the master, filer, chunk path and local holder status address
once. No endpoint is discovered from an absent master field. `-server-id`
defaults to the local hostname; set it to the local blockvolume's actual server
ID when they differ. A host check runs only when that ID matches the master's
primary host. The response must also name the observed volume, replica and epoch.
Status HTTP is restricted to explicit loopback IPs and refuses redirects. Do not
enable an unauthenticated external status listener for remote inspection.
`cluster.check` emits the fourteen checks in the troubleshooting page's order.
Each failed line includes the same cure paragraph and a link to its page section.
Tests pin both order and cure paragraphs. Exit 0 means all checks completed
without findings, 1 reports a failed check, 2 is invalid input and 3 means at
least one check could not be performed here. Off-host or unavailable data never
becomes `ok`. A deliberately selected local-engine backend is a checked capability:
`volume.chunkstore` reports `ok: local engine only: no snapshots`, while
`volume.cut` and `volume.cleaning` report `not applicable: no chunk store`.
Those capability outcomes do not change the exit code. A stream retains any nonzero command result even if a later command
succeeds. Quotes group words; there is no shell expansion or subprocess execution.
These are separate read observations, not one atomic snapshot. A changed primary
can require rerunning the command. Workspace lease evidence applies to RF1 only.
Heartbeat freshness is the master's yes/no observation; the registration time is
not shown as heartbeat age. The clock check compares blockmaster's reported time
with the midpoint of the client's request and response times. It adds half the
request round trip as uncertainty to the absolute midpoint difference, and
reports FAIL when that sum is at least half the configured `-max-clock-skew`
(default 20 s, so a 10 s check threshold). Configure it to match blockmaster.
The measured number includes request latency: a high reading alone does not
prove a clock offset.
Cut failures are cumulative since process start. A single observation with a
historical failure count cannot prove a new failure; it is reported as incomplete
with the count and the log reference. Pending HEAD outcomes and overdue scheduled
snapshots are explicit findings. Missing version, readiness or cut fields are
reported as unavailable, with no inferred healthy default.
The cleaning-result check reads `Chunk.Maintenance`: `passesOk`, optional
`lastPass{atNs,planned,removed,error,headGen,headGenError}`, `inProgress` and `currentStartNs`.
`removed` is the total number of removed chunks, roots and segments, not just
chunks. `planned` is likewise the total planned removals. The row also shows
`plannedChunks`, `plannedRoots`, `plannedSegments`, `removedChunks`,
`removedRoots` and `removedSegments` from that pass, so an older root or segment
backlog can be distinguished from chunk work. These six fields are counts of
objects, not bytes; none replaces the corresponding total.
An absent last pass or recorded error cannot become ok. Missing required fields,
an unknown or zero cleaning HEAD generation without a diagnostic note, and an
absent or null error field are unavailable. An explicit empty `error` is required
for a completed pass. `headGenError` is a separate diagnostic: if cleaning
completed but reading its HEAD generation failed, the row is `ok` and shows that
note even with `headGen` zero. A nonempty `error` still reports a failed pass;
the diagnostic never hides a cleaning failure.
A pass still running is incomplete, with its start time shown. Older builds
without Maintenance give an unavailable observation. Build revisions likewise
depend on the master and holder publishing their revisions. This client does not
implement the exact HEAD-generation accounting verdict.