diff --git a/seaweed-block/cmd/sw-block/shell_check.go b/seaweed-block/cmd/sw-block/shell_check.go index f2f1fe4212..854cf9be8a 100644 --- a/seaweed-block/cmd/sw-block/shell_check.go +++ b/seaweed-block/cmd/sw-block/shell_check.go @@ -55,6 +55,7 @@ type durableInspection struct { Removed *uint64 `json:"removed"` Error *string `json:"error"` HeadGen *uint64 `json:"headGen"` + HeadGenError *string `json:"headGenError"` PlannedChunks *uint64 `json:"plannedChunks"` PlannedRoots *uint64 `json:"plannedRoots"` PlannedSegments *uint64 `json:"plannedSegments"` @@ -464,13 +465,17 @@ func (o *inspectionObservation) cleaning() checkFinding { if p.AtNs == nil || p.Planned == nil || p.Removed == nil || p.HeadGen == nil || p.Error == nil || p.PlannedChunks == nil || p.PlannedRoots == nil || p.PlannedSegments == nil || p.RemovedChunks == nil || p.RemovedRoots == nil || p.RemovedSegments == nil { return checkElsewhere("last cleaning result fields unavailable") } - if *p.HeadGen == 0 { + if *p.HeadGen == 0 && (p.HeadGenError == nil || *p.HeadGenError == "") { return checkElsewhere("cleaning HEAD generation unavailable; no observed cleaning pass") } if *p.AtNs <= 0 || *m.PassesOK == 0 { return checkFail("no successful cleaning pass recorded") } - return checkOK(fmt.Sprintf("last pass at_ns=%d planned=%d removed=%d plannedChunks=%d plannedRoots=%d plannedSegments=%d removedChunks=%d removedRoots=%d removedSegments=%d head_gen=%d passesOk=%d", *p.AtNs, *p.Planned, *p.Removed, *p.PlannedChunks, *p.PlannedRoots, *p.PlannedSegments, *p.RemovedChunks, *p.RemovedRoots, *p.RemovedSegments, *p.HeadGen, *m.PassesOK)) + finding := fmt.Sprintf("last pass at_ns=%d planned=%d removed=%d plannedChunks=%d plannedRoots=%d plannedSegments=%d removedChunks=%d removedRoots=%d removedSegments=%d head_gen=%d passesOk=%d", *p.AtNs, *p.Planned, *p.Removed, *p.PlannedChunks, *p.PlannedRoots, *p.PlannedSegments, *p.RemovedChunks, *p.RemovedRoots, *p.RemovedSegments, *p.HeadGen, *m.PassesOK) + if p.HeadGenError != nil && *p.HeadGenError != "" { + finding += fmt.Sprintf(" headGenError=%q", *p.HeadGenError) + } + return checkOK(finding) } return checkFail("selected volume absent from durable status") }) diff --git a/seaweed-block/cmd/sw-block/shell_test.go b/seaweed-block/cmd/sw-block/shell_test.go index ca08775305..471d9b245a 100644 --- a/seaweed-block/cmd/sw-block/shell_test.go +++ b/seaweed-block/cmd/sw-block/shell_test.go @@ -96,7 +96,7 @@ func TestShellCheckUsesTypedLeaseReadinessCutAndVersionAnswers(t *testing.T) { {"healthy", ""}, {"disabled", "master.lifecycle"}, {"lease-expired", "volume.lease"}, {"lease-revoking", "volume.lease"}, {"lease-wrong-holder", "volume.lease"}, {"frontend-false", "volume.frontend"}, {"cut-pending", "volume.cut"}, {"snapshot-overdue", "volume.cut"}, {"missing-cut-fields", "volume.cut"}, {"version-missing", "versions.equal"}, {"version-mismatch", "versions.equal"}, {"cleaning-error", "volume.cleaning"}, {"cleaning-not-run", "volume.cleaning"}, {"cleaning-running", "volume.cleaning"}, {"cleaning-missing", "volume.cleaning"}, - {"missing-cleaning-head-gen", "volume.cleaning"}, {"null-cleaning-head-gen", "volume.cleaning"}, {"missing-cleaning-breakdown", "volume.cleaning"}, {"retention-only", "volume.cleaning"}, {"missing-cleaning-error", "volume.cleaning"}, {"null-cleaning-error", "volume.cleaning"}, {"completed-empty", ""}, {"no-chunk-store", "volume.cut"}, + {"missing-cleaning-head-gen", "volume.cleaning"}, {"null-cleaning-head-gen", "volume.cleaning"}, {"missing-cleaning-breakdown", "volume.cleaning"}, {"retention-only", "volume.cleaning"}, {"missing-cleaning-error", "volume.cleaning"}, {"null-cleaning-error", "volume.cleaning"}, {"completed-empty", ""}, {"completed-head-gen-note", ""}, {"failed-head-gen-note", "volume.cleaning"}, {"no-chunk-store", "volume.cut"}, } { t.Run(tc.mode, func(t *testing.T) { ln, err := net.Listen("tcp", "127.0.0.1:0") @@ -127,7 +127,7 @@ func TestShellCheckUsesTypedLeaseReadinessCutAndVersionAnswers(t *testing.T) { delete(stats, "PendingUnresolved") } chunk := map[string]any{"Attached": true, "Stats": stats, "ScheduledSnapshot": map[string]any{"snapshot_overdue": tc.mode == "snapshot-overdue", "lastFailure": map[string]any{"code": "remote_unavailable"}}} - lastPass := map[string]any{"atNs": time.Now().UnixNano(), "planned": 11, "removed": 6, "plannedChunks": 3, "plannedRoots": 5, "plannedSegments": 3, "removedChunks": 2, "removedRoots": 1, "removedSegments": 3, "error": "", "headGen": 7} + lastPass := map[string]any{"atNs": time.Now().UnixNano(), "planned": 11, "removed": 6, "plannedChunks": 3, "plannedRoots": 5, "plannedSegments": 3, "removedChunks": 2, "removedRoots": 1, "removedSegments": 3, "error": "", "headGen": 7, "headGenError": ""} if tc.mode == "retention-only" || tc.mode == "completed-empty" { lastPass["planned"] = 0 lastPass["removed"] = 0 @@ -144,6 +144,13 @@ func TestShellCheckUsesTypedLeaseReadinessCutAndVersionAnswers(t *testing.T) { if tc.mode == "missing-cleaning-breakdown" { delete(lastPass, "removedRoots") } + if tc.mode == "completed-head-gen-note" || tc.mode == "failed-head-gen-note" { + lastPass["headGen"] = 0 + lastPass["headGenError"] = "HEAD read unavailable after completed cleaning" + } + if tc.mode == "failed-head-gen-note" { + lastPass["error"] = "cleaning failed" + } if tc.mode == "retention-only" { lastPass["headGen"] = 0 } @@ -217,6 +224,11 @@ func TestShellCheckUsesTypedLeaseReadinessCutAndVersionAnswers(t *testing.T) { if code != 3 { t.Fatalf("expected incomplete only for missing filer, exit=%d out=%s", code, &out) } + if tc.mode == "completed-head-gen-note" { + if finding := rows["volume.cleaning"].Finding; !strings.Contains(finding, "HEAD read unavailable after completed cleaning") { + t.Fatalf("completed cleaning lost generation-read note: %s", finding) + } + } if tc.mode == "healthy" { finding := rows["volume.cleaning"].Finding for _, part := range []string{"planned=11", "removed=6", "plannedChunks=3", "plannedRoots=5", "plannedSegments=3", "removedChunks=2", "removedRoots=1", "removedSegments=3"} { diff --git a/seaweed-block/docs/design/inspection-shell.md b/seaweed-block/docs/design/inspection-shell.md index 72ed8bbf52..9041acf608 100644 --- a/seaweed-block/docs/design/inspection-shell.md +++ b/seaweed-block/docs/design/inspection-shell.md @@ -55,7 +55,7 @@ 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}`, `inProgress` and `currentStartNs`. +`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`, @@ -63,8 +63,12 @@ chunks. `planned` is likewise the total planned removals. The row also shows 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, and an absent or null error field -are unavailable. An explicit empty error is required for a completed pass. +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