fix: stop publishing ~420 service ports to the host by default - #7
Merged
Merged
Conversation
Every container published the full ECR/EKS/ElastiCache/OpenSearch/RDS proxy port ranges (~500 host ports with 4566), which made startup slow and intermittently hung it forever: Docker Desktop would start the container but never materialize the port mappings, so the health-check wait timed out. Running `go test ./...` (six packages in parallel, each starting its own container) made the failure near-certain. Gate each range behind an opt-in flag, mirroring the existing LambdaConfig.ExposeRuntimePorts pattern: - EcrConfig.ExposeRegistryPorts - EksConfig.ExposeApiServerPorts - ElastiCacheConfig.ExposeProxyPorts - OpenSearchConfig.ExposeProxyPorts - RdsConfig.ExposeProxyPorts By default only the edge port (4566) is published now; container startup drops from 15-20s to under a second, and the full parallel test suite passes consistently (verified with four consecutive `go test ./...` runs).
|
| Filename | Overview |
|---|---|
| floci.go | Rebuilds exposed ports from current configuration state, resolving the previously reported additive opt-out behavior. |
| services.go | Makes the five large service-specific host-port ranges explicitly opt-in. |
| ports_internal_test.go | Verifies exact ranges for every exposure flag and confirms that disabling exposure removes previously added ports. |
Reviews (2): Last reviewed commit: "test: cover each Expose flag publishing ..." | Re-trigger Greptile
The port set was additive, so applying a config with an Expose flag enabled and then re-applying it with the flag disabled left the range published. refreshExposedPorts now resets the set to the edge port and re-derives it from the current configs, making the flags declarative.
Table-driven test asserting that enabling each of the six Expose flags (ECR, EKS, ElastiCache, Lambda, OpenSearch, RDS) publishes exactly the service range plus the edge port.
Contributor
Author
|
@hectorvent Gentle ping, this has been open for about a week. Would appreciate a review when you have a chance 🙏 |
hectorvent
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go test ./...was failing intermittently — container startup would hang until the 120s health-check timeout ("wait until ready: context deadline exceeded"), especially when the six test packages ran in parallel, but sometimes even for a single container.The root cause is that every Floci container published ~500 host ports by default: the edge port (4566) plus the full proxy ranges of ECR (100), EKS (100), ElastiCache (21), OpenSearch (100), and RDS (99), unconditionally. Under this load Docker Desktop intermittently starts the container (it even reports healthy) but never materializes the host port mappings —
NetworkSettings.Portsstays empty — so the wait strategy can never reach the health endpoint. Withgo test ./...running six containers in parallel (~3,000 port forwards requested at once), failure was near-certain.Changes
false), mirroring the existingLambdaConfig.ExposeRuntimePortspattern:EcrConfig.ExposeRegistryPortsEksConfig.ExposeApiServerPortsElastiCacheConfig.ExposeProxyPortsOpenSearchConfig.ExposeProxyPortsRdsConfig.ExposeProxyPortsrefreshExposedPortsnow rebuilds the exposed-port set from the current configs instead of only adding to it, so re-applying a config with a flag turned off also removes the previously added range (addresses review feedback).ports_internal_test.go) asserting that each of the six Expose flags publishes exactly its service range plus the edge port, and that opt-out removes previously added ports.By default only port 4566 is published now. Container startup drops from 15–20s to under a second.
Breaking change
Code that connects to ECR/EKS/ElastiCache/OpenSearch/RDS proxy ports from the host (e.g. via
GetMappedPort) must now set the correspondingExpose…Portsflag. In-container access (Lambda handlers, service-to-service) is unaffected.Test plan
go test ./...runs, all packages green, 1–3s per package.go build ./...andgo vet ./...pass.