Merge pull request #222 from basecamp/deploy-groups

Allow booting containers in groups for rolling restarts
This commit is contained in:
David Heinemeier Hansson
2023-05-02 13:14:32 +02:00
committed by GitHub
9 changed files with 121 additions and 6 deletions

View File

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

View File

@@ -51,6 +51,14 @@ class Mrsk::Commander
end
end
def boot_strategy
if config.boot.limit.present?
{ in: :groups, limit: config.boot.limit, wait: config.boot.wait }
else
{}
end
end
def roles_on(host)
roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name)
end

View File

@@ -87,6 +87,10 @@ class Mrsk::Configuration
roles.select(&:running_traefik?).flat_map(&:hosts).uniq
end
def boot
Mrsk::Configuration::Boot.new(config: self)
end
def repository
[ raw_config.registry["server"], image ].compact.join("/")

View File

@@ -0,0 +1,20 @@
class Mrsk::Configuration::Boot
def initialize(config:)
@options = config.raw_config.boot || {}
@host_count = config.all_hosts.count
end
def limit
limit = @options["limit"]
if limit.to_s.end_with?("%")
@host_count * limit.to_i / 100
else
limit
end
end
def wait
@options["wait"]
end
end