Skip to content

Budget admission runs after the VM has already booted #120

Open

Description

@markovejnovic

Problem

Hyper.Node.try_run/3 (lib/hyper/node.ex) calls start_fun first and only then Budget.admit(spec, pid). When admission refuses, it calls stop_fun to tear the VM down again.

Impact

N concurrent CreateVm calls all claim a uid and NetId, set up a volume, netns and jail, and start Firecracker before most of them are refused. A caller can repeatedly push a node past its CPU, RAM and disk budget for the duration of a boot, and every refused VM costs a full launch plus teardown in the helper.

Fix

Reserve first: take the budget reservation before starting the VM, keyed by a placeholder, then transfer it to the VM pid once it is running (or release it if the start fails).

Activity

  1. added
    bug
    on Nov 11, 2026
  2. markovejnovic commented on Nov 30, 2026

    @markovejnovic
    ContributorAuthor

    The Quint specs in #206 record this as an expected violation: placement_reliable violates runningWithinCapacity (the VMs running on a node exceed its hard budget until the loser is stopped), while admittedWithinCapacity holds. A counterexample in the model, not reproduced on a running system.

    Two things beyond the cost described above, both from reading the code at e281a48:

    • docs/cookbook/architecture.md:210-211 says the hard budget is never to be exceeded.
    • If the process running try_run/3 dies between start_fun and admit (lib/hyper/node.ex:357-359), nothing stops the VM and it stays unreserved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Fields

    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions