host: the disk alert names /run inodes, the cleanup says unpinned
Copy accuracy from round 2: /run inode use reads "/run has used N% of its inodes", and the cleanup's journal line says the removed build was unpinned rather than never adopted. Copy not yet reviewed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+21
−12
internal/host/alertsink.go+10 −8internal/host/demodisk_status.go+2 −1internal/host/demodisk_status_test.go+6 −0internal/metrics/alert.go+3 −3
diff --git a/internal/host/alertsink.go b/internal/host/alertsink.go| index 58b6d3eac..89ac9e7da 100644 |
| --- a/internal/host/alertsink.go |
| +++ b/internal/host/alertsink.go |
| @@ -419,11 +419,12 @@ func alertSentence(ev metrics.Event) string { |
| name, subject := metrics.SplitRule(ev.Rule) |
| switch name { |
| case "disk": |
| - switch ev.Where { |
| - case "": |
| + fs, inodes := strings.CutSuffix(ev.Where, " inodes") |
| + switch { |
| + case ev.Where == "": |
| return fmt.Sprintf("disk is %s full on %s", pct(ev.Value), ev.Box) |
| - case diskWhereDataInodes: |
| - return fmt.Sprintf("/data has used %s of its inodes on %s", pct(ev.Value), ev.Box) |
| + case inodes: |
| + return fmt.Sprintf("%s has used %s of its inodes on %s", fs, pct(ev.Value), ev.Box) |
| default: |
| return fmt.Sprintf("%s is %s full on %s", ev.Where, pct(ev.Value), ev.Box) |
| } |
| @@ -450,11 +451,12 @@ func alertClearSentence(ev metrics.Event) string { |
| name, subject := metrics.SplitRule(ev.Rule) |
| switch name { |
| case "disk": |
| - switch ev.Where { |
| - case "": |
| + fs, inodes := strings.CutSuffix(ev.Where, " inodes") |
| + switch { |
| + case ev.Where == "": |
| return fmt.Sprintf("disk is back to %s full on %s", pct(ev.Value), ev.Box) |
| - case diskWhereDataInodes: |
| - return fmt.Sprintf("/data is back to %s of its inodes used on %s", pct(ev.Value), ev.Box) |
| + case inodes: |
| + return fmt.Sprintf("%s is back to %s of its inodes used on %s", fs, pct(ev.Value), ev.Box) |
| default: |
| return fmt.Sprintf("%s is back to %s full on %s", ev.Where, pct(ev.Value), ev.Box) |
| } |
diff --git a/internal/host/demodisk_status.go b/internal/host/demodisk_status.go| index 7e8e705f6..a63ac7bdf 100644 |
| --- a/internal/host/demodisk_status.go |
| +++ b/internal/host/demodisk_status.go |
| @@ -80,6 +80,7 @@ const ( |
| diskWhereData = "/data" |
| diskWhereDataInodes = "/data inodes" |
| diskWhereRun = "/run" |
| + diskWhereRunInodes = "/run inodes" |
| ) |
| // demoDiskFill is the highest use of anything d read: /data's blocks and |
| @@ -104,7 +105,7 @@ func demoDiskFill(d *status.DemoDisk) *diskReading { |
| } |
| if r := d.Run; r != nil { |
| higher(r.FreeBytes, r.Bytes, diskWhereRun) |
| - higher(r.FreeInodes, r.Inodes, diskWhereRun) |
| + higher(r.FreeInodes, r.Inodes, diskWhereRunInodes) |
| } |
| return fill |
| } |
diff --git a/internal/host/demodisk_status_test.go b/internal/host/demodisk_status_test.go| index 3ed0adf99..383e116cb 100644 |
| --- a/internal/host/demodisk_status_test.go |
| +++ b/internal/host/demodisk_status_test.go |
| @@ -95,6 +95,10 @@ func TestDemoDiskFillIsTheHighestUse(t *testing.T) { |
| if got := demoDiskFill(d); got == nil || got.frac != 1 || got.where != diskWhereData { |
| t.Fatalf("fill = %+v, want /data's blocks", got) |
| } |
| + d.Data.FreeBytes, d.Run.FreeInodes = 90, 0 |
| + if got := demoDiskFill(d); got == nil || got.frac != 1 || got.where != diskWhereRunInodes { |
| + t.Fatalf("fill = %+v, want /run's inodes", got) |
| + } |
| if demoDiskFill(nil) != nil || demoDiskFill(&status.DemoDisk{Data: &status.FilesystemRoom{}}) != nil { |
| t.Fatal("no reading made a fill") |
| } |
| @@ -180,6 +184,8 @@ func TestFormatAlertNamesTheFilesystemMeasured(t *testing.T) { |
| {diskWhereData, true, "carlos alert: /data is 97% full on box-1"}, |
| {diskWhereDataInodes, true, "carlos alert: /data has used 97% of its inodes on box-1"}, |
| {diskWhereRun, true, "carlos alert: /run is 97% full on box-1"}, |
| + {diskWhereRunInodes, true, "carlos alert: /run has used 97% of its inodes on box-1"}, |
| + {diskWhereRunInodes, false, "carlos alert cleared: /run is back to 97% of its inodes used on box-1"}, |
| {diskWhereDataInodes, false, "carlos alert cleared: /data is back to 97% of its inodes used on box-1"}, |
| {diskWhereRun, false, "carlos alert cleared: /run is back to 97% full on box-1"}, |
| } { |
diff --git a/internal/metrics/alert.go b/internal/metrics/alert.go| index 7b2c389b7..c9077f902 100644 |
| --- a/internal/metrics/alert.go |
| +++ b/internal/metrics/alert.go |
| @@ -196,9 +196,9 @@ type Event struct { |
| Value float64 `json:"value"` |
| Box string `json:"box"` |
| // Where is what a disk event measured, when the box says ("/data", |
| - // "/data inodes", "/run"): a demo box's disk rule reads several |
| - // filesystems, and its message names the one it read. Evaluate never |
| - // sets it. |
| + // "/data inodes", "/run", "/run inodes"): a demo box's disk rule reads |
| + // several filesystems, and its message names the one it read. Evaluate |
| + // never sets it. |
| Where string `json:"where,omitempty"` |
| } |