fix(proxy): sync the secrets env file on every reboot path - #110
Merged
Conversation
The port-holder replacement paths (generation handoff, fresh generation,
holder migration) all launch a container that reads --env-file at docker
run, but only the legacy stop_and_replace path uploaded the proxy
secrets file first. A port-holder reboot on a host that never held the
file — a drift reboot right after acme credentials or a cache store were
added to the run config — died with:
docker: open .kamal/proxy/secrets.env: no such file or directory
after the old proxy was already stopped and pruned, leaving the host
with no proxy at all.
The sync (upload when the run config carries secrets, remove when it no
longer does) now happens in replace_container, before any path launches
a generation. Regression test drives a port-holder reboot with acme
credentials and asserts the upload.
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.
The bug
The port-holder replacement paths (
handoff_generation, fresh generation,migrate_to_holder) all launch a container that reads--env-file .kamal/proxy/secrets.envatdocker run— but only the legacystop_and_replacepath uploaded the file first. A drift-triggered reboot on a port-holder host that had never held the file (the exact situation right afterrun.acme.credentialsor a cache store is first added to the config) failed with:…after the old proxy container was already stopped and pruned, leaving the host with no proxy at all. Hit in the wild on the first deploy that added acme credentials to a fleet already running
port_holder: true.LoadbalancerRebootandproxy bootboth sync the file correctly; onlyReboot's port-holder branches missed it.The fix
Hoist the sync into
replace_container, before any path launches a generation: upload (0600) when the run config carries secrets, remove the stale file when it no longer does — same semanticsstop_and_replacehad, now covering all four paths.Tests
deploy_with_proxy_acme_port_holder.yml+ regression test driving a port-holder reboot with acme credentials, asserting the 0600 upload happens and the token never reaches the command line. RED ondash(uploads[]), GREEN with the fix.test/cli/proxy_test.rb: 102 runs, 0 failures. Full unit suite (sans integration): identical failure set to cleandash(the documented arch/Docker-dependent ones) plus the one new test.Summary by cubic
Ensure all proxy reboot paths with port-holder sync the secrets env file before starting any generation. This prevents docker failures (“open
.kamal/proxy/secrets.env: no such file or directory”) and avoids proxy downtime.replace_containerviasync_proxy_secrets, executed before all reboot paths..kamal/proxy/secrets.envwith mode0600when secrets exist; removes it when not.Written for commit 2683c18. Summary will update on new commits.