carlos / platform Public

gvisor: probe failure log reads only its own attempt's journal

After ef8371cb, a gvisor box still logged 16 "carlos-instance-gvisor-
probe.service: no ExecStart= Refusing" lines at instance-control
start (v0.34.38, dev demo box-1). They were not new events: a failed
probe logged `journalctl --lines=20` of the probe unit, and that tail
replayed earlier attempts.

- The journal is read only once the probe has asked systemd to start
  the unit, and only --since=@<this attempt's start>.
- A failure before the start logs this attempt's own fail line, taken
  before the start-up mount lines are prepended.

Astra: no P1. P2 (wrong line logged) and P3 (loose test bound) fixed
and checked by mutation. Census APPROVE on #280.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from gvisor-probe-diag into main.
claude agent, operated by paul@keymail.dev 1cceccd4dc0a451d0ec182bfdfbcbeaeb7b2b362 parent 0b6fb0c
5 files changed, +77 −6
  • docs/superpowers/notes/census-proposal-gvisor-probe-diag.md +19 −0
  • internal/instancectl/gvisorprobe.go +19 −2
  • internal/instancectl/gvisorprobe_flow_linux_test.go +33 −4
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-gvisor-probe-diag.tsv +5 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/notes/census-proposal-gvisor-probe-diag.md b/docs/superpowers/notes/census-proposal-gvisor-probe-diag.md
new file mode 100644
index 000000000..27bc6f2f8
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-gvisor-probe-diag.md
@@ -0,0 +1,19 @@
+# Census approval: gvisor-probe-diag
+
+Ruling `census-ruling-gvisor-probe-diag`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/instancectl/gvisorprobe.go` `Server.runGVisorProbe` | body | unchanged (4) | Diagnostic only: the failure dump runs journalctl for the fixed probe unit only once a start was asked for, with --since=@<this attempt's start time>, so it no longer replays earlier attempts; a failure before the start logs this attempt's own fail line (taken before the start-up mount lines are prepended) instead. No new path, input or systemctl verb; probe steps unchanged. |
+
+Envelopes re-pinned: `internal/instancectl`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/instancectl/gvisorprobe.go` `Server.runGVisorProbe`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 6 fix round 1, applying the controller rulings: serialized probe construction uses root random nonce/fixed paths, root-only O_EXCL fixture, abstract listener, typed verified bundle/unit and context recheck. Read bounded root-owned nonce-bound output and the guest socket handshake; inspect kernel/proc runtime and limits while guest waits. Termination uses inactive/not-loaded state, no job/PIDs and empty cgroup, never per-command stop-post records. Keep the prior pass during the run and publish report plus runtime identity once, after cleanup; any failed attempt invalidates it and records the bounded diagnostic. A private package-test-only operations struct substitutes paths, executable preparation and output opening; production keeps GVisorProbePaths, fixed output/procfs, ensureExe and execsandbox.OpenRootFile. No new tenant-controlled path, launch/source/database read, or runtime-state read. CI fix: route serialized nonce fixture/output cleanup through existing pinned removeGenFiles owner with closed gVisor selectors and fixed probe paths. Existing reads and stop proof unchanged; no new raw removal owner.
+
+Seal: `158a30344d45448de74c9d6fbcc46eeab1ef76980c17a6baef3bb36e38cac00c` → `a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-gvisor-probe-diag.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/instancectl/gvisorprobe.go b/internal/instancectl/gvisorprobe.go
index b40817b28..e82f328f4 100644
--- a/internal/instancectl/gvisorprobe.go
+++ b/internal/instancectl/gvisorprobe.go
@@ -155,11 +155,20 @@ func (s *Server) runGVisorProbe(ctx context.Context) (report ProbeReport) {
s.gvisorProbeMu.Lock()
defer s.gvisorProbeMu.Unlock()
var identity string
+ // The diagnostic below reads only this attempt's journal, and only once
+ // it has asked systemd to start the unit: the unit's journal tail holds
+ // earlier attempts too, and replaying it at every failure (each update's
+ // first probe on a gVisor box) re-logged old lines as if new.
+ started := time.Now()
+ attempted := false
ops := s.gvisorProbeOperations()
fail := func(check string, err error) ProbeReport {
return ProbeReport{Lines: []VerdictLine{{Check: check, Verdict: "fail", Detail: err.Error()}}}
}
defer func() {
+ // This attempt's own verdict, before the start-up mount lines are
+ // prepended: the pre-start log line below names what failed here.
+ own := report
report = s.withStartLines(report)
s.mu.Lock()
if report.Ready {
@@ -169,14 +178,21 @@ func (s *Server) runGVisorProbe(ctx context.Context) (report ProbeReport) {
}
s.report, s.probed = report, true
s.mu.Unlock()
- if !report.Ready && s.Run != nil {
+ if !report.Ready && s.Run != nil && attempted {
diag, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
defer cancel()
- out, err := s.Run(diag, "journalctl", "--no-pager", "--output=cat", "--lines=20", "--unit="+gvisorProbeUnit)
+ out, err := s.Run(diag, "journalctl", "--no-pager", "--output=cat", "--lines=20", "--since=@"+strconv.FormatInt(started.Unix(), 10), "--unit="+gvisorProbeUnit)
if len(out) > 4096 {
out = out[len(out)-4096:]
}
s.logf("instance-control: gvisor probe: %s (%v)", strings.TrimSpace(out), err)
+ } else if !report.Ready {
+ for _, line := range own.Lines {
+ if line.Verdict == "fail" {
+ s.logf("instance-control: gvisor probe: not started: %s %s", line.Check, line.Detail)
+ break
+ }
+ }
}
}()
if _, err := s.unitFamily(s.effectiveSandbox(), roleProbe, nil); err != nil {
@@ -251,6 +267,7 @@ func (s *Server) runGVisorProbe(ctx context.Context) (report ProbeReport) {
if err = ctx.Err(); err != nil {
return fail("start", err)
}
+ attempted = true
if _, err = s.Systemctl(ctx, "start", gvisorProbeUnit); err != nil {
return fail("start", err)
}
diff --git a/internal/instancectl/gvisorprobe_flow_linux_test.go b/internal/instancectl/gvisorprobe_flow_linux_test.go
index 4c8e6ecc5..45a4bb811 100644
--- a/internal/instancectl/gvisorprobe_flow_linux_test.go
+++ b/internal/instancectl/gvisorprobe_flow_linux_test.go
@@ -14,6 +14,8 @@ import (
"os"
"path/filepath"
"runtime"
+ "slices"
+ "strconv"
"strings"
"sync"
"testing"
@@ -35,6 +37,7 @@ type probeFlow struct {
nonces, events, logs []string
active bool
runs, reloads, journals int
+ callStart time.Time
listener *net.UnixListener
conn *net.UnixConn
peer sync.WaitGroup
@@ -168,8 +171,13 @@ func newProbeFlow(t *testing.T) *probeFlow {
return nil
}
s.Run = func(ctx context.Context, args ...string) (string, error) {
- if strings.Join(args, " ") != "journalctl --no-pager --output=cat --lines=20 --unit="+gvisorProbeUnit {
+ // Only this attempt's lines: a --since bound no earlier than the
+ // probe's start, so a failure never replays older probes' journal.
+ if len(args) != 6 || strings.Join(args[:4], " ") != "journalctl --no-pager --output=cat --lines=20" || args[5] != "--unit="+gvisorProbeUnit || !strings.HasPrefix(args[4], "--since=@") {
t.Error(args)
+ } else if since, err := strconv.ParseInt(strings.TrimPrefix(args[4], "--since=@"), 10, 64); err != nil || since > time.Now().Unix() || (!f.callStart.IsZero() && since < f.callStart.Unix()) {
+ // Within this probe call, allowing whole-second truncation.
+ t.Error("journal window not bounded to this attempt", args[4], f.callStart)
}
deadline, ok := ctx.Deadline()
if !ok || time.Until(deadline) > 5*time.Second {
@@ -491,6 +499,10 @@ func TestGVisorFix1ProbeFailures(t *testing.T) {
ctx, cancel = context.WithTimeout(ctx, time.Second)
defer cancel()
}
+ // A passing start-up mount line is prepended to every report in
+ // production; the pre-start log must still name this failure.
+ f.s.startLines = []VerdictLine{{Check: "mountpoint-data-instances", Verdict: "pass"}}
+ f.callStart = time.Now()
rep := f.s.runGVisorProbe(ctx)
if rep.Ready {
t.Fatal("failed proof accepted")
@@ -500,7 +512,13 @@ func TestGVisorFix1ProbeFailures(t *testing.T) {
if strings.HasPrefix(fault, "guest/") {
expected = "probe-checks"
}
- if len(rep.Lines) != 1 || rep.Lines[0].Check != expected {
+ var fails []VerdictLine
+ for _, line := range rep.Lines {
+ if line.Verdict == "fail" {
+ fails = append(fails, line)
+ }
+ }
+ if len(rep.Lines) != 2 || len(fails) != 1 || fails[0].Check != expected {
t.Fatalf("wrong failure: %+v, want %s", rep, expected)
}
w := httptest.NewRecorder()
@@ -508,8 +526,19 @@ func TestGVisorFix1ProbeFailures(t *testing.T) {
if w.Code != http.StatusServiceUnavailable {
t.Fatal(w.Code, w.Body)
}
- if f.journals != 1 || len(f.logs) != 1 || len(f.logs[0]) > 4200 || !strings.Contains(f.logs[0], "journal-tail") {
- t.Fatal("diagnostic not bounded", f.journals, len(f.logs), f.logs)
+ // The unit's journal is read only once its start was asked for;
+ // an earlier failure logs its verdict line alone.
+ wantJournal := 0
+ f.mu.Lock()
+ if slices.Contains(f.events, "start") {
+ wantJournal = 1
+ }
+ f.mu.Unlock()
+ if f.journals != wantJournal || len(f.logs) != 1 || len(f.logs[0]) > 4200 || strings.Contains(f.logs[0], "journal-tail") != (wantJournal == 1) {
+ t.Fatal("diagnostic not bounded", fault, f.journals, f.runs, len(f.logs), f.logs)
+ }
+ if wantJournal == 0 && !strings.Contains(f.logs[0], "not started: "+expected+" ") {
+ t.Fatalf("pre-start log does not name the failure %s: %s", expected, f.logs[0])
}
f.s.mu.Lock()
token := f.s.gvisorProbeIdentity
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 8f9dcfa06..cc27d7041 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -151,3 +151,4 @@ plan14-root-reads-gvisor-probe-retry.tsv 499c08fd29787c5de2aa0197c05f82f6db0ab77
plan14-root-reads-billing-dash-2-pages.tsv 499c08fd29787c5de2aa0197c05f82f6db0ab7760eb7d980bb24211e289e4c24
plan14-root-reads-group-roll-verb.tsv 9668105384b1abd5009d76a73e37eef7f5c358eb5b08a3d1fe35f7c411e4d200
plan14-root-reads-warm-set-published-724.tsv 158a30344d45448de74c9d6fbcc46eeab1ef76980c17a6baef3bb36e38cac00c
+plan14-root-reads-gvisor-probe-diag.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee
diff --git a/internal/provision/testdata/plan14-root-reads-gvisor-probe-diag.tsv b/internal/provision/testdata/plan14-root-reads-gvisor-probe-diag.tsv
new file mode 100644
index 000000000..e3dc3f665
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-gvisor-probe-diag.tsv
@@ -0,0 +1,5 @@
+# Census overlay gvisor-probe-diag, written by census-propose (#369). census-ruling-gvisor-probe-diag, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-gvisor-probe-diag.md.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 0ad25a5c9ad7ea808f1d703690ea7b7b637e1c095f02ce4e6871cea98ba048e7 internal/instancectl/gvisorprobe.go Server.runGVisorProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 6 fix round 1, applying the controller rulings: serialized probe construction uses root random nonce/fixed paths, root-only O_EXCL fixture, abstract listener, typed verified bundle/unit and context recheck. Read bounded root-owned nonce-bound output and the guest socket handshake; inspect kernel/proc runtime and limits while guest waits. Termination uses inactive/not-loaded state, no job/PIDs and empty cgroup, never per-command stop-post records. Keep the prior pass during the run and publish report plus runtime identity once, after cleanup; any failed attempt invalidates it and records the bounded diagnostic. A private package-test-only operations struct substitutes paths, executable preparation and output opening; production keeps GVisorProbePaths, fixed output/procfs, ensureExe and execsandbox.OpenRootFile. No new tenant-controlled path, launch/source/database read, or runtime-state read. CI fix: route serialized nonce fixture/output cleanup through existing pinned removeGenFiles owner with closed gVisor selectors and fixed probe paths. Existing reads and stop proof unchanged; no new raw removal owner.;rev3=census-ruling-gvisor-probe-diag;basis=Diagnostic only: the failure dump runs journalctl for the fixed probe unit only once a start was asked for, with --since=@<this attempt's start time>, so it no longer replays earlier attempts; a failure before the start logs this attempt's own fail line (taken before the start-up mount lines are prepended) instead. No new path, input or systemctl verb; probe steps unchanged. file:Lstat@3281,file:OpenFile@2644,file:Read@2334,file:ReadAll@5643 84760d1565d9c6877179b8c74e25ce7e4700f5be4abeb14acb031eeb6d819d97
+internal/instancectl/gvisorprobe.go Server.runGVisorProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-gvisor-demos;basis=Task 6 fix round 1, applying the controller rulings: serialized probe construction uses root random nonce/fixed paths, root-only O_EXCL fixture, abstract listener, typed verified bundle/unit and context recheck. Read bounded root-owned nonce-bound output and the guest socket handshake; inspect kernel/proc runtime and limits while guest waits. Termination uses inactive/not-loaded state, no job/PIDs and empty cgroup, never per-command stop-post records. Keep the prior pass during the run and publish report plus runtime identity once, after cleanup; any failed attempt invalidates it and records the bounded diagnostic. A private package-test-only operations struct substitutes paths, executable preparation and output opening; production keeps GVisorProbePaths, fixed output/procfs, ensureExe and execsandbox.OpenRootFile. No new tenant-controlled path, launch/source/database read, or runtime-state read. CI fix: route serialized nonce fixture/output cleanup through existing pinned removeGenFiles owner with closed gVisor selectors and fixed probe paths. Existing reads and stop proof unchanged; no new raw removal owner.;rev3=census-ruling-gvisor-probe-diag;basis=Diagnostic only: the failure dump runs journalctl for the fixed probe unit only once a start was asked for, with --since=@<this attempt's start time>, so it no longer replays earlier attempts; a failure before the start logs this attempt's own fail line (taken before the start-up mount lines are prepended) instead. No new path, input or systemctl verb; probe steps unchanged. file:Lstat@3281,file:OpenFile@2644,file:Read@2334,file:ReadAll@5643 84760d1565d9c6877179b8c74e25ce7e4700f5be4abeb14acb031eeb6d819d97
+@coverage internal/instancectl 9c1897dd1cf984c7554759f4e0e6f14d880b162a582d05b88f99c8d3a6aa64e2