Ensure primary_role app hosts are sorted first
When booting non-primary role hosts we will always wait for a primary role host to boor first. So when booting in groups, if there are no primary role hosts in the first batch, then booting will stall. Sort primary role app_hosts first to avoid this. Fixes: https://github.com/basecamp/kamal/issues/1553
This commit is contained in:
@@ -11,7 +11,7 @@ class Kamal::Commander::Specifics
|
||||
@primary_role = primary_or_first_role(roles_on(primary_host))
|
||||
|
||||
stable_sort!(roles) { |role| role == primary_role ? 0 : 1 }
|
||||
stable_sort!(hosts) { |host| roles_on(host).any? { |role| role == primary_role } ? 0 : 1 }
|
||||
sort_primary_role_hosts_first!(hosts)
|
||||
end
|
||||
|
||||
def roles_on(host)
|
||||
@@ -19,7 +19,7 @@ class Kamal::Commander::Specifics
|
||||
end
|
||||
|
||||
def app_hosts
|
||||
config.app_hosts & specified_hosts
|
||||
@app_hosts ||= sort_primary_role_hosts_first!(config.app_hosts & specified_hosts)
|
||||
end
|
||||
|
||||
def proxy_hosts
|
||||
@@ -55,4 +55,8 @@ class Kamal::Commander::Specifics
|
||||
specified_hosts
|
||||
end
|
||||
end
|
||||
|
||||
def sort_primary_role_hosts_first!(hosts)
|
||||
stable_sort!(hosts) { |host| roles_on(host).any? { |role| role == primary_role } ? 0 : 1 }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user