simplify(#2363): drop remap, shrink modulus to exclude DHCP pool

No need to preserve agent IPs across this deploy — nothing outside a
container depends on a specific agent IP.  Simpler approach: subtract
DHCP_POOL_SIZE from the usable count before hashing so agents only ever
land in [2, usable - DHCP_POOL_SIZE + 1], never in the DHCP pool.

Removes the secondary-hash remap block (~10 lines).  Returns None for
subnets too small to hold both agent slots and the pool (edge case;
practical subnets are /24).
This commit is contained in:
atlas 2026-07-13 11:01:16 +02:00 committed by mara
commit 9396918ffb
2 changed files with 21 additions and 29 deletions

View file

@ -40,10 +40,10 @@ async fn setup_proposed_seeds_flake_nix() {
#[test]
fn agent_network_ip_is_in_subnet() {
// Default subnet 10.42.0.0/24 — agents get .2 to .240 (last 14 are DHCP pool).
// agent_slots = usable(253) - DHCP_POOL_SIZE(14) = 239 → offsets in [2, 240].
let ip = agent_network_ip("alice", "10.42.0.0/24").expect("should produce an IP");
let octets: Vec<u8> = ip.split('.').map(|o| o.parse().unwrap()).collect();
assert_eq!(&octets[..3], &[10, 42, 0], "wrong /24 prefix");
// usable=253, dhcp_start=241 → agent range is .2-.240
assert!(
octets[3] >= 2 && octets[3] <= 240,
"host byte {} — expected in agent-only range [2,240]",
@ -55,6 +55,7 @@ fn agent_network_ip_is_in_subnet() {
fn agent_network_ip_never_in_dhcp_pool() {
// No agent should be assigned an address in the DHCP pool
// (.241-.254 on a /24 with DHCP_POOL_SIZE=14).
// agent_slots = usable(253) - DHCP_POOL_SIZE(14) = 239 → offsets in [2, 240].
let subnet = "10.42.0.0/24";
let names = [
"alice",
@ -79,7 +80,6 @@ fn agent_network_ip_never_in_dhcp_pool() {
for name in names {
let ip = agent_network_ip(name, subnet).unwrap_or_else(|| panic!("{name} returned None"));
let last: u8 = ip.rsplit('.').next().unwrap().parse().unwrap();
// dhcp_start_offset = usable(253) + 2 - DHCP_POOL_SIZE(14) = 241
assert!(
last < 241,
"{name} got .{last} — inside the DHCP pool [.241-.254]"