mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
Adds EcsCredentialsProxy, which launches one small socat container per Docker network, on first use, holding the address AWS SDKs hardcode for container credentials and forwarding to EcsTaskRoleCredentialsServer over host.docker.internal. Reuses the same floci/network-helper:local image and build-on-first-use logic as security-group enforcement (now factored into LocallyBuiltHelperImage, shared by both). Docker accepts a link-local address request even when the runtime then drops it (the review discussion on #4063), so the bind is never trusted from the API call alone: after start, an actual HTTP round trip through the address, socat, and to the real server is required before the proxy is considered ready, not just that the address shows up on the interface. A prior version of this checked only the interface, which has a real race between the address appearing and socat finishing its bind; the end-to-end check is what catches both that and a genuinely dropped LinkLocalIPs. Proven against a real Docker daemon: a plain container with its own 169.254.0.0/16 address (what the follow-up EcsContainerManager wiring gives each task container) fetches real credentials through the proxy end to end. That same test corrects an assumption from earlier discussion: a task container needs an address in that range to reach the proxy at all. Without one, its routing table has no connected route for 169.254.0.0/16, so the kernel routes toward the default gateway instead of resolving the peer directly, and the connection is refused before it reaches the proxy's socket, the same symptom a completely absent listener produces. This is exactly why the original design in #2987 gave every task container its own link-local address; that part of the design was right. EmulatorLifecycle now starts and stops the credentials server, and runs the session sweep, gated on the same enabled() flag: previously the flag did nothing at all, since nothing in main called it after three merged PRs. EcsCredentialsProxy also implements ContainerTeardown, so its proxy containers are removed on shutdown and on /state/reset instead of outliving either indefinitely. Full task wiring (EcsContainerManager actually issuing credentials and giving task containers their own link-local address) is still a separate follow-up.