diff --git a/lib/kamal/cli/base.rb b/lib/kamal/cli/base.rb index 9d99f759e..84863c4e7 100644 --- a/lib/kamal/cli/base.rb +++ b/lib/kamal/cli/base.rb @@ -293,7 +293,7 @@ def reset_invocation(cli_class) end def ensure_run_directory - on(KAMAL.hosts) do + on(KAMAL.primary_host) do execute(*KAMAL.server.ensure_run_directory) end end diff --git a/test/cli/lock_test.rb b/test/cli/lock_test.rb index e3db32018..31c1f9bb9 100644 --- a/test/cli/lock_test.rb +++ b/test/cli/lock_test.rb @@ -13,6 +13,15 @@ class CliLockTest < CliTestCase end end + test "acquire ensures the run directory only on the primary host" do + run_command("acquire", "-m", "hello").tap do |output| + assert_match "Running /usr/bin/env mkdir -p .kamal on 1.1.1.1", output + assert_no_match(/mkdir -p \.kamal on 1\.1\.1\.2/, output) + assert_no_match(/mkdir -p \.kamal on 1\.1\.1\.3/, output) + assert_no_match(/mkdir -p \.kamal on 1\.1\.1\.4/, output) + end + end + test "status when there is no deploy lock" do SSHKit::Backend::Abstract.any_instance.stubs(:capture_with_debug) .raises(RuntimeError, "cat: .kamal/lock-app/details: No such file or directory")