Skip to content

Add --lock-wait to retry deploy lock acquisition#1844

Open
matthewbjones wants to merge 1 commit intobasecamp:mainfrom
matthewbjones:lock-wait
Open

Add --lock-wait to retry deploy lock acquisition#1844
matthewbjones wants to merge 1 commit intobasecamp:mainfrom
matthewbjones:lock-wait

Conversation

@matthewbjones
Copy link
Copy Markdown
Contributor

Multiple CI workflows targeting the same Kamal deployment race on the deploy lock — only the first wins and the rest abort with LockError. --lock-wait makes lock-acquiring commands (deploy, redeploy, rollback, app boot, etc.) poll for the lock instead of failing immediately, useful for shared CI environments.

The retry target is the same atomic mkdir that backs lock acquire, so wait-then-acquire is race-free without a separate check phase. On timeout, the existing lock holder's details are printed and Kamal::Cli::LockError is raised.

Defaults: 15 minute timeout, 15 second poll interval. Both configurable.

# Wait up to default 15m for the lock, polling every 15s
kamal deploy --lock-wait

# Custom timeout/interval (30 minutes, 30 second polls)
kamal deploy --lock-wait --lock-wait-timeout 1800 --lock-wait-interval 30

Heartbeat output during the wait:

Acquiring the deploy lock (waiting up to 900s)...
Deploy lock is held by:
Locked by: alice at 2026-04-28T15:23:45Z
Version: abc1234
Message: deploying
Retrying in 15s (885s remaining)...
Retrying in 15s (870s remaining)...

Multiple CI workflows targeting the same Kamal deployment race on
the deploy lock; only the first wins and the rest abort.
`--lock-wait` polls the lock instead of failing immediately, with
`--lock-wait-timeout` and `--lock-wait-interval` controlling
behavior (defaults: 15 minutes, 15 seconds).
Copilot AI review requested due to automatic review settings April 28, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant