activator: an end rebuilt from systemd keeps the unit's clean exits (Astra R1 P2)
Astra round 1 (READY AFTER FIXES, no P1, every census unit APPROVE) found one P2: the empty-code fallback counted only exit 0 as success and overwrote the record's "success", while the instance templates accept 129, 130, 141 and 143 (the trampoline's 128+n for HUP, INT, PIPE and TERM) and systemd counts those signal deaths clean. A normal SIGTERM stop (1/143) became "exit-code" and a warning. UnitMainExit now also reads the unit's SuccessExitStatus (systemctl show, the policy as systemd loaded it from the template the platform ships, so there is no second list in Go), returned as a MainExit. cleanMainExit is systemd's is_clean_exit for a main process: exit 0 or a listed code, a death by HUP, INT, PIPE, TERM or a signal the policy names, never a core dump. A "success" record stays success only for such an end; SIGKILL's 137 is still corrected to exit-code. Tests read each record-reading unit's template (run, gen, sidecar, rootfs run, rootfs gen, rootfs worker) from internal/host/units: every listed status and each clean signal is success, 137, exit 1, KILL and a core dump are not; a worker's and web's 1/143 and a worker's 2/TERM end clean end-to-end. Mutations caught: the policy ignored, no clean signals, 137 clean, a core dump clean. Census re-proposed with the same claims file: the two new units' digests moved and their claims say so; same units, classes and sites. Findings committed as docs/superpowers/reviews/CODEX-FINDINGS-rootfs-worker-exit-R1.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+222
−46
docs/superpowers/notes/census-proposal-rootfs-worker-exit.md+1 −1docs/superpowers/reviews/CODEX-FINDINGS-rootfs-worker-exit-R1.md+32 −0internal/activator/control.go+25 −16internal/activator/rootfsworkers_backend_test.go+114 −13internal/activator/unitproc.go+44 −10internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv+5 −5
CI passed — run details
Intent
Attributed to this commit: 18.5 g CO₂e (2,324,871 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on rootfs-worker-exit, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/docs/superpowers/notes/census-proposal-rootfs-worker-exit.md b/docs/superpowers/notes/census-proposal-rootfs-worker-exit.md| index c725ade0f..4232ec797 100644 |
| --- a/docs/superpowers/notes/census-proposal-rootfs-worker-exit.md |
| +++ b/docs/superpowers/notes/census-proposal-rootfs-worker-exit.md |
| @@ -21,6 +21,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/activator/control.go:systemctlUnitMainExit`: reads +file:CommandContext; written legacy, accepted-legacy, frozen |
| - new `internal/activator/unitproc.go:ExecBackend.unitMainExitOf`: reads +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen |
| -Seal: `78b7e7e30ad3ada44388a4ee16f3950ef888ae03e552477dcbfbb07c51ffb83e` → `19fd02ddce24e25bac069e2e33441d6c62869ef3f6d7bb5142a3e93e58bcfbf0`. |
| +Seal: `78b7e7e30ad3ada44388a4ee16f3950ef888ae03e552477dcbfbb07c51ffb83e` → `7ebc3871ee3c93ff168bfa62d23d6be5a970786c67a9b8aa813e8cc4e39b3d74`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-worker-exit-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-worker-exit-R1.md| new file mode 100644 |
| index 000000000..b0fb9facb |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-rootfs-worker-exit-R1.md |
| @@ -0,0 +1,32 @@ |
| +Reviewed `a66482c9..18e55618` at pinned tip `8ea0b282a8c046e1687f3f326f9b90f5052794b3`, round 1/3. |
| + |
| +**P1:** None. |
| + |
| +**P2 — The fallback misclassifies accepted clean exits as failures.** |
| +Evidence: [unitproc.go:547](internal/activator/unitproc.go:547) treats only exit `0` as success, then overwrites the record’s `"success"` result at [unitproc.go:565](internal/activator/unitproc.go:565). The templates explicitly accept `129`, `130`, `141`, and `143`; [the rootfs generation template:40](internal/host/units/carlos-instance-rootfs-gen@.service:40) explains why. |
| + |
| +Failure scenario: a normal SIGTERM stop leaves an empty-code record and matching main status `1/143`. The fallback changes its result to `"exit-code"`, causing `exitLine`/`exitLevel` to report a warning. Systemd also treats certain signal deaths as clean. [Systemd’s classification](https://raw.githubusercontent.com/systemd/systemd/v257/src/shared/exit-status.c) confirms that nonzero status alone does not establish failure. |
| + |
| +Fix: apply the relevant unit’s clean-exit policy when reconstructing the result. Preserve the `137` failure correction. Add regression cases for accepted nonzero exits and clean signals; the new test currently checks only `0` as clean at [rootfsworkers_backend_test.go:659](internal/activator/rootfsworkers_backend_test.go:659). |
| + |
| +Invariant: reconstructing missing exit fields must preserve the unit’s successful-stop semantics. Termination proof, restart eligibility and lease handling are unaffected. |
| + |
| +**P3:** None. |
| + |
| +**Census verdicts — authority and read-boundary review** |
| + |
| +| Unit or envelope | Verdict | Evidence and basis | |
| +|---|---|---| |
| +| `ExecBackend.observe` | APPROVE | [unitproc.go:451](internal/activator/unitproc.go:451): termination evidence remains required before consuming the advisory record. | |
| +| `Service.noteWorkerExitLocked` | APPROVE | [rootfsworkers.go:622](internal/activator/rootfsworkers.go:622): changes event reporting only; failed starts remain excluded and C35 uses C09 pacing. | |
| +| `systemctlUnitMainExit` | APPROVE | [control.go:127](internal/activator/control.go:127): unprivileged query of the handle’s generated unit name; no new root operation. | |
| +| `ExecBackend.unitMainExitOf` | APPROVE | [unitproc.go:515](internal/activator/unitproc.go:515): bounded query, matching nonempty invocation required, advisory fields only. | |
| +| `.` envelope | APPROVE | [instances_cli.go:596](instances_cli.go:596): REASON uses `rolloutwords.Reason`; empty reason retains the existing cell. | |
| +| `internal/activator` envelope | APPROVE | New seam, mapping and event path introduce no additional root authority or weaker termination check. The P2 above concerns reporting. | |
| +| `internal/rolloutwords` envelope | APPROVE | [words.go:109](internal/rolloutwords/words.go:109): approved format constants only. | |
| + |
| +The invocation and main-exit fields come from one systemd property snapshot; a replacement invocation is rejected. Systemd resets main-exit status when starting a new invocation. [Query implementation](https://raw.githubusercontent.com/systemd/systemd/v257/src/shared/bus-map-properties.c), [service lifecycle](https://raw.githubusercontent.com/systemd/systemd/v257/src/core/service.c). |
| + |
| +`git diff --check` passed. Targeted tests could not start: the read-only sandbox denied Go’s build directory under `$TMPDIR`. `GOCACHE` remained unset. No full suites ran, and mutation results were not verified. No files were edited. |
| + |
| +READY AFTER FIXES |
| \ No newline at end of file |
diff --git a/internal/activator/control.go b/internal/activator/control.go| index 92cafa34c..0ca06618b 100644 |
| --- a/internal/activator/control.go |
| +++ b/internal/activator/control.go |
| @@ -117,32 +117,41 @@ func systemctlUnitState(ctx context.Context, unit string) (string, string, error |
| } |
| // UnitMainExit answers `systemctl show -p |
| -// InvocationID,ExecMainCode,ExecMainStatus <unit>`, which needs no |
| -// privilege: how systemd recorded the end of the unit's main process, and |
| -// the invocation it belongs to. The code is a number (0 none recorded, 1 |
| -// exited, 2 killed, 3 dumped), the status the exit code or the signal's |
| -// number. |
| -type UnitMainExit func(ctx context.Context, unit string) (invocation, code, status string, err error) |
| - |
| -func systemctlUnitMainExit(ctx context.Context, unit string) (string, string, string, error) { |
| - out, err := exec.CommandContext(ctx, "systemctl", "show", "-p", "InvocationID,ExecMainCode,ExecMainStatus", unit).Output() |
| +// InvocationID,ExecMainCode,ExecMainStatus,SuccessExitStatus <unit>`, which |
| +// needs no privilege: how systemd recorded the end of the unit's main |
| +// process, the invocation it belongs to, and the unit's own clean-exit |
| +// policy as systemd loaded it from the template the platform ships. |
| +type UnitMainExit func(ctx context.Context, unit string) (MainExit, error) |
| + |
| +// MainExit is one `systemctl show` of a unit's main process's end. Code is |
| +// a number (0 none recorded, 1 exited, 2 killed, 3 dumped), Status the exit |
| +// code or the signal's number, SuccessExitStatus the unit's |
| +// SuccessExitStatus= as systemctl prints it: exit codes, then signal names. |
| +type MainExit struct { |
| + Invocation, Code, Status, SuccessExitStatus string |
| +} |
| + |
| +func systemctlUnitMainExit(ctx context.Context, unit string) (MainExit, error) { |
| + out, err := exec.CommandContext(ctx, "systemctl", "show", "-p", "InvocationID,ExecMainCode,ExecMainStatus,SuccessExitStatus", unit).Output() |
| if err != nil { |
| - return "", "", "", err |
| + return MainExit{}, err |
| } |
| - var inv, code, status string |
| + var m MainExit |
| for _, line := range strings.Split(string(out), "\n") { |
| if k, v, ok := strings.Cut(line, "="); ok { |
| - switch k { |
| + switch v = strings.TrimSpace(v); k { |
| case "InvocationID": |
| - inv = strings.TrimSpace(v) |
| + m.Invocation = v |
| case "ExecMainCode": |
| - code = strings.TrimSpace(v) |
| + m.Code = v |
| case "ExecMainStatus": |
| - status = strings.TrimSpace(v) |
| + m.Status = v |
| + case "SuccessExitStatus": |
| + m.SuccessExitStatus = v |
| } |
| } |
| } |
| - return inv, code, status, nil |
| + return m, nil |
| } |
| // CgroupEvents reads the unit's cgroup.events under the host slice. cgroup |
diff --git a/internal/activator/rootfsworkers_backend_test.go b/internal/activator/rootfsworkers_backend_test.go| index 4cf10f7d9..78b639a02 100644 |
| --- a/internal/activator/rootfsworkers_backend_test.go |
| +++ b/internal/activator/rootfsworkers_backend_test.go |
| @@ -75,15 +75,41 @@ func (u *workerUnits) setMain(unit, inv, code, status string) { |
| } |
| // mainExit is the fake UnitMainExit: an unset unit answers as systemd |
| -// does for one that never ran, code and status 0. |
| -func (u *workerUnits) mainExit(_ context.Context, unit string) (string, string, string, error) { |
| +// does for one that never ran, code and status 0. The clean-exit policy is |
| +// the one the unit's template ships (shippedSuccessExitStatus), as systemd |
| +// would load it. |
| +func (u *workerUnits) mainExit(_ context.Context, unit string) (MainExit, error) { |
| + policy, err := shippedSuccessExitStatus(unit) |
| + if err != nil { |
| + return MainExit{}, err |
| + } |
| u.mu.Lock() |
| defer u.mu.Unlock() |
| m, ok := u.main[unit] |
| if !ok { |
| - return "", "0", "0", nil |
| + return MainExit{Code: "0", Status: "0", SuccessExitStatus: policy}, nil |
| + } |
| + return MainExit{Invocation: m[0], Code: m[1], Status: m[2], SuccessExitStatus: policy}, nil |
| +} |
| + |
| +// shippedSuccessExitStatus is the SuccessExitStatus= of the template unit |
| +// is an instance of, read from the unit files the platform ships |
| +// (internal/host/units); "" when the template declares none. |
| +func shippedSuccessExitStatus(unit string) (string, error) { |
| + at := strings.Index(unit, "@") |
| + if at < 0 { |
| + return "", fmt.Errorf("%s is not a template's instance", unit) |
| + } |
| + raw, err := os.ReadFile(filepath.Join("..", "host", "units", unit[:at+1]+".service")) |
| + if err != nil { |
| + return "", err |
| + } |
| + for _, line := range strings.Split(string(raw), "\n") { |
| + if v, ok := strings.CutPrefix(line, "SuccessExitStatus="); ok { |
| + return strings.TrimSpace(v), nil |
| + } |
| } |
| - return m[0], m[1], m[2], nil |
| + return "", nil |
| } |
| func (u *workerUnits) events(_ string, unit string) (bool, bool, error) { |
| @@ -657,6 +683,10 @@ func TestAnExitRecordWithNoCodeReadsSystemd(t *testing.T) { |
| {"killed by KILL", "2", "9", instancectl.ExitRecord{Invocation: "inv1", Result: "signal", Code: "killed", Status: "KILL"}, true}, |
| {"dumped by SEGV", "3", "11", instancectl.ExitRecord{Invocation: "inv1", Result: "core-dump", Code: "dumped", Status: "SEGV"}, false}, |
| {"a clean exit stays a success", "1", "0", instancectl.ExitRecord{Invocation: "inv1", Result: "success", Code: "exited", Status: "0"}, false}, |
| + // Astra R1 P2: a stop's SIGTERM reaches the app through the |
| + // trampoline, which exits 143, a status the template counts clean. |
| + {"stopped by TERM through the trampoline: a success", "1", "143", instancectl.ExitRecord{Invocation: "inv1", Result: "success", Code: "exited", Status: "143"}, false}, |
| + {"killed by TERM: a success", "2", "15", instancectl.ExitRecord{Invocation: "inv1", Result: "success", Code: "killed", Status: "TERM"}, false}, |
| {"no exit recorded", "0", "0", noCode, false}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| @@ -679,13 +709,27 @@ func TestAnExitRecordWithNoCodeReadsSystemd(t *testing.T) { |
| t.Fatalf("WorkerExit = %+v, %v; want the record as written", got, ok) |
| } |
| }) |
| - t.Run("web", func(t *testing.T) { |
| - t.Parallel() |
| + for _, tc := range []struct{ status, line, level string }{ |
| + {"137", "instance exited: exit 137 (exit-code)", "warn"}, |
| + {"143", "instance exited (exit 0)", "info"}, |
| + } { |
| + t.Run("web exits "+tc.status, func(t *testing.T) { |
| + t.Parallel() |
| + webExit(t, noCode, tc.status, tc.line, tc.level) |
| + }) |
| + } |
| +} |
| + |
| +// webExit ends rootfs web generation 7 with rec as its record and systemd's |
| +// main exit 1/status, and checks the member's one line and its level. |
| +func webExit(t *testing.T, rec instancectl.ExitRecord, status, line, level string) { |
| + t.Helper() |
| + { |
| b, ctl, rt, units := newWorkerBackend(t) |
| sink := &rootfsSink{} |
| b.Logs = sink |
| web, _ := startWorkerWeb(t, b, ctl, rt, units, "") |
| - raw, err := json.Marshal(noCode) |
| + raw, err := json.Marshal(rec) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -693,18 +737,75 @@ func TestAnExitRecordWithNoCodeReadsSystemd(t *testing.T) { |
| t.Fatal(err) |
| } |
| unit := instancectl.RootfsGenUnitName(rt.Host, 7) |
| - units.setMain(unit, "inv1", "1", "137") |
| + units.setMain(unit, "inv1", "1", status) |
| units.set(unit, "inactive", "inv1", false) |
| waitFor(t, "web to exit", web.Exited) |
| - if msgs := sink.msgs(); !slices.Equal(msgs, []string{"instance exited: exit 137 (exit-code)"}) { |
| - t.Errorf("web's exit told the member %q, want exit 137", msgs) |
| + if msgs := sink.msgs(); !slices.Equal(msgs, []string{line}) { |
| + t.Errorf("web's exit %s told the member %q, want %q", status, msgs, line) |
| } |
| sink.mu.Lock() |
| defer sink.mu.Unlock() |
| - if len(sink.events) == 1 && sink.events[0].level != "warn" { |
| - t.Errorf("web's exit 137 at %q, want warn", sink.events[0].level) |
| + if len(sink.events) == 1 && sink.events[0].level != level { |
| + t.Errorf("web's exit %s at %q, want %s", status, sink.events[0].level, level) |
| } |
| - }) |
| + } |
| +} |
| + |
| +// Astra R1 P2: an end rebuilt from systemd keeps the unit's own clean-exit |
| +// policy, the SuccessExitStatus= of the template each record-reading unit |
| +// is an instance of, and systemd's clean signals for a main process (HUP, |
| +// INT, PIPE, TERM). SIGKILL's 137 and every other end stay failures. |
| +func TestMainExitKeepsEachUnitsCleanExits(t *testing.T) { |
| + const host = "shop.example.com" |
| + noCode := instancectl.ExitRecord{Invocation: "inv1", Result: "success"} |
| + units := map[string]string{ |
| + "run": instancectl.UnitName(instancectl.RoleRun, host), |
| + "generation": instancectl.GenUnitName(host, 7), |
| + "sidecar": instancectl.UnitName(instancectl.RoleSidecar, host), |
| + "rootfs run": instancectl.RootfsUnitName(instancectl.RoleRun, host), |
| + "rootfs gen": instancectl.RootfsGenUnitName(host, 7), |
| + "rootfs work": instancectl.WorkerUnitName(host, "jobs"), |
| + } |
| + for kind, unit := range units { |
| + policy, err := shippedSuccessExitStatus(unit) |
| + if err != nil { |
| + t.Fatalf("%s: %v", kind, err) |
| + } |
| + statuses := strings.Fields(policy) |
| + if len(statuses) == 0 { |
| + t.Fatalf("%s: %s's template declares no SuccessExitStatus=", kind, unit) |
| + } |
| + check := func(m MainExit, want instancectl.ExitRecord) { |
| + t.Helper() |
| + m.SuccessExitStatus = policy |
| + want.Invocation = "inv1" |
| + if got := withMainExit(noCode, m); got != want { |
| + t.Errorf("%s (%s) %s/%s = %+v, want %+v", kind, policy, m.Code, m.Status, got, want) |
| + } |
| + } |
| + for _, s := range statuses { |
| + check(MainExit{Code: "1", Status: s}, instancectl.ExitRecord{Result: "success", Code: "exited", Status: s}) |
| + } |
| + for name, n := range map[string]string{"HUP": "1", "INT": "2", "PIPE": "13", "TERM": "15"} { |
| + check(MainExit{Code: "2", Status: n}, instancectl.ExitRecord{Result: "success", Code: "killed", Status: name}) |
| + } |
| + check(MainExit{Code: "1", Status: "0"}, instancectl.ExitRecord{Result: "success", Code: "exited", Status: "0"}) |
| + check(MainExit{Code: "1", Status: "137"}, instancectl.ExitRecord{Result: "exit-code", Code: "exited", Status: "137"}) |
| + check(MainExit{Code: "1", Status: "1"}, instancectl.ExitRecord{Result: "exit-code", Code: "exited", Status: "1"}) |
| + check(MainExit{Code: "2", Status: "9"}, instancectl.ExitRecord{Result: "signal", Code: "killed", Status: "KILL"}) |
| + check(MainExit{Code: "3", Status: "15"}, instancectl.ExitRecord{Result: "core-dump", Code: "dumped", Status: "TERM"}) |
| + } |
| + // The policy is what makes a status clean: none declared, 143 fails; |
| + // a signal the policy names by name is clean. |
| + if got := withMainExit(noCode, MainExit{Code: "1", Status: "143"}); got.Result != "exit-code" { |
| + t.Errorf("143 with no policy = %+v, want exit-code", got) |
| + } |
| + if got := withMainExit(noCode, MainExit{Code: "2", Status: "14", SuccessExitStatus: "129 SIGALRM"}); got.Result != "success" { |
| + t.Errorf("ALRM named by the policy = %+v, want success", got) |
| + } |
| + if got := withMainExit(noCode, MainExit{Code: "2", Status: "14", SuccessExitStatus: "129 130"}); got.Result != "signal" { |
| + t.Errorf("ALRM not named by the policy = %+v, want signal", got) |
| + } |
| } |
| func TestRootfsWorkerRefusalsStartNothing(t *testing.T) { |
diff --git a/internal/activator/unitproc.go b/internal/activator/unitproc.go| index cf4bc2f97..1ce55bd80 100644 |
| --- a/internal/activator/unitproc.go |
| +++ b/internal/activator/unitproc.go |
| @@ -9,6 +9,7 @@ import ( |
| "os" |
| "path/filepath" |
| "strconv" |
| + "strings" |
| "sync/atomic" |
| "time" |
| @@ -519,25 +520,27 @@ func (b *ExecBackend) unitMainExitOf(p *unitProc, rec instancectl.ExitRecord) in |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| defer cancel() |
| - inv, code, status, err := read(ctx, p.unit) |
| + m, err := read(ctx, p.unit) |
| if err != nil { |
| log.Printf("activator: %s: main exit of %s: %v", p.rt.Host, p.unit, err) |
| return rec |
| } |
| - if inv == "" || inv != p.invocation { |
| + if m.Invocation == "" || m.Invocation != p.invocation { |
| return rec |
| } |
| - return withMainExit(rec, code, status) |
| + return withMainExit(rec, m) |
| } |
| // withMainExit is rec with systemd's ExecMainCode and ExecMainStatus as its |
| // code and status, the words systemd gives ExecStopPost: 1 (CLD_EXITED) is |
| // exited with the exit code; 2 (CLD_KILLED) and 3 (CLD_DUMPED) are killed |
| // and dumped with the signal's name where workerSignals knows it, its |
| -// number otherwise. A result of "success" (or none) over anything but exit |
| -// 0 becomes systemd's own word for it. Any other code recorded no exit, |
| -// and rec is returned as it is. |
| -func withMainExit(rec instancectl.ExitRecord, code, status string) instancectl.ExitRecord { |
| +// number otherwise. A result of "success" (or none) stays "success" for an |
| +// end systemd counts clean (cleanMainExit) and becomes systemd's own word |
| +// for any other: exit-code, signal or core-dump, so SIGKILL's 137 is a |
| +// failure. Any other code recorded no exit, and rec is returned as it is. |
| +func withMainExit(rec instancectl.ExitRecord, m MainExit) instancectl.ExitRecord { |
| + code, status := m.Code, m.Status |
| n, err := strconv.Atoi(status) |
| if err != nil || n < 0 { |
| return rec |
| @@ -546,9 +549,6 @@ func withMainExit(rec instancectl.ExitRecord, code, status string) instancectl.E |
| switch code { |
| case "1", "exited": |
| rec.Code, rec.Status, result = "exited", status, "exit-code" |
| - if n == 0 { |
| - result = "success" |
| - } |
| case "2", "3", "killed", "dumped": |
| rec.Code, rec.Status, result = "killed", status, "signal" |
| if code == "3" || code == "dumped" { |
| @@ -562,12 +562,46 @@ func withMainExit(rec instancectl.ExitRecord, code, status string) instancectl.E |
| default: |
| return rec |
| } |
| + if cleanMainExit(rec.Code, n, m.SuccessExitStatus) { |
| + result = "success" |
| + } |
| if rec.Result == "" || rec.Result == "success" { |
| rec.Result = result |
| } |
| return rec |
| } |
| +// cleanMainExit is systemd's is_clean_exit for a service's main process |
| +// (EXIT_CLEAN_DAEMON) under the unit's own SuccessExitStatus=, as |
| +// `systemctl show` prints it (exit codes, then signal names): an exit is |
| +// clean at 0 or at a code the policy lists; a death by signal is clean for |
| +// HUP, INT, PIPE and TERM, systemd's own clean signals, or for a signal the |
| +// policy names; a core dump never is. The policy is the unit's as systemd |
| +// loaded it from the template the platform ships (internal/host/units), so |
| +// the trampoline's 129, 130, 141 and 143 stay clean without a second list |
| +// here. |
| +func cleanMainExit(code string, n int, policy string) bool { |
| + for _, f := range strings.Fields(policy) { |
| + switch code { |
| + case "exited": |
| + if v, err := strconv.Atoi(f); err == nil && v == n { |
| + return true |
| + } |
| + case "killed": |
| + if num, ok := workerSignals[strings.TrimPrefix(strings.ToUpper(f), "SIG")]; ok && num == n { |
| + return true |
| + } |
| + } |
| + } |
| + switch code { |
| + case "exited": |
| + return n == 0 |
| + case "killed": |
| + return n == workerSignals["HUP"] || n == workerSignals["INT"] || n == workerSignals["PIPE"] || n == workerSignals["TERM"] |
| + } |
| + return false |
| +} |
| + |
| // exitLine words the event line from the advisory record observe already |
| // read once and passes to both exitLine and exitLevel, so the two can |
| // never disagree from reading the file twice with something changing in |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index c27c4bab6..3590b7ccc 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -36,4 +36,4 @@ plan14-root-reads-fleet-secrets-key.tsv 9df7f5aca9a502966c9643b7062829c1c25bfbd8 |
| plan14-root-reads-static-headers.tsv 94b8ccf921f64be24a4773f72d55a8e24ceba3acfb40eefe3b56af6f5b008138 |
| plan14-root-reads-rootfs-check-volumes.tsv 042684bf5af6f61ce8b87f10b68a42b08d131ba4cb5bcab16320c7b032a724e6 |
| plan14-root-reads-rootfs-fleet-followups.tsv 78b7e7e30ad3ada44388a4ee16f3950ef888ae03e552477dcbfbb07c51ffb83e |
| -plan14-root-reads-rootfs-worker-exit.tsv 19fd02ddce24e25bac069e2e33441d6c62869ef3f6d7bb5142a3e93e58bcfbf0 |
| +plan14-root-reads-rootfs-worker-exit.tsv 7ebc3871ee3c93ff168bfa62d23d6be5a970786c67a9b8aa813e8cc4e39b3d74 |
diff --git a/internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv b/internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv| index e198f6712..937eda2fa 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-rootfs-worker-exit.tsv |
| @@ -2,13 +2,13 @@ |
| # 1 body, 1 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| # 2 new dispositions: 0 reads re-frozen at their disposition with the claim, 2 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| @legacy 654efde59dfa1b0581fdcd671633bccd26e950637a979e31e7b51dd6d7beccec internal/activator/unitproc.go ExecBackend.observe legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=final fix I3: the process observer's termination proof for a rootfs handle (Runtime, the new kind, one site) goes through unitEvents (two more Route sites): the host slice's cgroup.events and, for a rootfs unit, the group systemd reports when that is elsewhere, so a foreign invocation root placed outside the slice and could not stop is never read as gone from the absent expected path; a failed stop of a foreign invocation leaves it unstopped, asked again next poll, completion pending; a binary handle's proof is unchanged (cgroup.events under the host slice); the agent decides only whether it keeps a handle and a launch file; no root decision; re-digested at the merge of origin/main 3c33f2eb: main's own change to the observer is in the body, this branch's rootfs-aware evidence and the rootfs-only failed-stop retry (merge prep N1: a binary handle behaves exactly as main) on top; the kinds are the union;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1: for a worker handle (p.worker != "") the observer keeps the exit record it read (workerExit, workerExitOK) for the supervisor instead of wording a member event, and says nothing for a replaced-after-stop or restarted-outside end; the termination evidence (cgroup.events via unitEvents, the foreign-invocation rule) and the record's single-use removal are unchanged and apply to a worker as to a generation; a binary or generation handle behaves exactly as before; the same 22 read sites, no read added;rev3=census-ruling-rootfs-worker-exit;basis=an exit record with an empty code (read and bounded as before) is filled by unitMainExitOf before it is kept for a worker or worded for the member; the termination proof (UnitState, cgroup evidence, the foreign-invocation rule) and the record's single-use removal are unchanged; the same 22 read sites, no read added registry:Host@1222,registry:Host@3062,registry:Host@3252,registry:Host@3599,registry:Host@3825,registry:Host@4529,registry:Host@5927,registry:Runtime@2414,registry:Runtime@806,whole:Route@1224,whole:Route@2222,whole:Route@2416,whole:Route@3064,whole:Route@3254,whole:Route@3601,whole:Route@3827,whole:Route@4531,whole:Route@5001,whole:Route@5479,whole:Route@5929,whole:Route@808,whole:Route@972 0e53c43116af56ded14aa9d786eb9ba4b7b2183422b8d2bf094636c0844f8b6d |
| -@legacy 26519d5badff16976140677555950a75d4ef1000ff71a93fdfe3016f38e17798 internal/activator/control.go systemctlUnitMainExit legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: runs `systemctl show -p InvocationID,ExecMainCode,ExecMainStatus <unit>` as the agent (no privilege), the same shape as systemctlUnitState and systemctlControlGroup; the unit name is the handle's own (unitNameFor/rootfsUnitFor), not tenant input; output parsed as three key=value strings file:CommandContext@108 74e7b49ce1a61d1602988fed295101fbc84212e7bfab1cca4d91048ee926855f |
| -@legacy 152429a6381484da89988583d7f2017af3962ba2706dcb17625caa391cabca55 internal/activator/unitproc.go ExecBackend.unitMainExitOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: reads the handle's unit main exit through UnitMainExit (Route.Host only for its log line), used only when the invocation systemd reports equals the handle's own; withMainExit accepts only systemd's numeric code (1, 2, 3) and a non-negative numeric status, signal names from the fixed workerSignals table; it changes only the advisory record's code, status and result, which decide event wording and a worker's restart line, never termination, a lease or any root decision registry:Host@381,whole:Route@383 4bf2ea75dc18730c6d147a628e32c84697da8e3af263cef7d19c4378ec5918c5 |
| +@legacy 76c247bc8eb0fc12169d87a85dd34085bc19418b0506ec7164c6601d1c0a9cd4 internal/activator/control.go systemctlUnitMainExit legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: runs `systemctl show -p InvocationID,ExecMainCode,ExecMainStatus,SuccessExitStatus <unit>` as the agent (no privilege), the same shape as systemctlUnitState and systemctlControlGroup; the unit name is the handle's own (unitNameFor/rootfsUnitFor), not tenant input; output parsed as four key=value strings into MainExit (Astra R1 P2: SuccessExitStatus is the unit's clean-exit policy as systemd loaded it from the shipped template) file:CommandContext@94 5ad2758610e6c9a20c7e5c3063058de728019a1e8d981c2a8b61aa9830f7794b |
| +@legacy 04397729273875f0b8aeb47ada4f5cf6b2180a799cadd47114375b31f3499593 internal/activator/unitproc.go ExecBackend.unitMainExitOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: reads the handle's unit main exit through UnitMainExit (Route.Host only for its log line), used only when the invocation systemd reports equals the handle's own; withMainExit accepts only systemd's numeric code (1, 2, 3) and a non-negative numeric status, signal names from the fixed workerSignals table; a "success" result stays success only for an end systemd counts clean (cleanMainExit: exit 0 or a code the unit's SuccessExitStatus lists, a death by HUP, INT, PIPE, TERM or a signal the policy names, never a core dump), so SIGKILL's 137 is still corrected to a failure (Astra R1 P2); it changes only the advisory record's code, status and result, which decide event wording and a worker's restart line, never termination, a lease or any root decision registry:Host@365,whole:Route@367 4b2db78929da79fa469863bf7632e755442399079f251f06a6752e12200a4dcb |
| @legacy 6d9992edc5189954dac625f3b626db8ffaa87fee4ed86342367f06e63e0a7a30 internal/activator/rootfsworkers.go Service.noteWorkerExitLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.16: the backoff, restart count and member event of one worker exit (RFS-3-C09 and RFS-3-C10); in-memory and the member's journal only;rev3=census-ruling-rootfs-worker-exit;basis=a worker that ended with no status to tell now also emits the member event RFS-3-C35 at warn (a failed start, which never ran, still gets the operator line alone, platform-39) (e.route, the entry's own route, as C09 and C10 already use), paced as C09; the operator log line is kept; in-memory state and the member's journal only; the new site is the route passed to emitEvent whole:Route@1256,whole:Route@1404,whole:Route@902 3c35a45e892785405bd961f29168ae230e8fea4d7202ccca499d2d4f8a4d07df |
| internal/activator/unitproc.go ExecBackend.observe legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=final fix I3: the process observer's termination proof for a rootfs handle (Runtime, the new kind, one site) goes through unitEvents (two more Route sites): the host slice's cgroup.events and, for a rootfs unit, the group systemd reports when that is elsewhere, so a foreign invocation root placed outside the slice and could not stop is never read as gone from the absent expected path; a failed stop of a foreign invocation leaves it unstopped, asked again next poll, completion pending; a binary handle's proof is unchanged (cgroup.events under the host slice); the agent decides only whether it keeps a handle and a launch file; no root decision; re-digested at the merge of origin/main 3c33f2eb: main's own change to the observer is in the body, this branch's rootfs-aware evidence and the rootfs-only failed-stop retry (merge prep N1: a binary handle behaves exactly as main) on top; the kinds are the union;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1: for a worker handle (p.worker != "") the observer keeps the exit record it read (workerExit, workerExitOK) for the supervisor instead of wording a member event, and says nothing for a replaced-after-stop or restarted-outside end; the termination evidence (cgroup.events via unitEvents, the foreign-invocation rule) and the record's single-use removal are unchanged and apply to a worker as to a generation; a binary or generation handle behaves exactly as before; the same 22 read sites, no read added;rev3=census-ruling-rootfs-worker-exit;basis=an exit record with an empty code (read and bounded as before) is filled by unitMainExitOf before it is kept for a worker or worded for the member; the termination proof (UnitState, cgroup evidence, the foreign-invocation rule) and the record's single-use removal are unchanged; the same 22 read sites, no read added registry:Host@1222,registry:Host@3062,registry:Host@3252,registry:Host@3599,registry:Host@3825,registry:Host@4529,registry:Host@5927,registry:Runtime@2414,registry:Runtime@806,whole:Route@1224,whole:Route@2222,whole:Route@2416,whole:Route@3064,whole:Route@3254,whole:Route@3601,whole:Route@3827,whole:Route@4531,whole:Route@5001,whole:Route@5479,whole:Route@5929,whole:Route@808,whole:Route@972 0e53c43116af56ded14aa9d786eb9ba4b7b2183422b8d2bf094636c0844f8b6d |
| -internal/activator/control.go systemctlUnitMainExit legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: runs `systemctl show -p InvocationID,ExecMainCode,ExecMainStatus <unit>` as the agent (no privilege), the same shape as systemctlUnitState and systemctlControlGroup; the unit name is the handle's own (unitNameFor/rootfsUnitFor), not tenant input; output parsed as three key=value strings file:CommandContext@108 74e7b49ce1a61d1602988fed295101fbc84212e7bfab1cca4d91048ee926855f |
| -internal/activator/unitproc.go ExecBackend.unitMainExitOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: reads the handle's unit main exit through UnitMainExit (Route.Host only for its log line), used only when the invocation systemd reports equals the handle's own; withMainExit accepts only systemd's numeric code (1, 2, 3) and a non-negative numeric status, signal names from the fixed workerSignals table; it changes only the advisory record's code, status and result, which decide event wording and a worker's restart line, never termination, a lease or any root decision registry:Host@381,whole:Route@383 4bf2ea75dc18730c6d147a628e32c84697da8e3af263cef7d19c4378ec5918c5 |
| +internal/activator/control.go systemctlUnitMainExit legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: runs `systemctl show -p InvocationID,ExecMainCode,ExecMainStatus,SuccessExitStatus <unit>` as the agent (no privilege), the same shape as systemctlUnitState and systemctlControlGroup; the unit name is the handle's own (unitNameFor/rootfsUnitFor), not tenant input; output parsed as four key=value strings into MainExit (Astra R1 P2: SuccessExitStatus is the unit's clean-exit policy as systemd loaded it from the shipped template) file:CommandContext@94 5ad2758610e6c9a20c7e5c3063058de728019a1e8d981c2a8b61aa9830f7794b |
| +internal/activator/unitproc.go ExecBackend.unitMainExitOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-worker-exit;basis=new: reads the handle's unit main exit through UnitMainExit (Route.Host only for its log line), used only when the invocation systemd reports equals the handle's own; withMainExit accepts only systemd's numeric code (1, 2, 3) and a non-negative numeric status, signal names from the fixed workerSignals table; a "success" result stays success only for an end systemd counts clean (cleanMainExit: exit 0 or a code the unit's SuccessExitStatus lists, a death by HUP, INT, PIPE, TERM or a signal the policy names, never a core dump), so SIGKILL's 137 is still corrected to a failure (Astra R1 P2); it changes only the advisory record's code, status and result, which decide event wording and a worker's restart line, never termination, a lease or any root decision registry:Host@365,whole:Route@367 4b2db78929da79fa469863bf7632e755442399079f251f06a6752e12200a4dcb |
| internal/activator/rootfsworkers.go Service.noteWorkerExitLocked legacy accepted-legacy accepted-legacy;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W, W1.16: the backoff, restart count and member event of one worker exit (RFS-3-C09 and RFS-3-C10); in-memory and the member's journal only;rev3=census-ruling-rootfs-worker-exit;basis=a worker that ended with no status to tell now also emits the member event RFS-3-C35 at warn (a failed start, which never ran, still gets the operator line alone, platform-39) (e.route, the entry's own route, as C09 and C10 already use), paced as C09; the operator log line is kept; in-memory state and the member's journal only; the new site is the route passed to emitEvent whole:Route@1256,whole:Route@1404,whole:Route@902 3c35a45e892785405bd961f29168ae230e8fea4d7202ccca499d2d4f8a4d07df |
| @coverage . 7068c680e02abdbbabc3ed4f2b166399134f4da933148b538f136bbc8a72885a |
| -@coverage internal/activator d8ab85c6704d01dfbe179028497150619de0c666d0ccb4bb91b794c88d0f18d5 |
| +@coverage internal/activator 0f975ab364c941694a8ab542da085b235c07b5a7fd2d6c1ebce08e6963996d61 |
| @coverage internal/rolloutwords 8e5a5e657c86fa4113803bbd6c46966ae9bd7e835c2f0fae552657a82998f32e |