Skip to content

Allow retaining deploy lock through post-deploy - #1930

Open
cyppe wants to merge 2 commits into
basecamp:mainfrom
cyppe:configurable-post-deploy-lock
Open

cyppe wants to merge 2 commits into
basecamp:mainfrom
cyppe:configurable-post-deploy-lock

Conversation

@cyppe

@cyppe cyppe commented Aug 19, 2026

Copy link
Copy Markdown

deploy, redeploy, and rollback currently release the automatic remote lock before running post-deploy. That lets a waiting deployment begin mutating the same service while a stateful post-deploy hook (for example, migrations or cache warming) is still running.

This adds an opt-in, backward-compatible configuration setting:

post_deploy_lock: true

When enabled, the existing remote deploy lock covers the entire command, from before build/pull through completion of post-deploy. The existing nested lock remains re-entrant, hooks inherit KAMAL_LOCK=true, and failures still release the lock. The default remains false, so existing deployments are unchanged. (setup already holds its outer lock through the nested deploy and remains unchanged.)

Tests cover configuration/validation, acquisition and release order, lock visibility in post-deploy, and release after hook failure.

Validation:

  • ./bin/test excluding Docker integration: 841 runs, 2,745 assertions, 0 failures/errors
  • bundle exec rubocop: 178 files, no offenses
  • Docker integration bootstrap was attempted locally, but the fresh deployer container could not resolve RubyGems/Docker Hub and therefore never installed the kamal executable; all resulting integration errors occurred before test behavior.

Copilot AI balanced review requested due to automatic review settings August 19, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional locking across the full deploy lifecycle, including post-deploy.

Changes:

  • Adds and documents post_deploy_lock.
  • Applies it to deploy, redeploy, and rollback.
  • Tests configuration and deploy lock behavior.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/kamal/cli/main.rb Extends lock scope for deployment commands.
lib/kamal/configuration.rb Exposes the configuration predicate.
lib/kamal/configuration/docs/configuration.yml Documents the setting.
test/cli/main_test.rb Tests deploy lock lifecycle.
test/configuration_test.rb Tests default and enabled values.
test/configuration/validation_test.rb Validates boolean input.
test/fixtures/deploy_with_post_deploy_lock.yml Provides enabled test configuration.
Suppressed comments (1)

lib/kamal/cli/main.rb:90

  • The opt-in lock behavior for rollback is not covered by the new tests; rollback has distinct conditional hook flow and nested locking. Add a successful rollback case with post_deploy_lock: true that verifies the outer lock remains held through post-deploy and is then released.
    modify(lock: KAMAL.config.post_deploy_lock?) do

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/kamal/cli/main.rb
Copilot AI review requested due to automatic review settings August 19, 2026 08:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

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.

2 participants