carlos / platform Public

host: stop witness stages the app on an exec mount, reads the right cgroup

Root runner 20261108T153054-843dc8 PASSED: mixed 4/40 alien, 4/40
Result=signal; control-group 5/40 alien, 40/40 success; an app that
ignores SIGTERM is killed at 3.3 s under TimeoutStopSec=3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 17917e6d2804844c04ae1efbbfb8a2fa0c9717a5 parent ce423ca
1 file changed, +22 −6
  • internal/host/instancestop_rootrunner_linux_test.go +22 −6

CI failed — run details

Intent

Attributed to this commit: 8.12 g CO₂e (1,026,408 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on instance-stop-528, 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/internal/host/instancestop_rootrunner_linux_test.go b/internal/host/instancestop_rootrunner_linux_test.go
index 44eff219d..0bd297b90 100644
--- a/internal/host/instancestop_rootrunner_linux_test.go
+++ b/internal/host/instancestop_rootrunner_linux_test.go
@@ -157,7 +157,17 @@ func TestRootInstanceStopUnderPrivatePIDs(t *testing.T) {
mkdirs(rundir, true)
mkdirs("/run/carlos/logs", false)
exe := "/run/carlos-control/exe/" + iid
- write(exe+"/app", bin, 0o755)
+ // As ensureExe lays it out: app is a link PID 1 chases to the build,
+ // which must sit on an exec mount (/run is noexec).
+ if _, err := os.Lstat("/opt/carlos-stopwit-app"); !errors.Is(err, fs.ErrNotExist) {
+ t.Fatalf("/opt/carlos-stopwit-app exists (%v)", err)
+ }
+ write("/opt/carlos-stopwit-app", bin, 0o755)
+ mkdirs(exe, false)
+ if err := os.Symlink("/opt/carlos-stopwit-app", exe+"/app"); err != nil {
+ t.Fatal(err)
+ }
+ made = append(made, exe+"/app")
mkdirs(exe+"/live", false)
if err := os.Symlink("../app", exe+"/live/"+host); err != nil {
t.Fatal(err)
@@ -181,8 +191,10 @@ func TestRootInstanceStopUnderPrivatePIDs(t *testing.T) {
t.Fatal("embedded template is not the PrivatePIDs, control-group template this witness is for")
}
template := "carlos-stopwit@.service"
- if out, _ := ctl("show", "-p", "LoadState", "--value", template); out != "not-found" {
- t.Fatalf("%s already present: %s", template, out)
+ for _, dir := range []string{"/etc/systemd/system", "/run/systemd/system", "/usr/lib/systemd/system"} {
+ if _, err := os.Lstat(filepath.Join(dir, template)); !errors.Is(err, fs.ErrNotExist) {
+ t.Fatalf("%s already present in %s (%v)", template, dir, err)
+ }
}
write("/run/systemd/system/"+template, []byte(strings.Join(lines, "\n")), 0o644)
unit := strings.Replace(instancectl.UnitName(instancectl.RoleRun, host), "carlos-instance@", "carlos-stopwit@", 1)
@@ -249,7 +261,8 @@ func TestRootInstanceStopUnderPrivatePIDs(t *testing.T) {
}
if s, _ := ctl("show", "-p", "ActiveState", "--value", unit); s != "active" && s != "activating" {
log, _ := exec.Command("journalctl", "-o", "cat", "--no-pager", "-n", "30", "-u", unit).CombinedOutput()
- t.Fatalf("unit %s before the tenant was up: %s", s, log)
+ out, _ := os.ReadFile("/run/carlos/logs/" + iid + ".run.sock")
+ t.Fatalf("unit %s before the tenant was up: %s\ntrampoline and tenant output: %s", s, log, out)
}
if time.Now().After(deadline) {
t.Fatal("tenant never came up")
@@ -277,8 +290,11 @@ func TestRootInstanceStopUnderPrivatePIDs(t *testing.T) {
}
time.Sleep(50 * time.Millisecond)
}
- if p, err := os.ReadFile("/sys/fs/cgroup/" + strings.TrimPrefix(must("show", "-p", "ControlGroup", "--value", unit), "/") + "/cgroup.procs"); err == nil && strings.TrimSpace(string(p)) != "" {
- t.Fatalf("processes left after stop: %s", p)
+ // An inactive unit has no ControlGroup; its cgroup directory, by the
+ // name the slice gives it, must be gone or empty.
+ cg := filepath.Join("/sys/fs/cgroup", strings.TrimPrefix(must("show", "-p", "ControlGroup", "--value", instancectl.SliceName(host)), "/"), unit, "cgroup.procs")
+ if p, err := os.ReadFile(cg); err == nil && strings.TrimSpace(string(p)) != "" {
+ t.Fatalf("processes left after stop in %s: %s", cg, p)
}
return o
}