Repository navigation
feat(runners): the callback proxy — the proxy sidecar, the host runner relay and the gateway proxy route (task #216, 8b) - #677
Conversation
Signed-off-by: Alex <[email protected]>
…ask #216) Signed-off-by: Alex <[email protected]>
…s' telemetry (task #216) Signed-off-by: Alex <[email protected]>
…adapter's shared state directory (task #216) Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…task #216) Signed-off-by: Alex <[email protected]>
… path alone (task #216) Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
There was a problem hiding this comment.
Changes requested, with 2 [Must] items, both inline:
runner/internal/proxy/host.go:69:OpenSocketdeletes the bind-mounted socket directory, so a host-runner restart cuts the running sidecars off from their relay.runner/internal/proxy/proxy.go:90: the relay's prefix check lets dot segments through, with the machine's bearer token attached.
The rest is in line with the task's decisions and the project's conventions. That covers the callback URL seam at every call site, the allow-list, the key-to-holder check, no body schema, the docs and the fixtures. There are also 1 [Recommendation] and 2 [Note] comments inline.
…bound body reads (task #216) - OpenSocket keeps the session's socket directory across a restart and replaces only relay.sock, so a running sidecar's bind mount reaches it. - The relay refuses empty, . and .. segments after decoding, and an encoded / or a backslash, as not_proxied. - Resume stops the agent's container when a relay or a network: host listener cannot be served again, so the session fails. - The relay and the sidecar read a request body within 30 s (408 body_timeout); the answer stays unbounded. Signed-off-by: Alex <[email protected]>
…s in the gateway proxy (task #216) - Drop the headers a Connection header nominates, on requests and answers. - Release the Active Record connection before the forward. - Rescue ClientDisconnected, close the stream and log at info. - One MCP key lookup (MCP::SessionKey.lookup) for MCPController and Runners::Proxy, and each key's header as its SessionKey module's HEADER. - Say why the assets route is safe only on dev-only filesystem storage, and how proxied calls take gateway threads. Signed-off-by: Alex <[email protected]>
…time (task #216) callbacks: and otel_endpoint: are required, and the adapters no longer fall back to the hosted values. Callers that mean hosted pass them explicitly. Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…ll (task #216) After a failed body read the read deadline stays, so the server's drain of the unread body fails at once and the 408 goes out. The sidecar opens a connection to the relay socket per call, so a replaced relay is reached on the next call. Signed-off-by: Alex <[email protected]>
…cket (task #216) Signed-off-by: Alex <[email protected]>
…g it (task #216) Signed-off-by: Alex <[email protected]>
…#216) Signed-off-by: Alex <[email protected]>
…t the streaming test's limit (task #216) Signed-off-by: Alex <[email protected]>
) Signed-off-by: Alex <[email protected]>
…-callback-proxy Resolved per Alex's decisions (task #216, comment 72539): - PROTOCOL.md: develop keeps §5.6 (releases) and §5.7 (checksums); the callback proxy becomes §5.8, and every reference to it is updated. - HostOptions.Binary has one meaning: the runner's own executable, symlinks resolved, which a self-update replaces and the proxy sidecar runs. One resolver (update.BinaryPath); ownBinary is dropped. - main.go: the host/proxy mode switch, with host still passing NoSelfUpdate. - client.go: develop's do/newRequest and the branch's Proxy with its own non-redirecting client. - conformance_test.go: both harness changes; the protocol-header presence checks apply to the proxy fixtures too. - routes, process-mode route test, fixtures README and DESIGN.md: both sides. Signed-off-by: Alex <[email protected]>
… task #216) # Conflicts: # config/settings.yml
There was a problem hiding this comment.
Code review round 4 at 70ee7094: approved. I reviewed the Fix CR round 3 commits (27963f57, bd4aad58, 50e10e3c, a8f193b6) and the conflict resolutions of the develop merge against Alex's decisions in task #216 (comments 72129 and 72539). I found nothing that needs a review comment. CI passes all 17 checks.
RunHost returned to polling after a failed Environment.Resume, and nothing called Resume again. It now returns the error, a plain failure rather than ExitStop, so systemd (Restart=always) restarts the runner until Docker answers. Signed-off-by: Alex <[email protected]>
sidecarExited read the log tail first, with no deadline of its own, so a stalled logs endpoint could keep the agent running. The agent is stopped first, and the tail is read under SidecarLogTimeout. Resume logs the real exit code of a stopped sidecar that is still there. Signed-off-by: Alex <[email protected]>
A malformed percent escape, or octets that are not UTF-8, in a proxy path are refused as route_not_allowed instead of raising. The controller skips Rails' path parameter encoding check so such a path reaches the allow-list. Signed-off-by: Alex <[email protected]>
An API controller has no ParameterEncoding table of its own, so skip_parameter_encoding needs setup_param_encode first. The gateway test sends malformed triplets through PATH_INFO, since the test client refuses them in a URL. gofmt the Environment struct. Signed-off-by: Alex <[email protected]>
The restart retry through the service manager, the sidecar-exit order and log deadline, and the strict decoding of proxy paths. Signed-off-by: Alex <[email protected]>
There was a problem hiding this comment.
Round 5 (head 81da93f): the three round 4 findings are fixed as Alex decided, and tests cover them. I left one non-blocking [Recommendation] (a raw non-ASCII path segment still gets a 500, and a code comment's claim about the Go relay is inaccurate). No [Must] findings.
- watchSidecar: a wait result with an error is a failed wait; inspect and wait again - the host runner narrows its state directory to 0700 at start, or needs an operator - the relay logs the route without the query, and a transport failure without its URL - settings_problems refuses a host port range that includes an image port - Route#allows? refuses a raw octet outside ASCII as route_not_allowed Signed-off-by: Alex <[email protected]>
Signed-off-by: Alex <[email protected]>
…s-0-1-0 * origin/develop: feat(coder): clone GitLab, Bitbucket and Azure DevOps repos in coder_prepare_repo (#703) fix(agents): show each runtime's own logo everywhere (#704) feat(teams): assign cards to a team and run triggers as a team (#701) feat(agents): collect the Copilot CLI transcript as a session log (#700) fix(agents): keep Grok and Antigravity conversations in the terminal scrollback (#698) feat(billing): redesign the Billing tab around active and previous subscriptions (#646) feat(web): switch the UI, admin, public pages and emails to Inter (#699) chore(deps): weekly dependency batch — aws-sdk-core 3.267 retry fix, prism 2, Mantine 9.7.5, runner Go 1.27.4 (#697) fix(board): leave archived tasks out of agent board listings (#690) feat(agents): add GitHub Copilot CLI as an agent runtime (#684) feat(runners): the callback proxy — the proxy sidecar, the host runner relay and the gateway proxy route (task #216, 8b) (#677) Signed-off-by: Rozhnov Alexandr <[email protected]>
Conflicts were between staging's feature-branch merges of #677, #684 and an earlier head of #689 and develop's squash-merges of #677/#684 (plus #700, #704). Each hunk takes develop's side (the final, reviewed version), except config/settings.yml, which keeps the runners.release block of #689, and CHANGELOG.md, which keeps both sides' entries. Staging-only content (#494) merged without conflict and is kept.
Summary
Task #216, row 8b of the external runners design (
docs/design/agent-runtimes/DESIGN.md§6.6, §6.9.3, §15): the callback proxy. An agent on amanualrunner can now reach MCP (finish_sessionincluded), the agent credential sync and refresh, git credentials (GitHub, GitLab, Bitbucket, Azure DevOps), cloud credentials and stored files through a proxy on127.0.0.1next to it. Before this, a runner session started but could not call the platform.Go (
runner/)aixle-runner --mode proxyis the sidecar (internal/proxy.RunSidecar). It is a reverse proxy on127.0.0.1:7690that relays to the host runner's Unix socket and holds no credential.proxy.Relay, served byproxy.Host) has a socket per session in<state dir>/proxy/<session>/, mounted read-only into that session's sidecar only. It serves/runner/v1/proxy/*and nothing else (404 not_proxied). It drops the agent'sAuthorizationandX-Aixle-Runner-*headers, adds the machine's access token, refreshes once oninvalid_token, and streams the answer back chunk by chunk.container.startopens the relay, then creates the sidecar from the agent image, with the host runner's own binary bind-mounted read-only as its entrypoint. The sidecar runs as65534:65534with every capability dropped,no-new-privilegesand a read-only root filesystem. The agent container then joins the sidecar's network namespace (NetworkMode: container:<sidecar>).network: hostno sidecar is created. The host runner listens on the payload'sproxy_porton the machine's127.0.0.1instead.container.stopremoves the agent's container, then the sidecar, and closes the relay.env.scrubandenv.resetremove sidecars along with the environment's other containers and close every relay. A restarted host runner serves the running sidecars again (Environment.Resume).container.startfails withdocker_files_not_visible. The message names the paths and the cause (a remoteDOCKER_HOST, or a daemon that runs elsewhere).gatewayOnlywith a reason. No fixture is on that list.Platform
ANY /runner/v1/proxy/:route/*(RunnerGateway::V1::ProxiesController) checks, in order:Runners::Proxy::ROUTES, decision 7; there is no OTLP route yet);Runners::Proxy.holder).X-Aixle-Runner-Environmentadded. The answer is streamed back withActionController::Live.X-Aixle-Runner-Refusal, so the runner can tell the gateway's own refusals from the endpoint's answers.runtime.callback_url(name, session)(ContainerRuntime::CallbackUrls). Hosted runtimes return theSettingsvalue unchanged.RunnerRuntimereturnshttp://127.0.0.1:<port>/<route>.ContainerAssetUrlnow supports a host with a path),read_tool_result, and the OTLP endpoint of the agent configs.RunnerRuntimedoes no string replacement.[otel]block, and Kiro getsKIRO_DISABLE_TELEMETRY, because without an endpoint its export falls back to the vendor's collector.Docs
runner/protocol/PROTOCOL.md§5.6 describes the proxy: route, port, socket, headers, refusals, and no body schema. §6.2 and §6.4 describe the changedcontainer.start,container.stopand scrub. The fixtures are infixtures/v1/proxy/, with the new setup stepssession_holds_machineandupstream_answers.DESIGN.md: row 8b is marked done, §6.6, §6.9.3 and §12.3 now match the code, and the OTLP route is listed as deferred.For review
network: hostport is per session, not per environment. It is20000 + session id mod 10000, sent asproxy_port. The strategy builds the container's environment before the session takes a machine, so the address cannot depend on the machine. If twonetwork: hostsessions on one machine collide on the port, the second fails withproxy_port_in_use.localadapter now keeps its binary and state inRUNNER_LOCAL_DIR(default/tmp/aixle-runner-local), a host directory mounted at the same path, so the daemon can resolve the sidecar's bind mounts. A machine registered before this change must runbin/runner-local registeragain.network: host, the local adapter's listener runs in web's network namespace, not the machine's, so that case needs a real machine.Related issues
Board task #216 (Runners 8b).
Type of change
How was this tested?
gofmt -l .,go vet ./...,go test -race -count=1 ./...and the linux/amd64 and arm64 builds all passed. New tests are ininternal/proxy/proxy_test.goandinternal/docker/proxy_test.go; the conformance test was extended.test/integration/runner_gateway_proxy_test.rb,test/services/runners/proxy_test.rbandtest/services/container_runtime/callback_urls_test.rb. The §12.3 hosted-unchanged test, the strategy, adapter,ContainerAssetUrland conformance tests were extended.65534:65534with a read-only root filesystem and every capability dropped, with the socket directory mounted read-only. A container that joined its network namespace reached the relay through127.0.0.1:7690, and the path, query, escaping, headers and body arrived unchanged.Checklist
git commit -s).organization has executed the Corporate CLA.
make check_allpasses locally (tests, rubocop, brakeman, eslint, typescript).[Unreleased]in CHANGELOG.md. (No entry: external runners are behind theexternal_runnersflag, and the earlier runner tasks added none either.)