diff --git a/lib/kamal/configuration/boot.rb b/lib/kamal/configuration/boot.rb index f6daa1fa..e5cf5a6e 100644 --- a/lib/kamal/configuration/boot.rb +++ b/lib/kamal/configuration/boot.rb @@ -8,7 +8,7 @@ class Kamal::Configuration::Boot limit = @options["limit"] if limit.to_s.end_with?("%") - @host_count * limit.to_i / 100 + [@host_count * limit.to_i / 100, 1].max else limit end diff --git a/test/commander_test.rb b/test/commander_test.rb index 4e848a4b..598fc56b 100644 --- a/test/commander_test.rb +++ b/test/commander_test.rb @@ -109,6 +109,12 @@ class CommanderTest < ActiveSupport::TestCase assert_equal({ in: :groups, limit: 1, wait: 2 }, @kamal.boot_strategy) end + test "percentage-based group strategy limit is at least 1" do + configure_with(:deploy_with_low_percentage_boot_strategy) + + assert_equal({ in: :groups, limit: 1, wait: 2 }, @kamal.boot_strategy) + end + test "try to match the primary role from a list of specific roles" do configure_with(:deploy_primary_web_role_override) diff --git a/test/fixtures/deploy_with_low_percentage_boot_strategy.yml b/test/fixtures/deploy_with_low_percentage_boot_strategy.yml new file mode 100644 index 00000000..9b6a3c64 --- /dev/null +++ b/test/fixtures/deploy_with_low_percentage_boot_strategy.yml @@ -0,0 +1,17 @@ +service: app +image: dhh/app +servers: + web: + - "1.1.1.1" + - "1.1.1.2" + workers: + - "1.1.1.3" + - "1.1.1.4" + +registry: + username: user + password: pw + +boot: + limit: 1% + wait: 2 diff --git a/test/fixtures/deploy_with_percentage_boot_strategy.yml b/test/fixtures/deploy_with_percentage_boot_strategy.yml index eb68a52f..9b6a3c64 100644 --- a/test/fixtures/deploy_with_percentage_boot_strategy.yml +++ b/test/fixtures/deploy_with_percentage_boot_strategy.yml @@ -13,5 +13,5 @@ registry: password: pw boot: - limit: 25% + limit: 1% wait: 2