Files
floci/src/test/java/io/github/hectorvent
Hector Ventura d51a0f9ce8 fix(ec2): prevent SSH port collision on concurrent RunInstances (#721) (#733)
immediately closing a ServerSocket. Between that check and Docker
binding the port, a second concurrent RunInstances call saw the same
port as free — both instances raced to bind 2200 and the second one
failed with "port is already allocated".

Fix: PortAllocator now maintains an in-memory ConcurrentSkipListSet of
reserved ports. allocate() is synchronized and adds the chosen port to
the set before returning, so concurrent callers skip it even before
Docker has bound it. release() removes the entry when the container is
terminated, making the port available for future instances.

Ec2ContainerManager.terminate() now calls portAllocator.release() after
the Docker container is removed.

Add PortAllocatorTest with 5 cases including a concurrency test that
races 20 threads simultaneously to confirm uniqueness.

Fixes #721
2026-05-07 00:37:31 -05:00
..