mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
* fix(ec2): allocate endpoint IPv4 addresses within the subnet prefix Interface endpoint ENIs kept the subnet CIDR's first three octets and picked a host of 200..249 from the endpoint id, ignoring the prefix length. Two /25s inside one /24 got the same address, and the lower one landed outside its own subnet; smaller subnets could also get reserved or out-of-range addresses. Derive the address from the subnet's parsed network and prefix: only offsets AWS lets a resource hold (skipping the first four and the last address) are candidates, the preferred one stays 200..249 for blocks of 256 addresses or more and moves to the top of the usable range for smaller ones, and the range is probed in subnet order past addresses the endpoint already holds (pinned ones first). Interface endpoints are refused with InsufficientFreeAddressesInSubnet in a subnet with no assignable address. Fixes #5384 * fix(ec2): keep endpoint reads working for undersized subnets and avoid instance IP collisions Deriving an interface endpoint's address threw InsufficientFreeAddressesInSubnet when its subnet had no usable address, which an endpoint stored before CreateVpcEndpoint refused such subnets can still hit. The derivation runs on every read, so one such endpoint broke DescribeNetworkInterfaces for the whole region. A subnet with nothing left for the interface now degrades it to the synthetic fallback address instead; create and modify still refuse new ones. Endpoint interfaces are derived rather than stored, so the instance allocator never saw them and, in a /28, both could land on the same address. The derivation now also skips addresses persisted ENIs, instances and NAT gateways hold in the subnet (the allocator's own in-use scan), and the allocator treats derived endpoint addresses as taken. The derivation reads only persisted state, so the two cannot recurse, and the regional enumeration scans each subnet once.