Repository navigation
Preview: find the session by its home name, try every place for a program, and log why it could not be reached - #175
Merged
Conversation
…ot reach it previewDialer chose ONE place for every port: a single unsandboxed process in the server's own network (an admin's terminal opened in the workspace, a helper) sent every port to the machine's real network, where the program of a sandboxed REPL is not and, on a worker, the site itself listens on 8080. Now each place is tried in turn and the first that connects wins: the namespace of each REPL that has one, then the emulation's socket, then the real network (only for an unsandboxed process, never the site's own port). A Preview that fails left no word in the log (502 on every port after a session moved to a worker, seen in a gateway and a worker log). It now logs, at most once in 30 seconds for a workspace and port, the processes found (with their network and sandbox state), each attempt and how it ended, and whether the emulation is on. The facts the dialer asks of /proc and the namespaces are behind previewProc, which the tests replace: an unsandboxed process does not hide an emulated program, and a program in another namespace is reached before the real network. LLD 17. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The session registry names a home by its directory name (donadjdc, Config.HomeOf); the Preview's token and the route table carry the path (/home/openrepl/donadjdc). homeBackend asked the registry for the path only, never found the session and fell back to the stale route, so after a session moved back to the gateway the Preview still went to the worker (reproduced on a local gateway and worker: the worker answered 'no process of donadjdc was found'). It now asks for the path and for its base name. The test uses the registry's real naming and fails without the fix. LLD 17. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Problem (critical)
After a session moved to a worker and back to the gateway, the Preview answered 502 on every port. Reproduced on a local gateway and worker (logs attached by the reporter).
Cause found with the new logging
gateway/router.go). PR 174 made the gateway ask the session registry where the session runs, but the registry names a home by its directory name (donadjdc,Config.HomeOf) while the Preview's token and the route table carry the path (/home/openrepl/donadjdc).homeBackendasked for the path only, never found the session and fell back to the stale route, so the Preview still went to the worker (the worker answeredno process of donadjdc was found). It now asks for the path and for its base name. The test uses the registry's real naming and fails without the fix.server/preview.go).previewDialerchose ONE place for every port: one unsandboxed process in the server's own network sent every port to the real network. It now tries each place in turn (the namespace of each REPL that has one, the emulation's socket, then the real network for an unsandboxed process, never the site's own port).Tests
TestThePreviewFollowsTheSessionWhenItMovedAndTheRouteIsStale(registry naming as in production),TestAnUnsandboxedProcessDoesNotHideAnEmulatedProgram,TestAProgramInAnotherNamespaceIsReachedBeforeTheRealNetwork.gateway,serverandlivepreviewGo tests pass. LLD 17.Notes
A program does not move with the session: after a move, start the server again in the new terminal. Not tried on a worker with real cgroup namespaces (the dev container lacks CAP_SYS_ADMIN).
🤖 Generated with Claude Code