hub (unreleased): the System page shows the kernel clean-up and the security-profile refresh; a clean-up no longer hides a kernel step (R-1383)
gates / gates (push) Successful in 2m20s
gates / gates (push) Successful in 2m20s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
e5c643d73d
commit
68292e40f6
14 files changed
+452
-13
No files matched your search
@@ -3,6 +3,16 @@
|
||||
- `bundlefiles`: the line „bundle X holds the same files as the vouched Y” is logged once per pair (INFO), not at
|
||||
every view of the System page (it was 6 DEBUG lines per view, seen at the 0.181.0 deploy). No behaviour change.
|
||||
- **Release 3 („the hub tells you”), built 2026-11-14 night, NOT deployed. Every new alarm is operator-only.**
|
||||
- **The System page shows the kernel clean-up and the security-profile refresh (R-1383; `11` §5.11.1, §5.12).**
|
||||
Two new cells per box. „Kernel clean-up”: from the clean-up report's new `kernel_cleanup` object (kept in the stored
|
||||
report: `osupdates.Report.KernelCleanup`) — removed, kept, space gained, the names in the title; amber on
|
||||
refused / failed / left-over paths. „Security profiles”: from the host report's new `profile_refresh` stanza
|
||||
(`sysfacts.ProfileRefresh`) — kernel, how many profiles changed, any failed service it restarted; amber when the
|
||||
agent's last ask failed. **A defect fixed on the way:** the „Kernel step” cell showed the newest kernel-layer report,
|
||||
so a clean-up hid a kernel that fell back the night before; `KernelLineFor` now reads the newest step and the newest
|
||||
clean-up each from its own report. No new table, no new event. Tests `TestKernelLine_CleanupBesideTheStep`,
|
||||
`TestSystemCells_KernelCleanupAndSecurityProfiles`, `TestSystemPage_ShowsCleanupAndProfiles`; 13 mutations seen red
|
||||
(one did not run at first and was done again).
|
||||
- **The record of an off-site account outlives an untick (R-1375 part 1, D71, `09` §3 decision 291; `05` §14.1).**
|
||||
The config form rebuilds the whole config at a save, so unticking the off-site tier dropped the `offsite` block and
|
||||
the hub forgot the account; a later RESET or delete skipped it. Now `offsite.KeepAccountRecord` leaves
|
||||
|
||||
@@ -480,6 +480,12 @@ type KernelLine struct {
|
||||
NoticeAt time.Time // the newest day-before mail (any kernel)
|
||||
NoticeKver string
|
||||
Tonight bool
|
||||
// The newest clean-up of old kernels (R-1383, release 3), kept APART from the step: both are kernel-layer
|
||||
// reports, and before this the newest of the two was shown as „the step” — a clean-up hid a kernel that fell back.
|
||||
CleanupOutcome string // cleaned | refused | failed; "" = none reported
|
||||
CleanupAt time.Time
|
||||
CleanupReason string
|
||||
Cleanup *CleanupDetail // nil = an agent older than release 3 (the reason text carries the names)
|
||||
}
|
||||
|
||||
// KernelLineFor reads one box's kernel line.
|
||||
@@ -489,12 +495,33 @@ func (s *Service) KernelLineFor(hostID string) KernelLine {
|
||||
if b := s.KernelBlockFor(hostID); b != nil {
|
||||
l.Tonight = b.Tonight
|
||||
}
|
||||
if rep, _ := s.Store.LatestOSReport(hostID, LayerKernel); rep != nil {
|
||||
// The newest STEP and the newest CLEAN-UP, each from its own report (newest first; 100 covers months).
|
||||
reps, _ := s.Store.OSReportsDesc(hostID, LayerKernel, 100)
|
||||
haveStep, haveCleanup := false, false
|
||||
for _, rep := range reps {
|
||||
if haveStep && haveCleanup {
|
||||
break
|
||||
}
|
||||
var kr Report
|
||||
_ = json.Unmarshal([]byte(rep.ReportJSON), &kr)
|
||||
l.LastOutcome, l.LastKernel, l.LastAt, l.LastReason = rep.Outcome, kernelOf(kr), rep.ReceivedAt, kr.HealthReason
|
||||
if l.LastReason == "" && len(kr.Refused) > 0 {
|
||||
l.LastReason = string(kr.Refused)
|
||||
reason := kr.HealthReason
|
||||
if reason == "" && len(kr.Refused) > 0 {
|
||||
reason = string(kr.Refused)
|
||||
}
|
||||
if rep.Mode == ModeKernelCleanup {
|
||||
if !haveCleanup {
|
||||
haveCleanup = true
|
||||
l.CleanupOutcome, l.CleanupAt, l.CleanupReason = rep.Outcome, rep.ReceivedAt, reason
|
||||
var d CleanupDetail
|
||||
if len(kr.KernelCleanup) > 0 && json.Unmarshal(kr.KernelCleanup, &d) == nil {
|
||||
l.Cleanup = &d
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !haveStep {
|
||||
haveStep = true
|
||||
l.LastOutcome, l.LastKernel, l.LastAt, l.LastReason = rep.Outcome, kernelOf(kr), rep.ReceivedAt, reason
|
||||
}
|
||||
}
|
||||
if n, _ := s.Store.LatestKernelNotice(hostID); n != nil {
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package osupdates
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func cleanupReport(detail string) Report {
|
||||
r := Report{Layer: LayerKernel, Trigger: "night", Mode: ModeKernelCleanup, Outcome: "cleaned", Healthy: true,
|
||||
ReleaseID: "kernel-cleanup", HealthReason: "removed 2 old kernel package(s): …"}
|
||||
if detail != "" {
|
||||
r.KernelCleanup = json.RawMessage(detail)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// R-1383 (release 3). A clean-up and a kernel step are both kernel-layer reports. Before this the System page showed
|
||||
// the NEWEST of the two as „the step”: a clean-up the night after a kernel fell back replaced the amber „fell_back”
|
||||
// line with „cleaned”. The stored effect asserted: the step line still reads the step; the clean-up has its own
|
||||
// fields with what it removed, kept and gained; the detail survives the hub's re-marshal of the report; and the
|
||||
// clean-up changes nothing the kernel lane decides on (it names no kernel).
|
||||
// COMPANION RED-PROOFS (observed, audits/night-build-2026-11-14/B/redproof-hub-b3.txt).
|
||||
func TestKernelLine_CleanupBesideTheStep(t *testing.T) {
|
||||
f := newFix(t)
|
||||
f.hostWithPendingKernel(t, "hp")
|
||||
f.laneFacts(t, "hp", "c-hp", kOld, "fell_back", kNew)
|
||||
f.ingest(t, "hp", kreport("fell_back", "boot", false))
|
||||
dueBefore, whyBefore := f.s.KernelDue("hp")
|
||||
if l := f.s.KernelLineFor("hp"); l.CleanupOutcome != "" || l.LastOutcome != "fell_back" {
|
||||
t.Fatalf("before any clean-up: %+v", l)
|
||||
}
|
||||
const detail = `{"removed":["proxmox-kernel-7.0.14-20-pve-signed","proxmox-kernel-7.0.2-6-pve-signed"],"kept":["7.0.14-22-pve","7.0.14-26-pve"],"bytes_gained":2147483648,"leftovers":0}`
|
||||
f.now = f.now.Add(24 * 60 * 60 * 1e9)
|
||||
rep := cleanupReport(detail)
|
||||
rep.RunID = "cleanup-1"
|
||||
f.ingest(t, "hp", rep)
|
||||
|
||||
l := f.s.KernelLineFor("hp")
|
||||
if l.LastOutcome != "fell_back" || l.LastKernel != kNew {
|
||||
t.Fatalf("the clean-up HID the step: the step line reads %q for %q, want fell_back for %s", l.LastOutcome, l.LastKernel, kNew)
|
||||
}
|
||||
if l.CleanupOutcome != "cleaned" || l.Cleanup == nil || len(l.Cleanup.Removed) != 2 || len(l.Cleanup.Kept) != 2 ||
|
||||
l.Cleanup.BytesGained == nil || *l.Cleanup.BytesGained != 2147483648 || l.Cleanup.Removed[0] != "proxmox-kernel-7.0.14-20-pve-signed" {
|
||||
t.Fatalf("the clean-up's own fields: outcome %q detail %+v", l.CleanupOutcome, l.Cleanup)
|
||||
}
|
||||
// the detail is in the STORED report (Ingest re-marshals the struct: a field the struct lacks is lost)
|
||||
stored, _ := f.s.Store.LatestOSReport("hp", LayerKernel)
|
||||
if stored == nil || stored.Mode != ModeKernelCleanup || !strings.Contains(stored.ReportJSON, `"kernel_cleanup":{"removed":["proxmox-kernel-7.0.14-20-pve-signed"`) {
|
||||
t.Fatalf("the stored report lost the detail: %+v", stored)
|
||||
}
|
||||
// and it is not a step for any kernel: the lane's verdict did not move
|
||||
var kr Report
|
||||
_ = json.Unmarshal([]byte(stored.ReportJSON), &kr)
|
||||
if k := kernelOf(kr); k != "" {
|
||||
t.Fatalf("the clean-up report reads as a step for kernel %q", k)
|
||||
}
|
||||
if due, why := f.s.KernelDue("hp"); due != dueBefore || why != whyBefore {
|
||||
t.Fatalf("the clean-up moved the kernel lane: due %q→%q, why %q→%q", dueBefore, due, whyBefore, why)
|
||||
}
|
||||
// a later step is the step line again, and the clean-up line stays
|
||||
f.now = f.now.Add(24 * 60 * 60 * 1e9)
|
||||
st := kreport("applied", "boot", true)
|
||||
st.RunID = "step-2"
|
||||
f.ingest(t, "hp", st)
|
||||
if l := f.s.KernelLineFor("hp"); l.LastOutcome != "applied" || l.CleanupOutcome != "cleaned" || l.Cleanup == nil {
|
||||
t.Fatalf("after a later step: %+v", l)
|
||||
}
|
||||
// an agent of release 2a sends no detail: the outcome and the reason text are still shown, the detail is nil
|
||||
f2 := newFix(t)
|
||||
old := cleanupReport("")
|
||||
old.RunID = "cleanup-old"
|
||||
f2.ingest(t, "hp", old)
|
||||
if l := f2.s.KernelLineFor("hp"); l.CleanupOutcome != "cleaned" || l.Cleanup != nil || !strings.Contains(l.CleanupReason, "removed 2 old kernel") || l.LastOutcome != "" {
|
||||
t.Fatalf("a clean-up without detail (agent 0.174.0): %+v", l)
|
||||
}
|
||||
}
|
||||
@@ -119,8 +119,23 @@ type Report struct {
|
||||
OOMCheck json.RawMessage `json:"oom_check,omitempty"`
|
||||
// Kernel (agent v0.152.0, R-836): the kernel layer's view {running, default, flag, phase, from, to, …}, kept verbatim.
|
||||
Kernel json.RawMessage `json:"kernel,omitempty"`
|
||||
// KernelCleanup (agents of release 3, R-1383): ONLY on a mode kernel-cleanup report — what the clean-up removed,
|
||||
// kept and gained. Kept verbatim (Ingest re-marshals this struct: a field that is not here is lost). It is NOT read
|
||||
// by kernelOf: a clean-up is not a step for any kernel. Pinned by TestKernelLine_CleanupBesideTheStep.
|
||||
KernelCleanup json.RawMessage `json:"kernel_cleanup,omitempty"`
|
||||
}
|
||||
|
||||
// CleanupDetail is the clean-up's result (felhom-agent osupdate.CleanupDetail, field-exact).
|
||||
type CleanupDetail struct {
|
||||
Removed []string `json:"removed"`
|
||||
Kept []string `json:"kept"`
|
||||
BytesGained *int64 `json:"bytes_gained"`
|
||||
Leftovers int `json:"leftovers"`
|
||||
}
|
||||
|
||||
// ModeKernelCleanup is the mode of the kernel-layer report that is NOT a kernel step.
|
||||
const ModeKernelCleanup = "kernel-cleanup"
|
||||
|
||||
// PendingPkg is one update the sources offer.
|
||||
type PendingPkg struct {
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -129,11 +129,26 @@ type System struct {
|
||||
DiskTrim *DiskTrim
|
||||
// LineTest is the top-level `line_test` stanza (R-1247), read like DiskTrim. nil = the agent sent none.
|
||||
LineTest *LineTest
|
||||
// ProfileRefresh is the top-level `profile_refresh` stanza (R-1383, agents of release 3), read like DiskTrim.
|
||||
// nil = the agent sent none (an older agent, a BYO host, or a box that never refreshed).
|
||||
ProfileRefresh *ProfileRefresh
|
||||
}
|
||||
|
||||
// ProfileRefresh is the box's last security-profile refresh (`11` §5.12; felhom-agent osupdate.ProfileRefreshStatus,
|
||||
// field-exact): from the root wrapper's own record, plus how the agent's last ask ended.
|
||||
type ProfileRefresh struct {
|
||||
Kernel string `json:"kernel"`
|
||||
At string `json:"at"`
|
||||
Rewritten int `json:"rewritten"`
|
||||
Restarted []string `json:"restarted"`
|
||||
LastAsk string `json:"last_ask"` // refreshed | not_needed | failed | refused | no_answer
|
||||
LastAskAt string `json:"last_ask_at"`
|
||||
}
|
||||
|
||||
type wire struct {
|
||||
DiskTrim *DiskTrim `json:"guest_disk_trim"`
|
||||
LineTest *LineTest `json:"line_test"`
|
||||
DiskTrim *DiskTrim `json:"guest_disk_trim"`
|
||||
LineTest *LineTest `json:"line_test"`
|
||||
Profile *ProfileRefresh `json:"profile_refresh"`
|
||||
System *struct {
|
||||
PVEVersion string `json:"pve_version"`
|
||||
KernelVersion string `json:"kernel_version"`
|
||||
@@ -162,6 +177,7 @@ func Parse(reportJSON string) System {
|
||||
return out
|
||||
}
|
||||
out.DiskTrim, out.LineTest = w.DiskTrim, w.LineTest
|
||||
out.ProfileRefresh = w.Profile
|
||||
if w.System == nil {
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type systemRow struct {
|
||||
Held, RebootSince, KernelPanic, Oops cell
|
||||
CrashRestarts24h, Guard cell
|
||||
KernelDefault, KernelStep cell // R-836: the GRUB default kernel; the kernel lane's step
|
||||
KernelCleanup, Profiles cell // R-1383: the clean-up of old kernels; the security-profile refresh
|
||||
Bundle cell // R-840: the root-owned config bundle
|
||||
Agent cell // R-530: the box's agent against the vouched one
|
||||
// guest
|
||||
@@ -115,6 +116,71 @@ func kernelCells(f sysfacts.System, kl osupdates.KernelLine, now time.Time) (dfl
|
||||
return dflt, step
|
||||
}
|
||||
|
||||
// cleanupCell is the System page's „Kernel clean-up” cell (R-1383, release 3; `11` §5.11.1): the newest clean-up of
|
||||
// old kernels — how many it removed and kept and how much space it gained, the names in the title. Amber when it was
|
||||
// refused or failed, or left paths of a removed kernel behind. A box tells the hub only when a clean-up removed
|
||||
// something, was refused, or failed — so „—” is the normal reading for a box with nothing to remove.
|
||||
func cleanupCell(kl osupdates.KernelLine, now time.Time) cell {
|
||||
if kl.CleanupOutcome == "" {
|
||||
return cell{Text: "—", Title: "no clean-up of old kernels reported (a box reports one only when it removed kernels, was refused, or failed)"}
|
||||
}
|
||||
when := ago(kl.CleanupAt, now)
|
||||
switch kl.CleanupOutcome {
|
||||
case "cleaned":
|
||||
d := kl.Cleanup
|
||||
if d == nil {
|
||||
return cell{Text: "cleaned " + when, Title: kl.CleanupReason}
|
||||
}
|
||||
gained := "space gained unknown"
|
||||
if d.BytesGained != nil {
|
||||
gained = fmt.Sprintf("%.1f GiB gained", float64(*d.BytesGained)/(1<<30))
|
||||
}
|
||||
c := cell{Text: fmt.Sprintf("removed %d, kept %d · %s · %s", len(d.Removed), len(d.Kept), gained, when),
|
||||
Title: "removed: " + strings.Join(d.Removed, ", ") + " — kept: " + strings.Join(d.Kept, ", ")}
|
||||
if d.Leftovers > 0 {
|
||||
c.Class = "warn"
|
||||
c.Text += fmt.Sprintf(" · %d left-over path(s)", d.Leftovers)
|
||||
}
|
||||
return c
|
||||
}
|
||||
return cell{Text: kl.CleanupOutcome + " " + when, Class: "warn", Title: kl.CleanupReason}
|
||||
}
|
||||
|
||||
// profileCell is the „Security profiles” cell (R-1383, release 3; `11` §5.12): the box's last refresh of its compiled
|
||||
// AppArmor profiles — the kernel it ran on, how many compiled profiles changed, and any FAILED service it restarted
|
||||
// (on the N100 that was the time service). Amber when the agent's last ask failed or got no answer.
|
||||
func profileCell(f sysfacts.System, now time.Time) cell {
|
||||
p := f.ProfileRefresh
|
||||
if p == nil {
|
||||
return cell{Text: "—", Title: "the box reports no security-profile refresh (an agent older than release 3, a BYO host, or no refresh yet)"}
|
||||
}
|
||||
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)))
|
||||
if len(p.Restarted) > 0 {
|
||||
parts = append(parts, "restarted "+strings.Join(p.Restarted, ", "))
|
||||
}
|
||||
}
|
||||
c := cell{Title: "last ask: " + p.LastAsk}
|
||||
if p.LastAsk == "" {
|
||||
c.Title = "from the box's own record (the agent has not asked since it started)"
|
||||
}
|
||||
switch p.LastAsk {
|
||||
case "failed", "no_answer":
|
||||
askAt, _ := time.Parse(time.RFC3339, p.LastAskAt)
|
||||
parts = append(parts, "last ask "+strings.ToUpper(p.LastAsk)+" "+ago(askAt, now))
|
||||
c.Class = "warn"
|
||||
case "refused":
|
||||
c.Title = "last ask: refused (an older root wrapper that does not know the mode, or a BYO host)"
|
||||
}
|
||||
if len(parts) == 0 {
|
||||
parts = append(parts, "no refresh yet")
|
||||
}
|
||||
c.Text = strings.Join(parts, " · ")
|
||||
return c
|
||||
}
|
||||
|
||||
// agentCell is the "Agent" cell (R-530, hub v0.135.0): the box's agent against the vouched one, how far behind and
|
||||
// since when. Amber while behind; red from the alarm's wait on (the operator alarm fires then). An unreadable
|
||||
// version is "unknown", never a guess; nothing vouched → the version alone.
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/osupdates"
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/sysfacts"
|
||||
)
|
||||
|
||||
// R-1383 (release 3): the two new cells of the System page, from what a box really sends.
|
||||
// COMPANION RED-PROOFS (observed, audits/night-build-2026-11-14/B/redproof-hub-b3.txt).
|
||||
func TestSystemCells_KernelCleanupAndSecurityProfiles(t *testing.T) {
|
||||
now := time.Date(2026, 11, 15, 6, 0, 0, 0, time.UTC)
|
||||
gained := int64(6442450944)
|
||||
// --- the clean-up ---
|
||||
if c := cleanupCell(osupdates.KernelLine{}, now); c.Text != "—" || c.Class != "" {
|
||||
t.Errorf("no clean-up reported: %+v (a box with nothing to remove reports none — not a fault)", c)
|
||||
}
|
||||
kl := osupdates.KernelLine{CleanupOutcome: "cleaned", CleanupAt: now.Add(-3 * time.Hour), CleanupReason: "removed 6 …",
|
||||
Cleanup: &osupdates.CleanupDetail{Removed: []string{"proxmox-kernel-7.0.2-6-pve-signed", "b", "c", "d", "e", "f"},
|
||||
Kept: []string{"7.0.14-26-pve", "7.0.14-28-pve"}, BytesGained: &gained}}
|
||||
c := cleanupCell(kl, now)
|
||||
for _, want := range []string{"removed 6, kept 2", "6.0 GiB gained", "3"} {
|
||||
if !strings.Contains(c.Text, want) {
|
||||
t.Errorf("clean-up cell %q lacks %q", c.Text, want)
|
||||
}
|
||||
}
|
||||
if c.Class != "" || !strings.Contains(c.Title, "proxmox-kernel-7.0.2-6-pve-signed") || !strings.Contains(c.Title, "kept: 7.0.14-26-pve, 7.0.14-28-pve") {
|
||||
t.Errorf("clean-up cell = %+v, want no colour and the names in the title", c)
|
||||
}
|
||||
kl.Cleanup.Leftovers = 2
|
||||
if c := cleanupCell(kl, now); c.Class != "warn" || !strings.Contains(c.Text, "2 left-over path(s)") {
|
||||
t.Errorf("left-over paths must be amber and named: %+v", c)
|
||||
}
|
||||
kl.Cleanup = nil // an agent of release 2a
|
||||
if c := cleanupCell(kl, now); !strings.HasPrefix(c.Text, "cleaned ") || c.Title != "removed 6 …" {
|
||||
t.Errorf("a clean-up without detail: %+v", c)
|
||||
}
|
||||
for _, bad := range []string{"refused", "failed"} {
|
||||
if c := cleanupCell(osupdates.KernelLine{CleanupOutcome: bad, CleanupAt: now.Add(-time.Hour), CleanupReason: "K4: the phase is judging"}, now); c.Class != "warn" || !strings.HasPrefix(c.Text, bad) || c.Title != "K4: the phase is judging" {
|
||||
t.Errorf("%s clean-up: %+v, want amber with the reason", bad, c)
|
||||
}
|
||||
}
|
||||
// --- the security profiles: parsed from a host report, as the page gets it ---
|
||||
if c := profileCell(sysfacts.Parse(`{"host_id":"x"}`), now); c.Text != "—" || c.Class != "" {
|
||||
t.Errorf("no stanza: %+v", c)
|
||||
}
|
||||
f := sysfacts.Parse(`{"profile_refresh":{"kernel":"7.0.14-28-pve","at":"2026-11-14T11:30:11Z","rewritten":2,"restarted":["chrony.service"],"last_ask":"refreshed","last_ask_at":"2026-11-14T11:30:11Z"}}`)
|
||||
c = profileCell(f, now)
|
||||
for _, want := range []string{"7.0.14-28-pve", "2 rewritten", "restarted chrony.service"} {
|
||||
if !strings.Contains(c.Text, want) {
|
||||
t.Errorf("profile cell %q lacks %q", c.Text, want)
|
||||
}
|
||||
}
|
||||
if c.Class != "" {
|
||||
t.Errorf("a good refresh must have no colour: %+v", c)
|
||||
}
|
||||
for _, ask := range []string{"failed", "no_answer"} {
|
||||
f = sysfacts.Parse(`{"profile_refresh":{"kernel":"7.0.14-28-pve","at":"2026-11-14T11:30:11Z","rewritten":2,"last_ask":"` + ask + `","last_ask_at":"2026-11-15T05:00:00Z"}}`)
|
||||
if c := profileCell(f, now); c.Class != "warn" || !strings.Contains(c.Text, "last ask "+strings.ToUpper(ask)) || !strings.Contains(c.Text, "2 rewritten") {
|
||||
t.Errorf("last ask %s: %+v, want amber, the failed ask AND the older record", ask, 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)
|
||||
}
|
||||
}
|
||||
|
||||
// Both cells are on the rendered page, under their names, and a failed ask reaches „Needs attention”.
|
||||
func TestSystemPage_ShowsCleanupAndProfiles(t *testing.T) {
|
||||
in := fixtureInput(true)
|
||||
gained := int64(1073741824)
|
||||
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,
|
||||
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)
|
||||
for _, want := range []string{">Kernel clean-up</dt>", ">Security profiles</dt>", "removed 1, kept 1", "1.0 GiB gained",
|
||||
"restarted chrony.service", "last ask FAILED"} {
|
||||
if !strings.Contains(page, want) {
|
||||
t.Errorf("the System page lacks %q", want)
|
||||
}
|
||||
}
|
||||
if att := sysSection(page, "attention"); !strings.Contains(att, "security profiles") {
|
||||
t.Errorf("a failed ask of the profile refresh is not under „Needs attention”")
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func TestSystemPage_EveryItemStillOnThePage(t *testing.T) {
|
||||
// per box, in the box panel (every column of the old wide table)
|
||||
`href="/hosts/demo-hp-d4e5f6"`, "Demo HP", `action="/os/ring/demo-hp-d4e5f6"`, `action="/os/enabled/tester1-0f1e2d"`,
|
||||
">Tunnel</dt>", ">Proxmox</dt>", ">Kernel (running)</dt>", ">Kernel (next boot)</dt>", ">Kernel (default)</dt>",
|
||||
">Kernel step</dt>", ">Debian</dt>", ">Felhom release</dt>", ">Pending</dt>", ">Not covered</dt>", ">Held</dt>",
|
||||
">Kernel step</dt>", ">Kernel clean-up</dt>", ">Security profiles</dt>", ">Debian</dt>", ">Felhom release</dt>", ">Pending</dt>", ">Not covered</dt>", ">Held</dt>",
|
||||
">Reboot needed</dt>", ">kernel.panic</dt>", ">Oops</dt>", ">Crash restarts 24 h</dt>", ">Crash guard</dt>",
|
||||
">Root files</dt>", ">Agent</dt>", ">Guest Debian</dt>", ">Restart needed</dt>", ">Last disk trim</dt>",
|
||||
">Docker</dt>", ">containerd</dt>", ">live-restore</dt>", ">Docker release</dt>", ">Last OS leg</dt>",
|
||||
|
||||
@@ -52,6 +52,7 @@ func buildSystemPage(in systemInput) map[string]interface{} {
|
||||
for i := range rows {
|
||||
id := rows[i].HostID
|
||||
rows[i].KernelDefault, rows[i].KernelStep = kernelCells(in.Facts[id], in.KernelLines[id], in.Now)
|
||||
rows[i].KernelCleanup, rows[i].Profiles = cleanupCell(in.KernelLines[id], in.Now), profileCell(in.Facts[id], in.Now)
|
||||
rows[i].Bundle = bundleCell(in.Facts[id], in.VouchedAgent, in.VouchedBundle, in.BundleSame[id], in.BundleSince[id], in.BundleAfter, in.Now)
|
||||
rows[i].Agent = agentCell(in.Agents[id], in.VouchedAgent, in.AgentSince[id], in.AgentAfter, in.Now)
|
||||
rows[i].Controller = unknownCell(in.Controllers[id])
|
||||
@@ -94,7 +95,8 @@ func (r *systemRow) labelled() []struct {
|
||||
}
|
||||
return []lc{
|
||||
{"tunnel", r.Tunnel}, {"Proxmox version", r.PVE}, {"running kernel", r.KernelRunning}, {"next-boot kernel", r.KernelNextBoot},
|
||||
{"default kernel", r.KernelDefault}, {"kernel step", r.KernelStep}, {"host Debian", r.HostDebian},
|
||||
{"default kernel", r.KernelDefault}, {"kernel step", r.KernelStep}, {"kernel clean-up", r.KernelCleanup},
|
||||
{"security profiles", r.Profiles}, {"host Debian", r.HostDebian},
|
||||
{"host updates not covered", r.HostNotCovered}, {"held packages", r.Held}, {"host restart", r.RebootSince},
|
||||
{"kernel.panic", r.KernelPanic}, {"kernel oops", r.Oops}, {"crash restarts", r.CrashRestarts24h}, {"crash guard", r.Guard},
|
||||
{"root files", r.Bundle}, {"agent", r.Agent}, {"controller", r.Controller}, {"guest Debian", r.GuestDebian},
|
||||
|
||||
@@ -185,6 +185,8 @@
|
||||
<dt>Kernel (next boot)</dt>{{template "sys_dd" .KernelNextBoot}}
|
||||
<dt title="The kernel GRUB boots normally (R-836). Amber: a one-shot flag names another kernel for the next boot only.">Kernel (default)</dt>{{template "sys_dd" .KernelDefault}}
|
||||
<dt title="The kernel lane (R-836): the newest step, the kernel the box is due, and whether its household was told for tonight (no mail, no step).">Kernel step</dt>{{template "sys_dd" .KernelStep}}
|
||||
<dt title="The newest clean-up of old kernels (R-1368): how many it removed and kept, and the space gained. A box reports one only when it removed kernels, was refused, or failed.">Kernel clean-up</dt>{{template "sys_dd" .KernelCleanup}}
|
||||
<dt title="The box's last refresh of its compiled security (AppArmor) profiles (R-1388): the kernel it ran on, how many changed, and a failed service it restarted.">Security profiles</dt>{{template "sys_dd" .Profiles}}
|
||||
<dt>Debian</dt>{{template "sys_dd" .HostDebian}}
|
||||
<dt>Felhom release</dt>{{template "sys_dd" .HostRelease}}
|
||||
<dt>Pending</dt>{{template "sys_dd" .HostPending}}
|
||||
|
||||
Reference in new issue
Block a user