AWS NIC creation retries forever when an untracked ENI holds the selected IP
When AWS gives the IP that Ubicloud selected for a new NIC to an ENI that Ubicloud does not track, Prog::Vnet::Aws::NicNexus#create_network_interface retries the same IP forever. The VM stays in start and the resource never becomes ready.
Where it occurred
AWS E2E run 36000402127, attempt 1. The postgres_ubuntu_2604 test waited 64 minutes in wait_postgres_resource, and then the job's 70 minute timeout stopped it. The rerun of the same commit passed, so the failure is random.
- NIC strand
ncy81ezzkf7a4jhe4ryad5h7ge, IP10.19.2.66,use_eip: true. This is the normal path, where Ubicloud creates the ENI. - From its first try at 12:41:07 until the job stopped (try 22), every run failed with:
No available network interface found for IP 10.19.2.66 - The GuardDuty VPC endpoint for the same VPC was created at 12:41:02–05, 2 to 5 seconds before the first try.
- Deadline pages were created for the NIC (12:46) and the VM (12:50). Nothing else changed.
What happens
NicNexus.allocate_ipv4_from_aws_subnetselects a random IP in the AWS subnet. It only compares the IP with the NICs in our database (subnet.nics). It does not know about ENIs that AWS creates in the subnet.create_network_interfacecallsCreateNetworkInterfacewith that IP. AWS returnsInvalidIPAddressInUse.- The rescue looks for an ENI with that IP in status
available, which covers our own retry after a lost response. Here the ENI that holds the IP isin-use, so the search finds nothing and the label fails. - The strand retries with the same IP, so it can never succeed.
Probable cause
The interface VPC endpoint for GuardDuty (Vnet::Aws::VpcNexus#create_guardduty_endpoint, when aws_cloudwatch_logs is set) puts one ENI in each AWS subnet, and AWS gives each of those ENIs a random IP. If an endpoint ENI takes the IP that we selected, the collision above occurs. I could not confirm which ENI held 10.19.2.66, because the E2E cleanup deleted the resources. CloudTrail in the E2E account has the CreateVpcEndpoint and network interface events for that time.
Any other ENI that AWS or a person creates in our subnets can cause the same problem.
Possible fixes
- Preferred: When
InvalidIPAddressInUseoccurs and noavailableENI has the IP, select a new IP (allocate_ipv4_from_aws_subnet), update the NIC'sprivate_ipv4, and try again. A lost response on our own retry still uses the current path, because the ENI isavailablethen. - Also compare the new IP with the IPs of the ENIs that are in the AWS subnet (
DescribeNetworkInterfaceswith asubnet-idfilter) before we use it. This makes the collision less probable, but it cannot prevent a race with an ENI that is created later.
Source: ubicloud/ubicloud