Move group_limit & group_wait under boot
Also make formatting the group strategy the responsibility of the commander.
This commit is contained in:
@@ -835,13 +835,14 @@ 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`.
|
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:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
service: myservice
|
service: myservice
|
||||||
|
|
||||||
group_limit: 10
|
boot:
|
||||||
group_wait: 30
|
group_limit: 10
|
||||||
|
group_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 `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.
|
||||||
|
|||||||
@@ -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.config.group_strategy) do |host|
|
on(MRSK.hosts, **MRSK.group_strategy) do |host|
|
||||||
roles = MRSK.roles_on(host)
|
roles = MRSK.roles_on(host)
|
||||||
|
|
||||||
roles.each do |role|
|
roles.each do |role|
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ class Mrsk::Commander
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def group_strategy
|
||||||
|
if config.boot.group_limit.present?
|
||||||
|
{ in: :groups, limit: config.boot.group_limit, wait: config.boot.group_wait }
|
||||||
|
else
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def roles_on(host)
|
def roles_on(host)
|
||||||
roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name)
|
roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ class Mrsk::Configuration
|
|||||||
roles.select(&:running_traefik?).flat_map(&:hosts).uniq
|
roles.select(&:running_traefik?).flat_map(&:hosts).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def boot
|
||||||
|
Mrsk::Configuration::Boot.new(section: raw_config.boot)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def repository
|
def repository
|
||||||
[ raw_config.registry["server"], image ].compact.join("/")
|
[ raw_config.registry["server"], image ].compact.join("/")
|
||||||
@@ -153,15 +157,6 @@ class Mrsk::Configuration
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def group_strategy
|
|
||||||
if group_limit.present?
|
|
||||||
{ in: :groups, limit: group_limit, wait: group_wait }
|
|
||||||
else
|
|
||||||
{}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def audit_broadcast_cmd
|
def audit_broadcast_cmd
|
||||||
raw_config.audit_broadcast_cmd
|
raw_config.audit_broadcast_cmd
|
||||||
end
|
end
|
||||||
@@ -246,12 +241,4 @@ class Mrsk::Configuration
|
|||||||
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
|
raise "Can't use commit hash as version, no git repository found in #{Dir.pwd}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_limit
|
|
||||||
raw_config.group_limit&.to_i
|
|
||||||
end
|
|
||||||
|
|
||||||
def group_wait
|
|
||||||
raw_config.group_wait&.to_i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
9
lib/mrsk/configuration/boot.rb
Normal file
9
lib/mrsk/configuration/boot.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class Mrsk::Configuration::Boot
|
||||||
|
attr_reader :group_wait, :group_limit
|
||||||
|
|
||||||
|
def initialize(section:)
|
||||||
|
section = section || {}
|
||||||
|
@group_limit = section["group_limit"]
|
||||||
|
@group_wait = section["group_wait"]
|
||||||
|
end
|
||||||
|
end
|
||||||
5
test/fixtures/deploy_with_group_strategy.yml
vendored
5
test/fixtures/deploy_with_group_strategy.yml
vendored
@@ -12,5 +12,6 @@ registry:
|
|||||||
username: user
|
username: user
|
||||||
password: pw
|
password: pw
|
||||||
|
|
||||||
group_limit: 3
|
boot:
|
||||||
group_wait: 30
|
group_limit: 3
|
||||||
|
group_wait: 30
|
||||||
|
|||||||
Reference in New Issue
Block a user