refactor(firecracker): single-source the network-pool defaults #350
Reference in New Issue
Block a user
Delete Branch "netpool-single-source"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The pool params (size / IP base / iface prefix / nft table) were triplicated across
netpool.py,scripts/firecracker-netpool.sh, andnix/firecracker-netpool.nix, plus the IP math (3×) and the nft ruleset (2×) — coupled only by hand + "must match" comments. Changing the base off CGNAT (ce3fad9) forced a coordinated three-file edit; a missed one would silently provision a range the launcher doesn't expect.One source of truth:
bot_bottle/backend/firecracker/netpool.defaults.env(plainKEY=VALUE: bash-sourceable, systemdEnvironmentFile-compatible, Python/Nix-parseable).netpool.pyreads it for defaults (missing file → hard error).:-8/10.243.0.0);upis now non-destructive/idempotent so re-running never cuts a live VM.readFile-parses it for option defaults and delegates bring-up to the same shell script — dropping its duplicate IP math, nft ruleset, and TAP loop, passing every value asEnvironment=.Net: defaults 3×→1×, nft ruleset 2×→1×, TAP loop 2×→1×. Tests now guard the invariant (Python reads the shared file; script/module hold no literals) instead of pinning duplicated strings. Nix parse-checked; unit tests green (the
/bin/sleeptest_sidecar_initerrors are pre-existing NixOS-local noise).🤖 Generated with Claude Code
3cde6eb3dato2b970d1170