Skip to content

Commit c432ea0

Browse files
committed
docs(reaper): correct liveness-source count; note intentional create_mutable/2 refusal and liveness test scope
1 parent 2a13f30 commit c432ea0

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/hyper/node/img.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ defmodule Hyper.Node.Img do
6161
@doc "Create a per-VM mutable layer for `vm_id` over `img_id`."
6262
@spec create_mutable(Hyper.Img.id(), Hyper.Vm.Id.t()) :: {:ok, pid()} | {:error, term()}
6363
def create_mutable(img_id, vm_id) do
64+
# Unlike activate/1, we intentionally do NOT map {:already_started, pid} -> {:ok, pid}:
65+
# vm_ids are unique per VM, so a duplicate vm_id is a bug, not a shared-server reuse.
66+
# Surfacing {:error, {:already_started, pid}} enforces the one-mutable-per-vm invariant.
6467
case DynamicSupervisor.start_child(
6568
@mutable_sup,
6669
{Mutable, %Mutable.Opts{img_id: img_id, vm_id: vm_id}}

lib/hyper/node/reaper.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ defmodule Hyper.Node.Reaper do
66
whose vm_id never reboots (so `Hyper.Node.Reclaim`, which runs once at boot, and
77
the relaunch-time cleanup in the FireVMM path, never get a chance to clear it).
88
9-
Liveness is the whole point. The reaper consults two independent sources of
10-
truth for "this vm is alive" (`Plan.orphans/3` removes their union from the
11-
candidate set) and only ever touches `hyper-rw-*` dm names and per-VM cgroup
12-
leaves - never `hyper-thinpool`, `hyper-img-*`, or a live VM's resources. A
9+
Liveness is the whole point. The reaper consults three independent sources of
10+
truth for "this vm is alive" — the local VM supervisor's children, the cluster
11+
routing table, and the node's live mutable layers (`Img.Mutable.active_vm_ids/0`)
12+
— (`Plan.orphans/3` removes their union from the candidate set) and only ever
13+
touches `hyper-rw-*` dm names and per-VM cgroup leaves - never `hyper-thinpool`,
14+
`hyper-img-*`, or a live VM's resources. A
1315
candidate must also survive two consecutive ticks (`Plan.confirm/2`) before it
1416
is reaped, so a VM caught mid-boot (resources present, not yet registered) is
1517
given a grace tick rather than destroyed.

test/hyper/node/reaper/liveness_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule Hyper.Node.Reaper.LivenessTest do
2+
# Guards the Img.Mutable.active_vm_ids/0 + Plan.orphans/3 contract: a live mutable
3+
# layer protects its vm_id from reaping. The gather_live/0 union of this source into
4+
# the full live set is verified by manual live-node testing (Task 4), not CI.
25
use ExUnit.Case, async: false
36

47
alias Hyper.Node.Img

0 commit comments

Comments
 (0)