hub (unreleased): the profile cell shows no count when the agent does not know it
gates / gates (push) Successful in 3m43s

Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
admin committed 2026-11-14 19:09:31 +01:00
1 parent f618c591eb
commit 78c08dc909
4 files changed
+21 -3

No files matched your search

@@ -102,3 +102,11 @@
review_fixes_test.go:29: unknown words must read as other / empty: Trust in Proxmox on h1: a cause this hub does not know (mode: <b>MODE</b> call +36…). The root CA copy ends in 3 day(s) (). Design: `03` §12a.{"ca_not_after":"","c
1 mutations, 0 not a red-proof
== MUTATION: an unknown count is shown as a count
RED on the mutant, GREEN on the real file
--- FAIL: TestSystemCells_KernelCleanupAndSecurityProfiles (0.00s)
system_b3_test.go:54: profile cell "7.0.14-28-pve · 0 rewritten · 18 h ago · restarted chrony.service" lacks "2 rewritten"
system_b3_test.go:63: last ask failed: {Text:7.0.14-28-pve · 0 rewritten · 18 h ago · last ask FAILED 1 h ago Class:warn Title:last ask: failed}, want amber, the failed ask AND the older record
system_b3_test.go:63: last ask no_answer: {Text:7.0.14-28-pve · 0 rewritten · 18 h ago · last ask NO_ANSWER 1 h ago Class:warn Title:last ask: no_answer}, want amber, the failed ask AND the older record
1 mutations, 0 not a red-proof
+1 -1
View File
@@ -139,7 +139,7 @@ type System struct {
type ProfileRefresh struct {
Kernel string `json:"kernel"`
At string `json:"at"`
Rewritten int `json:"rewritten"`
Rewritten *int `json:"rewritten"` // nil = the agent does not know it (it restarted since the refresh)
Restarted []string `json:"restarted"`
LastAsk string `json:"last_ask"` // refreshed | not_needed | failed | refused | no_answer
LastAskAt string `json:"last_ask_at"`
+5 -1
View File
@@ -157,7 +157,11 @@ func profileCell(f sysfacts.System, now time.Time) cell {
var parts []string
if p.At != "" {
at, _ := time.Parse(time.RFC3339, p.At)
parts = append(parts, strings.TrimSpace(p.Kernel+" · "+fmt.Sprintf("%d rewritten", p.Rewritten)+" · "+ago(at, now)))
line := p.Kernel
if p.Rewritten != nil {
line += fmt.Sprintf(" · %d rewritten", *p.Rewritten)
}
parts = append(parts, strings.TrimSpace(line+" · "+ago(at, now)))
if len(p.Restarted) > 0 {
parts = append(parts, "restarted "+strings.Join(p.Restarted, ", "))
}
+7 -1
View File
@@ -63,6 +63,11 @@ func TestSystemCells_KernelCleanupAndSecurityProfiles(t *testing.T) {
t.Errorf("last ask %s: %+v, want amber, the failed ask AND the older record", ask, c)
}
}
// after an agent restart the count is not known: no „0 rewritten”
f = sysfacts.Parse(`{"profile_refresh":{"kernel":"7.0.14-28-pve","at":"2026-11-14T11:30:11Z","last_ask":"not_needed","last_ask_at":"2026-11-15T05:00:00Z"}}`)
if c := profileCell(f, now); strings.Contains(c.Text, "rewritten") || !strings.Contains(c.Text, "7.0.14-28-pve") || c.Class != "" {
t.Errorf("a refresh whose count is not known: %+v — want the kernel and the time, no count", c)
}
f = sysfacts.Parse(`{"profile_refresh":{"last_ask":"refused","last_ask_at":"2026-11-15T05:00:00Z"}}`)
if c := profileCell(f, now); c.Class != "" || c.Text != "no refresh yet" || !strings.Contains(c.Title, "older root wrapper") {
t.Errorf("a refused ask (an older wrapper) is not a fault: %+v", c)
@@ -76,7 +81,8 @@ func TestSystemPage_ShowsCleanupAndProfiles(t *testing.T) {
in.KernelLines = map[string]osupdates.KernelLine{"demo-hp-d4e5f6": {CleanupOutcome: "cleaned", CleanupAt: in.Now.Add(-2 * time.Hour),
Cleanup: &osupdates.CleanupDetail{Removed: []string{"proxmox-kernel-7.0.14-20-pve-signed"}, Kept: []string{"7.0.14-23-pve"}, BytesGained: &gained}}}
f := in.Facts["demo-hp-d4e5f6"]
f.ProfileRefresh = &sysfacts.ProfileRefresh{Kernel: "7.0.14-23-pve", At: in.Now.Add(-5 * time.Hour).UTC().Format(time.RFC3339), Rewritten: 1,
one := 1
f.ProfileRefresh = &sysfacts.ProfileRefresh{Kernel: "7.0.14-23-pve", At: in.Now.Add(-5 * time.Hour).UTC().Format(time.RFC3339), Rewritten: &one,
Restarted: []string{"chrony.service"}, LastAsk: "failed", LastAskAt: in.Now.Add(-time.Hour).UTC().Format(time.RFC3339)}
in.Facts["demo-hp-d4e5f6"] = f
page := renderSystem(t, in)