Simplify domain language to just "boot" and unscoped config keys
This commit is contained in:
@@ -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.
|
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
|
```yaml
|
||||||
service: myservice
|
service: myservice
|
||||||
|
|
||||||
boot:
|
boot:
|
||||||
group_limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
|
limit: 10 # Can also specify as a percentage of total hosts, such as "25%"
|
||||||
group_wait: 2
|
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.
|
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.
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
execute *MRSK.app.tag_current_as_latest
|
execute *MRSK.app.tag_current_as_latest
|
||||||
end
|
end
|
||||||
|
|
||||||
on(MRSK.hosts, **MRSK.group_strategy) do |host|
|
on(MRSK.hosts, **MRSK.boot_strategy) do |host|
|
||||||
roles = MRSK.roles_on(host)
|
roles = MRSK.roles_on(host)
|
||||||
|
|
||||||
roles.each do |role|
|
roles.each do |role|
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ class Mrsk::Commander
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_strategy
|
def boot_strategy
|
||||||
if config.boot.group_limit.present?
|
if config.boot.limit.present?
|
||||||
{ in: :groups, limit: config.boot.group_limit, wait: config.boot.group_wait }
|
{ in: :groups, limit: config.boot.limit, wait: config.boot.wait }
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ class Mrsk::Configuration::Boot
|
|||||||
@host_count = config.all_hosts.count
|
@host_count = config.all_hosts.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_limit
|
def limit
|
||||||
limit = @options["group_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
|
||||||
else
|
else
|
||||||
@@ -13,7 +14,7 @@ class Mrsk::Configuration::Boot
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_wait
|
def wait
|
||||||
@options["group_wait"]
|
@options["wait"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class CliAppTest < CliTestCase
|
|||||||
# Strategy is used when booting the containers
|
# 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
|
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
|
end
|
||||||
|
|
||||||
test "start" do
|
test "start" do
|
||||||
|
|||||||
@@ -55,19 +55,19 @@ class CommanderTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "default group strategy" do
|
test "default group strategy" do
|
||||||
assert_empty @mrsk.group_strategy
|
assert_empty @mrsk.boot_strategy
|
||||||
end
|
end
|
||||||
|
|
||||||
test "specific limit group strategy" do
|
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
|
end
|
||||||
|
|
||||||
test "percentage-based group strategy" do
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ registry:
|
|||||||
password: pw
|
password: pw
|
||||||
|
|
||||||
boot:
|
boot:
|
||||||
group_limit: 3
|
limit: 3
|
||||||
group_wait: 2
|
wait: 2
|
||||||
@@ -13,5 +13,5 @@ registry:
|
|||||||
password: pw
|
password: pw
|
||||||
|
|
||||||
boot:
|
boot:
|
||||||
group_limit: 25%
|
limit: 25%
|
||||||
group_wait: 2
|
wait: 2
|
||||||
Reference in New Issue
Block a user