hub v0.140.0: a failed operator mail is retried (1, 5, 15 min); a Docker set needs a passing memory-kill check on every ring-0 box (decision 157)
gates / gates (push) Successful in 2m40s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-06 19:14:00 +02:00
1 parent 2441c86a89
commit eed1dbd80c
8 files changed
+298 -17

No files matched your search

+77 -2
View File
@@ -1,6 +1,7 @@
package osupdates
import (
"encoding/json"
"strings"
"testing"
"time"
@@ -10,13 +11,23 @@ var engineSet = []Package{{Name: "docker-ce", Version: "5:29.8.2-1~debian.13~tri
{Name: "containerd.io", Version: "2.3.6-1~debian.13~trixie", Origin: "Docker"}}
func (f *fix) dockerNight(t *testing.T, host string, healthy bool) {
t.Helper()
f.dockerNightOOM(t, host, healthy, `{"result":"pass","oom_killed":true,"oom_event":true,"exit_code":137,"image":"felhom-controller","detail":""}`)
}
// dockerNightOOM is dockerNight with the step's memory-kill check as given ("" = an agent that reports none).
func (f *fix) dockerNightOOM(t *testing.T, host string, healthy bool, oom string) {
t.Helper()
out := "nothing"
if !healthy {
out = "health_failed"
}
f.ingest(t, host, Report{Layer: LayerDocker, Trigger: "night", Mode: "apply", Outcome: out, Healthy: healthy,
Installed: append([]Package{pk("libc6", "x")}, engineSet...)})
r := Report{Layer: LayerDocker, Trigger: "night", Mode: "apply", Outcome: out, Healthy: healthy,
Installed: append([]Package{pk("libc6", "x")}, engineSet...)}
if oom != "" {
r.OOMCheck = json.RawMessage(oom)
}
f.ingest(t, host, r)
}
// The Docker set is NEVER approved automatically (`11` §5.8: the operator approves it). Red-proof: add LayerDocker to
@@ -77,3 +88,67 @@ func TestDocker_UnhealthyStepBlocksTheButton(t *testing.T) {
t.Fatalf("an unhealthy Docker step did not block: %v", err)
}
}
// Decision 157 (R-528): the Docker set is approved only when every ring-0 box's step showed the engine reports a
// memory kill. RED-PROOF (REPORT): make oomCheckWaiting return "" — the three blocking tests below approve.
func TestDockerApproval_AFailedMemoryKillCheckBlocks(t *testing.T) {
f := newFix(t)
fail := `{"result":"fail","oom_killed":false,"oom_event":true,"exit_code":137,"image":"felhom-controller","detail":"OOMKilled=false"}`
for i := 0; i < 2; i++ {
f.dockerNight(t, "hp", true)
f.dockerNightOOM(t, "n100", true, fail)
if i == 0 {
f.s.Evaluate() // stamps the set\'s first-seen at the first night, as the tick does
}
f.now = f.now.Add(24 * time.Hour)
}
if _, err := f.s.ApproveDocker(); err == nil || !strings.Contains(err.Error(), "memory-kill check did not pass") {
t.Fatalf("a set whose engine missed a memory kill was approvable: %v", err)
}
}
func TestDockerApproval_AMissingMemoryKillCheckBlocks(t *testing.T) {
f := newFix(t)
for i := 0; i < 2; i++ {
f.dockerNight(t, "hp", true)
f.dockerNightOOM(t, "n100", true, "") // an older agent: no check at all
if i == 0 {
f.s.Evaluate() // stamps the set\'s first-seen at the first night, as the tick does
}
f.now = f.now.Add(24 * time.Hour)
}
if _, err := f.s.ApproveDocker(); err == nil || !strings.Contains(err.Error(), "has not reported the Docker step's memory-kill check") {
t.Fatalf("a set with no memory-kill check was approvable: %v", err)
}
}
func TestDockerApproval_AnErroredMemoryKillCheckBlocks(t *testing.T) {
f := newFix(t)
errd := `{"result":"error","oom_killed":false,"oom_event":false,"exit_code":null,"image":null,"detail":"the controller's image could not be read"}`
for i := 0; i < 2; i++ {
f.dockerNight(t, "hp", true)
f.dockerNightOOM(t, "n100", true, errd)
if i == 0 {
f.s.Evaluate() // stamps the set\'s first-seen at the first night, as the tick does
}
f.now = f.now.Add(24 * time.Hour)
}
if _, err := f.s.ApproveDocker(); err == nil {
t.Fatal("a set whose memory-kill check errored was approvable")
}
}
func TestDockerApproval_APassingCheckOnEveryBoxAllows(t *testing.T) {
f := newFix(t)
for i := 0; i < 2; i++ {
f.dockerNight(t, "hp", true)
f.dockerNight(t, "n100", true)
if i == 0 {
f.s.Evaluate() // stamps the set\'s first-seen at the first night, as the tick does
}
f.now = f.now.Add(24 * time.Hour)
}
if _, err := f.s.ApproveDocker(); err != nil {
t.Fatalf("passing checks on every ring-0 box should allow the approval: %v", err)
}
}
+39
View File
@@ -111,6 +111,9 @@ type Report struct {
DockerEngine string `json:"docker_engine,omitempty"` // docker layer (agent v0.142.0)
Authority string `json:"authority,omitempty"` // docker layer: ring0 | signed
Undo bool `json:"undo,omitempty"` // docker layer: a signed undo
// OOMCheck (agent v0.150.0, decision 157): the Docker step's memory-kill check, kept verbatim — oomCheckWaiting
// reads it from the stored report.
OOMCheck json.RawMessage `json:"oom_check,omitempty"`
}
// PendingPkg is one update the sources offer.
@@ -599,10 +602,46 @@ func (s *Service) DockerStatus() (Status, error) {
st.Waiting = fmt.Sprintf("%s has %d of %d healthy night Docker step(s) with this set", h, nights, need)
return st, nil
}
if why := oomCheckWaiting(h, reps); why != "" {
st.Waiting = why
return st, nil
}
}
return st, nil
}
// oomCheckWaiting is `09` §3 decision 157 (R-528): a Docker engine set is approved only when every ring-0 box showed,
// after its Docker step with this set, that the engine reports a memory kill correctly — the wrapper's `oom_check`
// (agent v0.150.0: a throwaway container under a 64 MB cap killed for memory; pass = `OOMKilled=true` AND the `oom`
// event). A failed or errored check on ANY report of the set blocks; no passing check at all blocks („missing").
// Returns "" when the box is clear. Pinned by TestDockerApproval_*.
func oomCheckWaiting(host string, reps []store.OSReport) string {
passed := false
for _, r := range reps {
var body struct {
OOMCheck *struct {
Result string `json:"result"`
Detail string `json:"detail"`
} `json:"oom_check"`
}
if json.Unmarshal([]byte(r.ReportJSON), &body) != nil || body.OOMCheck == nil {
continue
}
switch body.OOMCheck.Result {
case "pass":
passed = true
default:
return fmt.Sprintf("%s: the Docker step's memory-kill check did not pass (%s: %s) at %s — a set whose engine "+
"may miss a memory kill is not approved (decision 157)", host, body.OOMCheck.Result, body.OOMCheck.Detail,
r.ReceivedAt.UTC().Format(time.RFC3339))
}
}
if !passed {
return fmt.Sprintf("%s has not reported the Docker step's memory-kill check with this set (agent v0.150.0 or newer runs it; decision 157)", host)
}
return ""
}
// ApproveDocker is the operator's button: it approves the Docker engine set ring 0 runs, only when DockerStatus allows.
// A ring-1 box then takes it only through a signed operator job (`11` §5.8) — approval alone installs nothing.
func (s *Service) ApproveDocker() (string, error) {
+7 -2
View File
@@ -1,6 +1,7 @@
package osupdates
import (
"encoding/json"
"log"
"os"
"path/filepath"
@@ -52,8 +53,12 @@ func (f *fix) reportL(t *testing.T, host, layer, trigger string, healthy bool, p
if !healthy {
outcome = "health_failed"
}
if err := f.s.Ingest(host, Report{RunID: host + trigger + f.now.String(), Layer: layer, Trigger: trigger, Mode: "apply", Outcome: outcome,
Healthy: healthy, Installed: pkgs, Upgraded: pkgs[:1]}); err != nil {
r := Report{RunID: host + trigger + f.now.String(), Layer: layer, Trigger: trigger, Mode: "apply", Outcome: outcome,
Healthy: healthy, Installed: pkgs, Upgraded: pkgs[:1]}
if layer == LayerDocker { // an agent >= v0.150.0 reports the step's memory-kill check (decision 157)
r.OOMCheck = json.RawMessage(`{"result":"pass","oom_killed":true,"oom_event":true,"exit_code":137,"image":"felhom-controller","detail":""}`)
}
if err := f.s.Ingest(host, r); err != nil {
t.Fatal(err)
}
}