site preview: serve any generator, leave nothing running, and start a preview in a VM #236
No reviewers
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!236
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/site-preview-generators"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Owner summary
allod site previewworks for a site that is not built with zola. A site whose flake has an app namedpreviewruns that app; a site withconfig.tomlruns zola as before; any other site is built and served as static files byalloditself.allodbeing killed, takes the server down with it and frees the port.allod site preview --vm <name>, run on the machine hosting the VM, starts the preview in the VM and forwards the ports over its own connection.deploy,checkandconfigare untouched.allodbefore zola starts;--portmust be a number; Ctrl-Z does nothing while a preview runs.allod, and check that nothing is left and the port is free, and one that types Ctrl-Z and Ctrl-C through a real terminal.--vmhas never been run against a VM. Only the twosshcommand lines are tested. The manual tests in the issue are still to do, from a hypervisor: page loads, an edit reloads the browser, an interrupt frees the ports on both machines, and the same with the connection dropped.Closes allod/tools#234
What was decided
Where the issue left a choice open:
ALLOD_PREVIEW_PORTandALLOD_PREVIEW_INTERFACE, set on every run, defaults1111and the literal127.0.0.1.--vmlearns which ports to forward: it asks the VM. A new flag,--ports, performs selection and prints the ports without starting anything, and--vmruns that over a first connection. The hypervisor's copy of the site can be stale; the VM's is the one being served. The first port answered must be the one asked for.--forward <port>[,<port>...], repeatable, valid only with--vm.--openis treated as zola's, with--draftsand--base-url: refused by name on the other two kinds, and refused with--vm.--portsanswers the page port and1024for a zola site. Zola 0.23.6 was measured serving live reload on the page port;1024is what 0.21 used when the issue was measured. It stays because a site pinned to an older zola needs it. The cost:--vmrefuses to start when1024is taken on the hypervisor, even for a site whose zola no longer uses it.flake.nixthat cannot be read, is an error naming what failed, never a fall through to zola or static.nixBuildandposixShellQuotemoved out of files carrying a build tag so the untaggedpreviewcan use them; their behavior is unchanged.Risk
R2. The change is local to one command, writes no state, and listens on loopback only. What the tests cannot reach is
--vmend to end, which needs a hypervisor.Known limits:
allodkilled outright (SIGKILL). The kernel signals the server itself (Linux only). A process the server started, and does not take down with it, can survive.allodwaits a bounded time, says so, and exits 8.allodchecking a port and the server binding it is not closed; a process taking the port in between gets the server's own error, notallod's.Validation
Run by the integrator on
e69f76d, throughnix develop:gofmt -l ./cmd ./internalgo vet ./...,go vet -tags site,secret ./...go test -count=1 ./...go test -count=1 -tags site ./...,-tags secret,-tags site,secretgo test -count=10 -run 'TestPreviewGroup|TestPreviewSuspend|TestPreviewFinalExit' ./cmd/allod/nix build .#checks.x86_64-linux.go-checksNo server or test helper process was left running afterwards.
Reported by the implementing agent and not repeated by the integrator:
nixandcurl. Static: pages served, a missing file and an escaping symlink answered 404, port free after SIGTERM. Zola 0.23.6: page served with the reload script, no zola left and both ports free after an interrupt. Preview app: the app received the port and interface and nothing was left after SIGTERM; its test app sent a malformed response, so a successful page load was not seen for this kind.Not run:
--vmagainst a VM; the dropped-connection case; the skip of the parent-death test off Linux.Review
One cold review by
gpt-5.6-solathigheffort, ofad19b75, followed by one fix round ine69f76d. The reviewer could not run the tests in its sandbox, so every finding was from reading. Two high, seven medium, four low defect findings, and a list of comment findings.site_preview_suspend_linux_test.go--interface ''binds every interface on the static kind-is a missing value.--port -1is now reported that wayflake.nixread as "no flake"go test -racereported nothing--impure,nix runwithoutbuiltins.currentSystemneeds itDecision recorded after the owner asked whether the port and cleanup behaviour should be changed here or later: this PR stays as it is.
The owner's questions were why port
1024is treated as special, how previews avoid colliding on ports, and how to start, stop and interrupt a preview from either machine with nothing left behind. Those are one design, and it replaces how--vmconnects, so it does not belong in a PR that has already had its review and fix round. It is written up as allod/tools#238.What this PR does on those points, unchanged: ports are fixed (
1111, and1024for a zola site) and a taken one is refused by name; a dropped connection is cleaned up in the VM only once the VM's SSH daemon notices; Ctrl-Z is ignored while a preview runs. Each is loud or documented, and none leaves anything behind in the paths the tests cover.Still needed before merge: the manual
--vmruns from a hypervisor listed in the owner summary. Their results are also the baseline allod/tools#238 compares against.Owner request recorded before it is carried out: a comment deletion pass over this PR, then merge.
The pass removes code comments this PR added and changes nothing else. A comment survives only where, without it, a careful reader would plausibly change the code into something wrong, and a survivor is cut to a line or two. Help text and the README are not comments and stay as they are.
How it is checked: the syntax tree of every Go file, with comments and positions left out, is compared before and after the pass and must be identical; then the full test runs are repeated.
The comment deletion pass is pushed as
023bc37. It removes comments this PR added and changes no code.Six comments remain, each a trap a reader could fall into: why the flake root travels in the environment, why the thread is held for the life of the server, why the server takes the terminal before it starts, why the exit state is read through a channel, why the terminal-output stop signal is ignored while taking the terminal back, and why the test cleanup skips a process it already saw exit.
Checked by the integrator on
023bc37:e69f76d.gofmtchanged once a comment between the fields was gone.gofmtprints nothing,go vetis clean, and thecmd/allodtests pass under all four build variants.master.The validation in the PR body was run on
e69f76d; this comment is what covers023bc37. Still not run:--vmagainst a VM.Closing without merging, by the owner's decision. The work is being restarted from a smaller design, and this comment records what went wrong here so the record is not lost with the branch.
What this PR was
About 2,200 added lines for
allod site preview: three ways to serve a site (a flakepreviewapp, zola, a static server built intoallod), supervision of the server as a child process, and--vmwith a port query over one connection and forwards over a second. It passed its tests, one cold review and one fix round.--vmwas never run against a VM.What went wrong
allodstarted the server as a child, so it needed a process group, signal forwarding, a terminal handover, a parent-death signal and a workaround for Ctrl-Z. Ifallodreplaces itself with the server there is no parent to outlive.1024inside a tool that was meant to stop caring which generator a site uses.--vmwas designed and reviewed by reading. The owner's manual runs on allod/tools#234 had already shown that a plainssh -ton its own connection cleans up with no code at all. The design should have started from that measurement.What carries forward
Nothing from this branch is needed by the new design. The measurements are: zola 0.23.6 serves live reload on the page port, where 0.21 used
1024;localhostresolves to::1only on these machines, so the literal127.0.0.1is what gets passed; andnix eval's--applycan tell an absent flake attribute from a flake that fails to evaluate.The replacement issue is linked from allod/tools#234 when it is filed.
Pull request closed