Deploy the hotcell cell from the kamal hooks, not bin/deploy - #3104
Merged
Conversation
flavorjones
force-pushed
the
hotcell-hooks-output
branch
2 times, most recently
from
September 7, 2026 16:03
5d9798c to
72ef740
Compare
`bin/deploy` wrapped `bin/kamal deploy` to bring the cell along, which left `kamal deploy`, `kamal rollback`, `--hosts` and `--roles` as the paths that did not. The pre-deploy hook already ran the check on every one of them; it only lacked the fix. Give `saas/hotcell/bin/check` the fix: `--publish` builds and pushes a missing image, `--reboot` reboots a stale accessory, `--apply` does both, each checking again afterwards. `--version=SHA` takes the pin from that commit instead of the tree, which is what a rollback needs, and `--hosts=a,b` asks and reboots those hosts only. A new `pre-build` hook runs `--publish` before the deploy lock with no ssh; `pre-deploy` runs `--reboot` under it, on the version and hosts kamal names. The nested kamal inherits the lock through `KAMAL_LOCK`. Kamal logs a hook's stdout at DEBUG, which would hide the build, push, and reboot without `-v`. Set `hooks_output: verbose` for both hooks, which needs kamal 2.12. Remove `bin/deploy`. `saas/test/hotcell-check-test` drives the check and both hooks against stubs.
flavorjones
force-pushed
the
hotcell-hooks-output
branch
from
September 7, 2026 16:30
72ef740 to
5c66c01
Compare
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.
bin/deploy(#3102) wrappedbin/kamal deployto bring the cell along, which leftkamal deploy,kamal rollback,--hostsand--rolesas the paths that did not. The pre-deploy hook already ransaas/hotcell/bin/checkon every one of them; it only lacked the fix. Same change as basecamp/haystack#8781.saas/hotcell/bin/checkdoes the work. Bare, it is unchanged: report and exit 2 (build and push), 3 (reboot), or 1 (could not tell). New flags:--publish: if the registry lacks the pinned image, build it--platform=linux/amd64, refuse if the build moved the pin, push, and check the registry again. Never sshes.--reboot: if a host is off the pin,bin/kamal accessory reboot hotcell --skip-hooks, then ask again. A fix that did not take prints the full explanation.--apply: both.--version=SHA: take the pin fromgit show SHA:saas/config/deploy.ymlinstead of the working tree. A version that is not a commit (kamal's<sha>_uncommitted_<hex>) falls back to the tree; an unfetched sha warns and falls back.--hosts=a,b: ask, and reboot, those hosts only. A list naming every cell host behaves as no list: sample one, reboot all.The accessory's hosts still come from
Kamal::Configuration, as before, since the saas config lives in the gem.The hooks stay small. A new
saas/.kamal/hooks/pre-buildrunscheck --version=$KAMAL_VERSION --publishbefore the deploy lock and with no ssh.pre-deployrunscheck --version=$KAMAL_VERSION --hosts=$KAMAL_HOSTS --rebootunder the lock. So:kamal deploypublishes a new cell image after the app image and reboots the cell before the app boots.kamal rollback SHArunspre-deploywithKAMAL_VERSION=SHA, so the cell goes back to what that commit pinned. Rollback runs nopre-build; a rolled-back image is already in the registry.--hosts/--rolesreach the hook as an already-filteredKAMAL_HOSTS, andkamal accessory rebootintersects them with the accessory's hosts itself.run_hookexportsKAMAL_LOCK=trueandKamal::Commanderreads it back.The hooks' output is visible. Kamal runs a hook through SSHKit, which logs its stdout at
DEBUG, so at the default verbosity the build, push, and reboot leave onlyRunning/Finishedlines behind.hooks_output: verbosefor both hooks insaas/config/deploy.ymlshows them. That setting is kamal 2.12's, so kamal moves 2.11 → 2.12 in both lockfiles.SKIP_HOTCELL_CHECKS=1still skips all of it.bin/deploy,saas/bin/deployandsaas/test/deploy-testare gone;saas/test/hotcell-check-test(33 assertions) drives the real check and both hooks against stubbeddocker,ssh,bundle,bin/kamal,buildandpush.SAAS=1 bin/kamal config -d stagingrenders under 2.12; nothing has run against a live destination.ref: https://app.basecamp.com/2914079/buckets/1666/card_tables/cards/10265014345
🤖 Generated with Claude Code