Skip to content

Commit

Permalink
raise over fail
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydwatkin committed Jul 4, 2024
1 parent 70bf1b2 commit fca63f2
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/capistrano/asg/tasks/rolling.rake
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ namespace :rolling do
group.start_instance_refresh(launch_template)

logger.verbose "Successfully started Instance Refresh on Auto Scaling Group **#{group.name}**."
rescue Capistrano::ASG::Rolling::InstanceRefreshFailed => e
logger.info "Failed to start Instance Refresh on Auto Scaling Group **#{group.name}**: #{e.message}"
rescue Capistrano::ASG::Rolling::InstanceRefreshraise RuntimeError, 'Auto Scaling Group update failed'ed => e
logger.info "raise RuntimeError, 'Auto Scaling Group update failed'ed to start Instance Refresh on Auto Scaling Group **#{group.name}**: #{e.message}"
end
end

Expand Down Expand Up @@ -111,8 +111,8 @@ namespace :rolling do
logger.info 'Terminating instance(s)...'
begin
instances.terminate
rescue Capistrano::ASG::Rolling::InstanceTerminateFailed => e
logger.warning "Failed to terminate Instance **#{e.instance.id}**: #{e.message}"
rescue Capistrano::ASG::Rolling::InstanceTerminateraise RuntimeError, 'Auto Scaling Group update failed'ed => e
logger.warning "raise RuntimeError, 'Auto Scaling Group update failed'ed to terminate Instance **#{e.instance.id}**: #{e.message}"
end
end
end
Expand All @@ -125,7 +125,7 @@ namespace :rolling do
end
else
logger.error 'No instances have been launched. Are you using a configuration with rolling deployments?'
fail
raise RuntimeError, 'Auto Scaling Group update failed'
end
end

Expand All @@ -139,7 +139,7 @@ namespace :rolling do
end
else
logger.error 'No instances have been launched. Are you using a configuration with rolling deployments?'
fail
raise RuntimeError, 'Auto Scaling Group update failed'
end

invoke 'deploy'
Expand Down Expand Up @@ -197,16 +197,16 @@ namespace :rolling do
logger.info "Instance refresh(es) not completed, waiting #{wait_for} seconds..."
sleep wait_for
end
failed = false
raise RuntimeError, 'Auto Scaling Group update failed'ed = false
completed_groups.each do |group|
if group.latest_instance_refresh.status == 'Failed'
failed = true
logger.error "~~ Auto Scaling Group: **#{name}** refresh failed ~~"
if group.latest_instance_refresh.status == 'raise RuntimeError, 'Auto Scaling Group update failed'ed'
raise RuntimeError, 'Auto Scaling Group update failed'ed = true
logger.error "~~ Auto Scaling Group: **#{name}** refresh raise RuntimeError, 'Auto Scaling Group update failed'ed ~~"
else
logger.info "Auto Scaling Group: **#{name}**, completed with status '#{refresh.status}'."
end
end
fail if failed
raise RuntimeError, 'Auto Scaling Group update failed' if raise RuntimeError, 'Auto Scaling Group update failed'ed
end
end
end

0 comments on commit fca63f2

Please sign in to comment.