fix(gateway): proxy sandbox-routed envd metrics requests - #159
fix(gateway): proxy sandbox-routed envd metrics requests#159feimingxliu wants to merge 1 commit into
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s). |
|
Live validation completed on a single-node x86_64 PVM k3s environment using a test-only Gateway image built from commit Results against a real running sandbox: The routed response was the envd JSON payload and included The Gateway rollout completed with 1/1 Ready and zero restarts. Scheduler and runtime workloads were not changed. The temporary sandbox was deleted after validation, and no Gateway warning/error logs were observed. |
|
@guozy18 Could you please take a look? It seems that the related code was originally written by you. |
What
/metricsrequests carrying sandbox routing headers to follow the existing Gateway -> runtime node -> sandbox proxy path./metricsto the selected sandbox port./metricsunavailable on the Gateway public HTTP listener./metricsrequests in Gateway HTTP instrumentation while continuing to skip the local reserved endpoint.Why
The Gateway currently returns 404 for every exact
/metricsrequest before it parses host routing, sandbox headers, or scheduler bindings. This blocks the existing envdGET /metricsendpoint even when the caller supplies a valid sandbox ID and target port.The runtime node proxy already supports the remaining path: the Gateway prefixes the request as
/proxy/metrics, and the node strips/proxybefore forwarding it to the sandbox interaction IP and requested port.Related issue
Closes #151
Related but not equivalent: #5 tracks the unimplemented E2B sandbox metrics API. This PR only fixes generic proxy access to the existing raw envd endpoint.
Scope and non-goals
Included:
/healthand/metricsreserved paths./metrics.Not included:
GET /sandboxes/{sandboxID}/metricsor aggregate sandbox metrics endpoints.Design and behavior changes
For exact
/healthand/metrics, the Gateway now resolves the routing boundary before choosing local behavior:A routing header set that omits the sandbox ID continues to return 400. Invalid host-based routes continue through the existing proxy error mapping.
Gateway Prometheus metrics remain on the separate metrics listener, default
:9102; this PR does not expose them from the public HTTP listener.Compatibility and operations
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
Skipped checks and reasons:
/metricsconform to that contract.Risks and reviewer notes
The main compatibility boundary is preserving the reserved local endpoints. Tests verify:
/healthand/metricsreach/proxy/healthand/proxy/metricson the selected runtime node;/healthand/metricsinject the sandbox ID and target port;/metricsremains 404;/healthand/metricsremain 400;/healthand/metricsbypass Gateway HTTP instrumentation.Checklist