fix(preview): one sync at a time, follow pushes, one router per preview #16
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/preview-sync-lock"
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?
Closes #15
Changes
docs/preview/sync.sh: takesflock -nondata/.lock; a second run while one is going printsanother sync is runningand exits 0. Cleans up by removingdata/.incomingwhole and recreating it. Starts the unpack container with this run's downloads mounted read-only at/inand the archive's name inZIP, instead of bind-mounting the archive (Docker creates a missing bind-mount source as a directory, which is what stopped every later run).docs/preview/unpack.sh: unpacks/in/$ZIP; refuses a name that is empty, has a slash or anything buta-z0-9.-.koto-preview-N):sync.shwrites them todata/.routers.yamland passes it to compose next tocompose.yaml, which keeps only the service. Traefik requests one certificate per router for all of its hostnames, so with one rule listing every preview each certificate named all previews (pr-14's carried pr-16 too) and every pull request opening or closing re-issued all of them against Let's Encrypt's 50/week for genji1024.com.docs/preview/fetch.sh: previews now follow pushes. The runs query hadevent=pull_request, but Forgejo filters on its internal event name,pull_request_syncfor a run after a push, even though the run reports"pull_request"; so every preview kept its pull request's first build (#14 was still servingb96db95, run 191, after2aae0b4passed as run 193). The event is now checked on the returned runs.compose.yamlcomments and README (running by hand next to the timer is safe; the certificate paragraph now matches).Verification
With the same
docker composestand-in as #10 (busyboxwget/unzip, jq), against forgejo.genji1024.com with #14 open:Starting from the broken state (
data/.incoming/pr-14.zipa directory): the run recovers, downloads #14's build (run 191, artifact 8), serves it and builds the rule.Two runs at once: the second prints
another sync is runningand exits 0; the first completes normally.The name check accepts
pr-14.zipand rejectspr-1/../x.zip, an empty name and one with a space;sh -npasses.Routers: generated
data/.routers.yamlfor previews 14 and 16 and rendereddocker compose -f compose.yaml -f data/.routers.yaml config: the web service carrieskoto-preview-14andkoto-preview-16, each with its ownHost(),websecure,certresolver: le, and the sharedkoto-previewservice.End to end,
sync.shin a scratch copy with Docker, against forgejo.genji1024.com: downloaded and served #14 at2aae0b4(run 193) and #16 at455f1bf(run 194), wrote both routers, and started nginx with them. A second run downloaded nothing and left the container as it was.After merging, the next run re-creates the web container with the two routers, and Traefik requests one certificate for each open preview.
On the host,
rm -rf ~/koto/docs/preview/data/.incomingclears the current broken state without waiting for this change.fix(preview): one sync at a time, and no file bind mountsto fix(preview): one sync at a time, no file bind mounts, one router per previewfix(preview): one sync at a time, no file bind mounts, one router per previewto fix(preview): one sync at a time, follow pushes, one router per preview