Repository navigation
Fix Envoy isolated-server readiness and enable e2e tests - #5926
Conversation
3f79384 to
8581a2d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5926 +/- ##
==========================================
- Coverage 71.67% 71.65% -0.03%
==========================================
Files 700 700
Lines 71923 71916 -7
==========================================
- Hits 51551 51529 -22
- Misses 16678 16692 +14
- Partials 3694 3695 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Creating the Envoy container in SetupEgress (before createMcpContainer) caused the STRICT_DNS ingress cluster to probe the MCP hostname before the container existed. On Linux Docker Engine this resulted in a cached negative DNS response that prevented the ingress from ever connecting, leaving the server stuck in "starting" past the readiness window. Move all Envoy container creation to SetupIngress (after the MCP container exists) so the STRICT_DNS cluster resolves the upstream hostname on its first probe. SetupEgress now only computes and returns the proxy env vars — the container name is deterministic, so no state needs to be threaded through egressResult. Remove the now-unused egressResult.ingressPort field and update the orchestration test. Also remove the BeforeEach(Skip(...)) guard from the Envoy e2e suite so the tests run now that the readiness issue is resolved. Closes #5922. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The Envoy e2e tests were timing out on Linux CI because the Envoy distroless image (~47MB) was being pulled cold inside the 120s readiness window. Pre-pull it in the proxy shard's image setup step alongside the other proxy-suite images. Raise the WaitForMCPServer timeout to 180s as a safety margin for any remaining startup variability. Closes #5922. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
8581a2d to
ccf886b
Compare
ccf886b to
7d8fd98
Compare
The Envoy STRICT_DNS ingress cluster resolves the MCP container's hostname before forwarding inbound traffic. On Linux Docker Engine, the default bridge DNS (127.0.0.11) cannot resolve names from custom internal networks, so resolution fails and the ingress never connects to the MCP upstream. Fix: pass the dnsmasq container's IP (already used by the MCP container as additionalDNS) into a new DNSServers field on proxySpec, and set it as the Envoy container's DNS server via HostConfig.DNS. Dnsmasq serves all names on the internal Docker network, so the STRICT_DNS cluster can now resolve the MCP container hostname. Closes #5922. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The writeEnvoyBootstrap function wrote the config file at 0o600, which prevented the Envoy distroless container (UID 101) from reading its own config when bind-mounted from a host file owned by a different UID. On Linux Docker Engine, strict POSIX permissions apply — the container user cannot read a 0o600 file owned by the runner user. macOS Docker Desktop's VirtioFS layer relaxed these permissions, masking the bug. Change the mode to 0o644. The bootstrap contains only network topology (hostnames, ports, RBAC rules) — no credentials or secrets — so world-readable is safe and necessary. Also add dns_lookup_family: V4_ONLY to the STRICT_DNS ingress cluster to prevent slow AAAA lookup timeouts when IPv6 is unavailable. Closes #5922. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The isolation tests (Squid + Envoy) are slow (60-180s per server) and unrelated to the proxy transport tests (stdio, SSE, OAuth, tunnels). Running them together in the proxy shard meant debugging isolation failures required waiting for all transport tests to complete first. New shard: label_filter=isolation, test_timeout=25m. The proxy shard now excludes isolation tests via "proxy && !isolation". Envoy image pre-pull moves to the network-isolation shard; the time server pre-pull stays in proxy. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The transparent proxy rewrites the Host header to include the port
("127.0.0.1:22354"), but ingressDomains was returning bare hostnames from
Inbound.AllowHost (e.g. "127.0.0.1") without ports. Envoy's virtual host
matching failed, so every initialize request from waitForInitializeSuccess
was rejected — the server never reached running state.
Fix: always return wildcard for the ingress virtual host domain. The
Inbound.AllowHost restriction is already enforced by the 127.0.0.1
host-side port binding, which limits the ingress to local connections only.
The virtual host domain list adds no security value here and breaks the
health check.
Also removes the AllowPort e2e test from this branch (it belongs on #5927).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The 30s fetchThrough context was too tight for the 16s upstream sleep plus MCP client round-trip overhead under CI infrastructure load (38s observed). Increase to 60s so the test proves the Envoy route timeout is disabled without racing against CI slowness. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- DNS injection (dnsmasq as Envoy DNS server) was belt-and-suspenders; Docker's embedded DNS at 127.0.0.11 resolves names for all networks a container is attached to, which covers the internal network where the MCP container lives. Removing it simplifies the code without risk. - Remove the 'Capture Envoy container logs on failure' CI step. Logs are now captured inside the test via DeferCleanup before teardown. - Add --silence-skips to the Ginkgo command. Without it, --label-filter runs all 475 specs but marks ~466 as skipped, flooding CI output. With --silence-skips (Ginkgo v2), only matching specs appear in the log. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
jerm-dro
left a comment
There was a problem hiding this comment.
Approving — the core fix is sound: deferring Envoy container creation to SetupIngress correctly resolves the negative-DNS-cache readiness bug (#5922) and aligns Envoy with Squid's proven two-phase pattern. Inbound AllowHost enforcement is intact (via the RBAC :authority matcher, not the vhost domain list), and orchestration order is unit-tested. Nothing blocks merge.
A handful of nitpick:-level cleanups — all stale comments / strings, no behavior impact:
pkg/container/docker/networkproxy.go(networkProxyinterface docstring) — still says envoy "creates its single dual-listener container here [inSetupEgress] and reserves the ingress port, carried back in theegressResult" and "A consolidated backend returns the port it reserved in SetupEgress." Both are now false, andegressResult.ingressPortis deleted in this PR. Update to the new model: both backends create their ingress container inSetupIngress.pkg/container/docker/envoy.go(buildIngressListenerdocstring, ~line 616) — still says "WhenInbound.AllowHostis set the virtual host domain list is restricted to those entries," butingressDomainsnow always returns a wildcard. Worth noting inbound host filtering is enforced by the RBAC:authoritymatcher (hostMatchRegex) so the two paths aren't confused.pkg/container/docker/envoy.go(buildIngressCluster, ~line 688) —DnsLookupFamily: V4_ONLYis load-bearing for the IPv6-latency rationale but has no test assertion; a regression dropping it would fail silently. Consider assertingdns_lookup_family: V4_ONLYin the ingress-cluster test.pkg/container/docker/envoy_test.go(TestEnvoyProxy_SetupOrchestrationheader, ~line 743) — comment describes pre-PR behavior ("the egress container is always created" framed aroundSetupEgress), the opposite of what the body now asserts.test/e2e/network_isolation_envoy_test.go(line 89) — timeout raised to 180s but the failure message still reads "should be running within 120 seconds."
- networkproxy.go interface docstring: update SetupEgress/SetupIngress comments to reflect the current model where both backends create their ingress container in SetupIngress (not in SetupEgress as was the case before the negative-DNS-cache fix). - envoy.go buildIngressListener docstring: replace the stale "Inbound.AllowHost restricts the virtual host domain list" comment with the correct explanation: the domain is always "*"; inbound host filtering uses the egress RBAC :authority matcher, not the ingress vhost list. - envoy_test.go TestBuildIngressCluster_UpstreamAddress: add an assertion for DnsLookupFamily="V4_ONLY" so a silent regression dropping it would be caught. - envoy_test.go TestEnvoyProxy_SetupOrchestration header: rewrite to describe the current behaviour (SetupEgress returns env vars only; SetupIngress creates the container). - network_isolation_envoy_test.go: fix stale "120 seconds" in the WaitForMCPServer failure message to match the 180s timeout. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
* Translate AllowPort into Envoy egress RBAC policy (#5915) Squid enforces AllowPort via the allowed_ports ACL, AND-d with AllowHost. The Envoy backend previously ignored AllowPort, leaving allowlisted hosts reachable on any port — a parity regression. Translate AllowPort into :authority suffix matchers (":80", ":443", …) in the RBAC ALLOW filter, mirroring Squid's AND semantics: - AllowHost + AllowPort → host AND port must match in the same policy - AllowPort only → any host on listed ports - AllowHost only → any port (unchanged) - InsecureAllowAll → ignores AllowPort (same as Squid) Uses :authority suffix matching so plain HTTP ("host:port") and HTTPS CONNECT ("host:port") are both covered. Remove the Known Limitation entry and add a parity row to the comparison table. Closes #5915. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Add e2e test for AllowPort enforcement via real Envoy Exercises the AllowPort fix end-to-end: starts an Envoy isolated server with AllowHost:[example.com] + AllowPort:[443], then asserts that https://example.com succeeds and http://example.com is blocked. This closes the gap between unit tests (which verify the config shape) and runtime behaviour through a real Envoy container. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Address review nitpicks from #5926 - networkproxy.go interface docstring: update SetupEgress/SetupIngress comments to reflect the current model where both backends create their ingress container in SetupIngress (not in SetupEgress as was the case before the negative-DNS-cache fix). - envoy.go buildIngressListener docstring: replace the stale "Inbound.AllowHost restricts the virtual host domain list" comment with the correct explanation: the domain is always "*"; inbound host filtering uses the egress RBAC :authority matcher, not the ingress vhost list. - envoy_test.go TestBuildIngressCluster_UpstreamAddress: add an assertion for DnsLookupFamily="V4_ONLY" so a silent regression dropping it would be caught. - envoy_test.go TestEnvoyProxy_SetupOrchestration header: rewrite to describe the current behaviour (SetupEgress returns env vars only; SetupIngress creates the container). - network_isolation_envoy_test.go: fix stale "120 seconds" in the WaitForMCPServer failure message to match the 180s timeout. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Address review findings F2-F10 and fix Ginkgo CLI version mismatch F2: networkproxy.go docstrings now accurately describe that Envoy creates no container in SetupEgress; both listeners land in one container created in SetupIngress. F3/F5: document the plain-HTTP AllowPort divergence from Squid in both the arch comparison table and the buildAllowlistPolicies function comment. F6: extract authorityAllowed closure into a package-level listenerAllowsAuthority helper so test assertions don't hide behind a reimplemented matcher. F7: add TestBuildAllowlistPolicies_AllowPort_Structure (structural shape assertion) and TestBuildAllowlistPolicies_AdditionalCases (multi-port OR, port-less authority divergence). F8: assert deny-before-allow ordering holds under AllowPort-only policy. F9: add comment at the container creation site explaining why the Envoy container retains the -egress name suffix. CI: pin Ginkgo CLI to v2.28.1 (matching go.mod) to eliminate the version mismatch warning that could cause unpredictable test behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Fix F1: plain-HTTP bare-hostname allowed when port 80 is in AllowPort Plain-HTTP requests omit the default port from :authority ("example.com" not "example.com:80"). The previous implementation used a separate port suffix AND-d with the host regex, which failed to match the portless form and over-blocked legitimate traffic — diverging from Squid's allowed_ports ACL which derives the port from the URL. Fix: replace the two-permission AND with a single combined safe_regex per policy that encodes both the host pattern and the port alternatives. When port 80 is in AllowPort the port suffix is made optional so bare hostnames (plain HTTP) are permitted alongside explicit ":80", matching Squid. When port 80 is NOT listed the port suffix is required. The same logic applies to the AllowPort-only case via anyHostPortRegex. Updates tests to reflect the new behaviour (F7b now asserts Squid parity rather than documenting a known divergence), structural assertion (F6), and arch doc comparison table. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * Address re-review findings N1-N4 N1: Extract portGroupRegex and hostBasePattern helpers to eliminate the duplicated port-alternation and host-escaping logic across hostPortMatchRegex, anyHostPortRegex, and hostMatchRegex. A future change to port encoding or subdomain anchoring now needs to be made in one place. N2: Replace the weak assert.Contains(re,"?") structural assertion with behavioural assertions that compile and evaluate the actual regex — bare hostname must match, explicit ports must match, non-listed ports and wrong hosts must not. The previous assertion was vacuous because "?" appears in non-capturing groups unrelated to the port-optional logic. N3: Add a TestBuildAllowlistPolicies_AdditionalCases subtest for AllowPort-only with port 443 (no port 80), exercising the includes80=false branch of anyHostPortRegex: bare hostname denied, explicit :443 allowed, :80 denied. N4: Add a wildcard AllowHost + AllowPort subtest (.example.com) to exercise the subdomain (.*\.)? path in hostPortMatchRegex, guarding against a bug in the wildcard+port combination going undetected. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes the Envoy network proxy's startup failure on Linux Docker Engine (#5922) and enables the Envoy e2e tests that were previously skipped.
Closes #5922. Part of #5900.
Root cause and fix
The Envoy container was created in
SetupEgress, beforecreateMcpContainer. The Envoy container's ingress listener uses aSTRICT_DNScluster pointing at the MCP container by hostname. On Linux Docker Engine, probing before the MCP container existed produced a cached negative DNS response — the ingress never recovered, leaving the server stuck instartingpast the 120s readiness window.Fix: move all Envoy container creation to
SetupIngress(aftercreateMcpContainer).SetupEgressnow only computes and returns the proxy env vars. The container name is deterministic (<name>-egress), so no state needs threading throughegressResult. TheegressResult.ingressPortfield is removed as no longer needed.Also removes the
BeforeEach(Skip(...))guard fromnetwork_isolation_envoy_test.go.Files changed
envoy.go—SetupEgressreturns env vars only;SetupIngresscreates the containernetworkproxy.go— remove unusedegressResult.ingressPortfieldenvoy_test.go— update orchestration test: container created inSetupIngress, notSetupEgressnetwork_isolation_envoy_test.go— remove skip guardType of change
Test plan
go build ./pkg/container/docker/...passesgolangci-lintcleanTestEnvoyProxy_SetupOrchestrationupdated and passingGenerated with Claude Code