Files
floci/src/test/java
Allen Sanborn d726533659 fix(ec2): return the network interface association in DescribeInstances (#6872)
* fix(ec2): publish a container instance's public address before it reports running

The launch worker flipped the instance to running and only then exposed its public
address, so a DescribeInstances poll in between saw a running instance with no public
IP. Terraform's wait-for-running reads exactly that. The restart paths already expose the
address before the state flips; the first launch now does the same. If exposing throws,
the existing catch fails the launch, so the instance is not left pending. A launch
cancelled after the address was published clears it in failLaunch.

* fix(ec2): report the public address as the primary interface association in DescribeInstances

DescribeInstances omitted networkInterfaceSet.item.association, which the Terraform
provider reads to set associate_public_ip_address, so the attribute drifted and forced
replacement on every plan. The association comes from the Elastic IP on the primary
private address when there is one (owned by the interface owner, as DescribeNetworkInterfaces
shows it), otherwise from the automatic address (owner amazon). Other interfaces carry none.

* test(ec2): explicit types, imports and assertNull in the public address and container manager tests

* perf(ec2): read the Elastic IPs once per DescribeInstances and RunInstances response

The primary interface association looked up the instance's Elastic IP by
scanning the address store, once per rendered instance. Index the region's
associated addresses by instance id and interface id once per response and
look each instance up in the index; single-instance callers build their own.

* fix(ec2): check an indexed Elastic IP still belongs to the instance before showing it

The per-response address index holds the live Address objects, which
AssociateAddress and DisassociateAddress change in place. An address
disassociated or moved to another instance after the index was read still
sat under its former owner's key, so that instance showed an association it
no longer had. The lookup now checks the address's owner and association
again, as the per-instance scan did.

* test(ec2): an indexed Elastic IP still held is shown, and a moved one is not

The stale-index test only asserted what must not be shown, so a lookup that
refused every address passed it. It now also checks that an instance still
holding the Elastic IP shows its allocation, association and public IP, and
pins the known limit for the new owner of a moved address: its public
address shows as an automatic one. The association copy is checked once
more, so a disassociation between lookup and copy shows the instance's own
address rather than an association with no id.
2026-10-28 20:17:28 -04:00
..