Merge pull request #707 from basecamp/boot-strategy-min-limit-1
Ensure a minimum limit of 1 for % boot strategy
This commit is contained in:
@@ -8,7 +8,7 @@ class Kamal::Configuration::Boot
|
|||||||
limit = @options["limit"]
|
limit = @options["limit"]
|
||||||
|
|
||||||
if limit.to_s.end_with?("%")
|
if limit.to_s.end_with?("%")
|
||||||
@host_count * limit.to_i / 100
|
[@host_count * limit.to_i / 100, 1].max
|
||||||
else
|
else
|
||||||
limit
|
limit
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ class CommanderTest < ActiveSupport::TestCase
|
|||||||
assert_equal({ in: :groups, limit: 1, wait: 2 }, @kamal.boot_strategy)
|
assert_equal({ in: :groups, limit: 1, wait: 2 }, @kamal.boot_strategy)
|
||||||
end
|
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
|
test "try to match the primary role from a list of specific roles" do
|
||||||
configure_with(:deploy_primary_web_role_override)
|
configure_with(:deploy_primary_web_role_override)
|
||||||
|
|
||||||
|
|||||||
17
test/fixtures/deploy_with_low_percentage_boot_strategy.yml
vendored
Normal file
17
test/fixtures/deploy_with_low_percentage_boot_strategy.yml
vendored
Normal file
@@ -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
|
||||||
@@ -13,5 +13,5 @@ registry:
|
|||||||
password: pw
|
password: pw
|
||||||
|
|
||||||
boot:
|
boot:
|
||||||
limit: 25%
|
limit: 1%
|
||||||
wait: 2
|
wait: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user