Simplify domain language to just "boot" and unscoped config keys

This commit is contained in:
David Heinemeier Hansson
2023-05-02 13:11:31 +02:00
parent f055766918
commit c83b74dcb7
8 changed files with 23 additions and 22 deletions

View File

@@ -835,17 +835,17 @@ mrsk lock release
When deploying to large numbers of hosts, you might prefer not to restart your services on every host at the same time.
MRSK's default is to boot new containers on all hosts in parallel. But you can control this by configuring `group_limit` and `group_wait` as boot options:
MRSK's default is to boot new containers on all hosts in parallel. But you can control this by configuring `boot/limit` and `boot/wait` as options:
```yaml
service: myservice
boot:
group_limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
group_wait: 2
limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
wait: 2
```
When `group_limit` is specified, containers will be booted on, at most, `group_limit` hosts at once. MRSK will pause for `group_wait` seconds between batches.
When `limit` is specified, containers will be booted on, at most, `limit` hosts at once. MRSK will pause for `wait` seconds between batches.
These settings only apply when booting containers (using `mrsk deploy`, or `mrsk app boot`). For other commands, MRSK continues to run commands in parallel across all hosts.

View File

@@ -13,7 +13,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
execute *MRSK.app.tag_current_as_latest
end
on(MRSK.hosts, **MRSK.group_strategy) do |host|
on(MRSK.hosts, **MRSK.boot_strategy) do |host|
roles = MRSK.roles_on(host)
roles.each do |role|

View File

@@ -51,9 +51,9 @@ class Mrsk::Commander
end
end
def group_strategy
if config.boot.group_limit.present?
{ in: :groups, limit: config.boot.group_limit, wait: config.boot.group_wait }
def boot_strategy
if config.boot.limit.present?
{ in: :groups, limit: config.boot.limit, wait: config.boot.wait }
else
{}
end

View File

@@ -4,8 +4,9 @@ class Mrsk::Configuration::Boot
@host_count = config.all_hosts.count
end
def group_limit
limit = @options["group_limit"]
def limit
limit = @options["limit"]
if limit.to_s.end_with?("%")
@host_count * limit.to_i / 100
else
@@ -13,7 +14,7 @@ class Mrsk::Configuration::Boot
end
end
def group_wait
@options["group_wait"]
def wait
@options["wait"]
end
end

View File

@@ -40,7 +40,7 @@ class CliAppTest < CliTestCase
# Strategy is used when booting the containers
Mrsk::Cli::App.any_instance.expects(:on).with([ "1.1.1.1" ], in: :groups, limit: 3, wait: 2).with_block_given
run_command("boot", config: :with_group_strategy)
run_command("boot", config: :with_boot_strategy)
end
test "start" do

View File

@@ -55,19 +55,19 @@ class CommanderTest < ActiveSupport::TestCase
end
test "default group strategy" do
assert_empty @mrsk.group_strategy
assert_empty @mrsk.boot_strategy
end
test "specific limit group strategy" do
configure_with(:deploy_with_group_strategy)
configure_with(:deploy_with_boot_strategy)
assert_equal({ in: :groups, limit: 3, wait: 2 }, @mrsk.group_strategy)
assert_equal({ in: :groups, limit: 3, wait: 2 }, @mrsk.boot_strategy)
end
test "percentage-based group strategy" do
configure_with(:deploy_with_precentage_group_strategy)
configure_with(:deploy_with_precentage_boot_strategy)
assert_equal({ in: :groups, limit: 1, wait: 2 }, @mrsk.group_strategy)
assert_equal({ in: :groups, limit: 1, wait: 2 }, @mrsk.boot_strategy)
end
private

View File

@@ -13,5 +13,5 @@ registry:
password: pw
boot:
group_limit: 3
group_wait: 2
limit: 3
wait: 2

View File

@@ -13,5 +13,5 @@ registry:
password: pw
boot:
group_limit: 25%
group_wait: 2
limit: 25%
wait: 2