Merge pull request #255 from basecamp/check-all-hosts-for-rollback-container

Check all hosts before rolling back
This commit is contained in:
David Heinemeier Hansson
2023-05-02 13:16:03 +02:00
committed by GitHub
2 changed files with 31 additions and 11 deletions

View File

@@ -236,15 +236,24 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
subcommand "lock", Mrsk::Cli::Lock
private
def container_available?(version, host: MRSK.primary_host)
available = nil
on(host) do
first_role = MRSK.roles_on(host).first
available = capture_with_info(*MRSK.app(role: first_role).container_id_for_version(version)).present?
def container_available?(version)
begin
on(MRSK.hosts) do
MRSK.roles_on(host).each do |role|
container_id = capture_with_info(*MRSK.app(role: role).container_id_for_version(version))
raise "Container not found" unless container_id.present?
end
end
rescue SSHKit::Runner::ExecuteError => e
if e.message =~ /Container not found/
say "Error looking for container version #{version}: #{e.message}"
return false
else
raise
end
end
available
true
end
def deploy_options