Repository navigation
Fix config push on bind-mounted gateway.toml - #50
Merged
Merged
Conversation
The config write used a temp file and a rename, which cannot replace a single-file bind mount — `-v host.toml:/app/gateway.toml`, the container setup DEPLOYMENT.md documents. Docker returns EBUSY, so every push to a containerised gateway would have failed. Keeps the atomic path where it works and writes through the mount when the rename is refused, reporting both errors if the fallback also fails. Also adds a test that builds the signal server's real Router. The handler tests call functions directly, so a malformed route path would have panicked at startup with nothing catching it.
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.
Found while working out how to update the containerised gateways.
The bug
write_tomlwrote a temp file and renamed it over the target. That's the right way to avoid a truncated config on crash — but you cannot rename over a single-file bind mount. Docker returnsEBUSY.That's exactly the container setup DEPLOYMENT.md documents:
So config push would have failed on every containerised gateway, with
replace /app/gateway.toml: Device or resource busy. The gateways ontideorg/punchd-gatewayare affected.The fix
Try the atomic rename first, and fall back to writing through the mount when it's refused. If the fallback fails too, both errors are reported rather than just the second.
The fallback is less crash-safe by nature — that's inherent to bind mounts, since the only way to update the host file from inside the container is to write through it.
Also
Adds a test that constructs the signal server's real
Router. The existing tests call handlers directly, so a malformed route path (axum 0.8 wants{id}, not:id) would panic at startup and no test would catch it — the binary would just never bind its port. Verified passing; this was ruled out as a cause during today's outage.Testing
46 gateway tests (3 new) and 28 signal server tests (1 new) pass. The new write tests cover a fresh write that reads back, an overwrite leaving no
.tmpbehind, and the fallback firing when rename can't succeed.The genuine bind-mount case needs Docker to reproduce; the test blocks the temp path with a directory to force the same code path.