earlyoom killed the guest mid-deploy — drive died as a confusing ssh-refused; guest needs OOM protection + guest-death detection + availability-aware floor #553

Closed
opened 2026-08-15 00:16:32 +00:00 by ben · 3 comments
Owner

Symptom

2026-08-15 tier-1 drive (post-#549): the deploy failed at the control-plane row with

[gateway] ssh: connect to host 127.0.0.1 port 36579: Connection refused

The port was correct and the unit healthy — the guest itself was dead. Its final console line (user journal, decoded):

qemu-system-x86_64.real: terminating on signal 15 from pid 925 (/usr/bin/earlyoom)

The HOST ran out of memory mid-founding (14 GB machine: guest ~3.6 GB + host-side clan/nix evaluation + the app + operator browser; swap 4/4 GB full) and earlyoom chose qemu — the biggest RSS — as its victim. Restart=no is by design for the app-tied user-scope guest (#427), so the guest stayed down and the deploy walked into a refused SSH forward.

Three rules worth pulling out

  1. Protect the guest from userspace OOM killers during founding. The guest is the single most load-bearing process of the whole journey; the unit should carry OOMScoreAdjust= (and consider ManagedOOMPreference=avoid) so earlyoom/systemd-oomd prefer any other victim. earlyoom by default SIGTERMs the largest process — which the gateway VM will almost always be on an operator laptop.

  2. A dead guest should fail as "the VM stopped", not as a connection error. The deploy seam already knows the guest unit; on any transport failure it should check is-active first and report the guest's death (with the earlyoom line — it is right there in the unit journal) instead of surfacing ssh: Connection refused to the operator.

  3. The hardware-floor probe checks capacity, not availability. The S9 card passed 14 GB total while available memory + full swap could not actually sustain guest + deploy concurrently. The probe (or a pre-deploy check) should consider MemAvailable against the guest size + deploy headroom and warn before standing up, not fail confusingly mid-leg.

Proof

Under artificial memory pressure (or an earlyoom simulation killing qemu mid-deploy): the drive fails with an explicit "the local VM stopped (killed by the system's out-of-memory guard)" fault carrying the journal evidence — and with the unit protection in place, earlyoom picks a different victim in the first place.

Incident from the 2026-08-15 fix-verification drive; chained after #549 (fixed) and #550 (open).

## Symptom 2026-08-15 tier-1 drive (post-#549): the deploy failed at the control-plane row with ``` [gateway] ssh: connect to host 127.0.0.1 port 36579: Connection refused ``` The port was correct and the unit healthy — the guest itself was dead. Its final console line (user journal, decoded): ``` qemu-system-x86_64.real: terminating on signal 15 from pid 925 (/usr/bin/earlyoom) ``` The HOST ran out of memory mid-founding (14 GB machine: guest ~3.6 GB + host-side clan/nix evaluation + the app + operator browser; swap 4/4 GB full) and earlyoom chose qemu — the biggest RSS — as its victim. `Restart=no` is by design for the app-tied user-scope guest (#427), so the guest stayed down and the deploy walked into a refused SSH forward. ## Three rules worth pulling out 1. **Protect the guest from userspace OOM killers during founding.** The guest is the single most load-bearing process of the whole journey; the unit should carry `OOMScoreAdjust=` (and consider `ManagedOOMPreference=avoid`) so earlyoom/systemd-oomd prefer any other victim. earlyoom by default SIGTERMs the largest process — which the gateway VM will almost always be on an operator laptop. 2. **A dead guest should fail as "the VM stopped", not as a connection error.** The deploy seam already knows the guest unit; on any transport failure it should check `is-active` first and report the guest's death (with the earlyoom line — it is right there in the unit journal) instead of surfacing `ssh: Connection refused` to the operator. 3. **The hardware-floor probe checks capacity, not availability.** The S9 card passed 14 GB total while available memory + full swap could not actually sustain guest + deploy concurrently. The probe (or a pre-deploy check) should consider MemAvailable against the guest size + deploy headroom and warn before standing up, not fail confusingly mid-leg. ## Proof Under artificial memory pressure (or an earlyoom simulation killing qemu mid-deploy): the drive fails with an explicit "the local VM stopped (killed by the system's out-of-memory guard)" fault carrying the journal evidence — and with the unit protection in place, earlyoom picks a different victim in the first place. Incident from the 2026-08-15 fix-verification drive; chained after #549 (fixed) and #550 (open).
Author
Owner

This was generated by AI during triage.

Verification: Confirmed no existing guest-side OOM protection or guest-death-aware transport error reporting in the codebase — earlyoom/OOM handling only appears in the masked-exit log-classification path (internal/clan/errors.go, #374), which detects an OOM kill after the fact in copy logs; it does not protect the guest process itself or reclassify a resulting SSH connection-refused as a guest death. Redundancy check: not already implemented.

Agent Brief

Category: bug
Summary: The founding guest VM has no OOM-kill protection and its death surfaces to the operator as a confusing SSH connection-refused instead of an honest "the VM was killed" fault; the hardware-floor probe also doesn't account for available memory headroom during a live deploy.

Current behavior:
On a host under memory pressure, userspace OOM killers (earlyoom, systemd-oomd) are free to pick the guest VM process as their victim — it is typically the largest RSS process on an operator's machine during founding. The guest's systemd unit deliberately does not auto-restart (by design, for the app-tied user-scope guest). When the guest is killed mid-deploy, the deploy's SSH-based transport to the guest fails with a generic connection-refused error; nothing in the deploy path checks whether the guest unit itself is still active, so the operator sees a transport error with no indication the guest died, let alone why. Separately, the pre-deploy hardware-floor probe checks total memory capacity but not available memory/swap headroom, so it can pass on a machine that cannot actually sustain guest + deploy concurrently.

Desired behavior:

  1. The guest's systemd unit is configured so userspace OOM killers prefer other victims over it (e.g. OOMScoreAdjust, and considering ManagedOOMPreference=avoid).
  2. When a deploy transport failure occurs, the deploy path checks whether the guest unit is still active before surfacing a generic transport error; if the guest is down, the fault reported to the operator says the local VM stopped (killed by the system's out-of-memory guard), carrying the relevant unit-journal evidence (e.g. the earlyoom kill line), instead of a bare "connection refused".
  3. The hardware-floor probe (or a pre-deploy check) considers MemAvailable (including swap) against the guest's memory footprint plus deploy headroom, and warns before stand-up begins rather than failing confusingly mid-leg.

Key interfaces:

  • The guest VM's systemd unit definition — gains OOM-preference directives.
  • The deploy transport failure path — gains a guest-liveness check (systemctl is-active or equivalent) before surfacing a transport error, and a distinct fault type/message for "guest process killed by OOM guard" that carries journal evidence.
  • The hardware-floor / pre-deploy capacity probe — gains an available-memory (not just total-memory) check.

Acceptance criteria:

  • Under simulated memory pressure (or a simulated earlyoom kill of the guest process mid-deploy), the drive fails with an explicit "the local VM stopped (killed by the system's out-of-memory guard)" fault carrying journal evidence, not a bare SSH connection-refused.
  • The guest unit carries OOM-preference directives; with them in place, a host-level OOM event prefers another process over the guest where one exists.
  • The hardware-floor/pre-deploy probe fails or warns when available memory (not just total) is insufficient for guest + deploy headroom.

Out of scope:

  • Any change to Restart=no on the guest unit (deliberate, per #427) — this ticket is about who the OOM killer picks and how death is reported, not about auto-restarting the guest.
  • The #549/#550 activation and retry-transport issues chained alongside this one — separate tickets, separate fixes.
> *This was generated by AI during triage.* **Verification:** Confirmed no existing guest-side OOM protection or guest-death-aware transport error reporting in the codebase — `earlyoom`/OOM handling only appears in the *masked-exit log-classification* path (`internal/clan/errors.go`, #374), which detects an OOM kill after the fact in copy logs; it does not protect the guest process itself or reclassify a resulting SSH connection-refused as a guest death. Redundancy check: not already implemented. ## Agent Brief **Category:** bug **Summary:** The founding guest VM has no OOM-kill protection and its death surfaces to the operator as a confusing SSH connection-refused instead of an honest "the VM was killed" fault; the hardware-floor probe also doesn't account for available memory headroom during a live deploy. **Current behavior:** On a host under memory pressure, userspace OOM killers (earlyoom, systemd-oomd) are free to pick the guest VM process as their victim — it is typically the largest RSS process on an operator's machine during founding. The guest's systemd unit deliberately does not auto-restart (by design, for the app-tied user-scope guest). When the guest is killed mid-deploy, the deploy's SSH-based transport to the guest fails with a generic connection-refused error; nothing in the deploy path checks whether the guest unit itself is still active, so the operator sees a transport error with no indication the guest died, let alone why. Separately, the pre-deploy hardware-floor probe checks total memory capacity but not available memory/swap headroom, so it can pass on a machine that cannot actually sustain guest + deploy concurrently. **Desired behavior:** 1. The guest's systemd unit is configured so userspace OOM killers prefer other victims over it (e.g. `OOMScoreAdjust`, and considering `ManagedOOMPreference=avoid`). 2. When a deploy transport failure occurs, the deploy path checks whether the guest unit is still active before surfacing a generic transport error; if the guest is down, the fault reported to the operator says the local VM stopped (killed by the system's out-of-memory guard), carrying the relevant unit-journal evidence (e.g. the earlyoom kill line), instead of a bare "connection refused". 3. The hardware-floor probe (or a pre-deploy check) considers `MemAvailable` (including swap) against the guest's memory footprint plus deploy headroom, and warns before stand-up begins rather than failing confusingly mid-leg. **Key interfaces:** - The guest VM's systemd unit definition — gains OOM-preference directives. - The deploy transport failure path — gains a guest-liveness check (`systemctl is-active` or equivalent) before surfacing a transport error, and a distinct fault type/message for "guest process killed by OOM guard" that carries journal evidence. - The hardware-floor / pre-deploy capacity probe — gains an available-memory (not just total-memory) check. **Acceptance criteria:** - [ ] Under simulated memory pressure (or a simulated earlyoom kill of the guest process mid-deploy), the drive fails with an explicit "the local VM stopped (killed by the system's out-of-memory guard)" fault carrying journal evidence, not a bare SSH connection-refused. - [ ] The guest unit carries OOM-preference directives; with them in place, a host-level OOM event prefers another process over the guest where one exists. - [ ] The hardware-floor/pre-deploy probe fails or warns when available memory (not just total) is insufficient for guest + deploy headroom. **Out of scope:** - Any change to `Restart=no` on the guest unit (deliberate, per #427) — this ticket is about who the OOM killer picks and how death is reported, not about auto-restarting the guest. - The #549/#550 activation and retry-transport issues chained alongside this one — separate tickets, separate fixes.
Author
Owner

swarm-claim host=matou-dev-server-01 run=6503
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=6503 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

close-report for #553 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 553,
  "status": "success",
  "commits": [
    "3c345eff021f895b383ae0954ad1b83520a031db"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/enroll/enroll.go",
    "internal/founding/deploy.go",
    "internal/founding/deploy_test.go",
    "internal/founding/lowmemory_internal_test.go",
    "internal/founding/privatepath.go",
    "internal/founding/testing/fakes.go",
    "internal/hostprobe/parse_test.go",
    "internal/hostprobe/prober.go",
    "internal/hostprobe/prober_test.go",
    "internal/hostprobe/sources_linux.go",
    "internal/hostprobe/sources_other.go",
    "internal/vm/manager.go",
    "internal/vm/manager_test.go"
  ],
  "tests": [
    {
      "command": "go test ./internal/vm/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/founding/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/hostprobe/",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/enroll/",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Under a simulated earlyoom kill of the guest mid-deploy, the drive fails with an explicit 'the local VM stopped (killed by the system's out-of-memory guard)' fault carrying journal evidence, not a bare SSH connection-refused": "TestDeploy_GuestKilledMidDeployReportsVMStoppedNotConnectionRefused (internal/founding/deploy_test.go): a scripted FailConnectivity deploy failure + a dead FakeLocalVM whose journal carries the earlyoom kill line yields ds.Failure.Detail naming the out-of-memory guard + the earlyoom evidence, and Kind != connectivity. Reclassification: reclassifyGuestDeath + Manager.DeathEvidence (internal/founding/deploy.go, internal/vm/manager.go). Negative guard: TestDeploy_ConnectivityFailureWithLiveGuestStaysConnectivity keeps a live-guest connectivity failure.",
    "The guest unit carries OOM-preference directives; with them in place a host-level OOM event prefers another process over the guest": "TestCreate_UnitCarriesOOMProtection (internal/vm/manager_test.go): the rendered unit carries OOMScoreAdjust=-900 + ManagedOOMPreference=avoid in both system and user scope; unitFile in internal/vm/manager.go.",
    "The hardware-floor/pre-deploy probe fails or warns when available memory (not just total) is insufficient for guest + deploy headroom": "New hostprobe MemAvailable source (MemAvailable + free swap) -> enroll.ProbeReport.MemAvailableBytes; TestParse_MemAvailableKB + TestProbe_ReportsAvailableMemory. Pre-stand-up lowMemoryAdvisory (internal/founding/privatepath.go, wired in runPrivateJourney before standUpLocalVM) warns when available < guest + ~2 GiB headroom; TestLowMemoryAdvisory covers the incident shape, ample memory, and unmeasured-zero."
  },
  "summary": "The founding guest VM is protected from userspace OOM killers, its mid-deploy death reads as an honest VM-stopped fault with journal evidence instead of a bare SSH connection-refused, and a pre-stand-up advisory warns on insufficient available memory.",
  "blockers": []
}
**close-report** for #553 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 553, "status": "success", "commits": [ "3c345eff021f895b383ae0954ad1b83520a031db" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/enroll/enroll.go", "internal/founding/deploy.go", "internal/founding/deploy_test.go", "internal/founding/lowmemory_internal_test.go", "internal/founding/privatepath.go", "internal/founding/testing/fakes.go", "internal/hostprobe/parse_test.go", "internal/hostprobe/prober.go", "internal/hostprobe/prober_test.go", "internal/hostprobe/sources_linux.go", "internal/hostprobe/sources_other.go", "internal/vm/manager.go", "internal/vm/manager_test.go" ], "tests": [ { "command": "go test ./internal/vm/", "exit_code": 0 }, { "command": "go test ./internal/founding/", "exit_code": 0 }, { "command": "go test ./internal/hostprobe/", "exit_code": 0 }, { "command": "go test ./internal/enroll/", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./...", "exit_code": 0 }, { "command": "go test ./...", "exit_code": 0 } ], "criteria": { "Under a simulated earlyoom kill of the guest mid-deploy, the drive fails with an explicit 'the local VM stopped (killed by the system's out-of-memory guard)' fault carrying journal evidence, not a bare SSH connection-refused": "TestDeploy_GuestKilledMidDeployReportsVMStoppedNotConnectionRefused (internal/founding/deploy_test.go): a scripted FailConnectivity deploy failure + a dead FakeLocalVM whose journal carries the earlyoom kill line yields ds.Failure.Detail naming the out-of-memory guard + the earlyoom evidence, and Kind != connectivity. Reclassification: reclassifyGuestDeath + Manager.DeathEvidence (internal/founding/deploy.go, internal/vm/manager.go). Negative guard: TestDeploy_ConnectivityFailureWithLiveGuestStaysConnectivity keeps a live-guest connectivity failure.", "The guest unit carries OOM-preference directives; with them in place a host-level OOM event prefers another process over the guest": "TestCreate_UnitCarriesOOMProtection (internal/vm/manager_test.go): the rendered unit carries OOMScoreAdjust=-900 + ManagedOOMPreference=avoid in both system and user scope; unitFile in internal/vm/manager.go.", "The hardware-floor/pre-deploy probe fails or warns when available memory (not just total) is insufficient for guest + deploy headroom": "New hostprobe MemAvailable source (MemAvailable + free swap) -> enroll.ProbeReport.MemAvailableBytes; TestParse_MemAvailableKB + TestProbe_ReportsAvailableMemory. Pre-stand-up lowMemoryAdvisory (internal/founding/privatepath.go, wired in runPrivateJourney before standUpLocalVM) warns when available < guest + ~2 GiB headroom; TestLowMemoryAdvisory covers the incident shape, ample memory, and unmeasured-zero." }, "summary": "The founding guest VM is protected from userspace OOM killers, its mid-deploy death reads as an honest VM-stopped fault with journal evidence instead of a bare SSH connection-refused, and a pre-stand-up advisory warns on insufficient available memory.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-15 01:29:17 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#553
No description provided.