Skip to content

Commit

Permalink
Fix status command if there's a standby instance in the ASG (#205)
Browse files Browse the repository at this point in the history
* Fix status command if there's a standby instance in the ASG

* Review feedback
  • Loading branch information
janost authored and askreet committed Feb 21, 2017
1 parent c792089 commit d2ce007
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/moonshot/stack_asg_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,21 @@ def create_instance_table(asg_info)
end

def instance_row(asg_instance, ec2_instance)
if ec2_instance
ip_address = ec2_instance.public_ip_address || "#{ec2_instance.private_ip_address} (PRV)"
uptime = uptime_format(ec2_instance.launch_time)
else
# We've seen race conditions where ASG tells us about instances that EC2 is no longer
# aware of.
ip_address = 'unknown'
uptime = 'unknown'
end
[
asg_instance.instance_id,
# @todo What about ASGs with only private IPs?
ec2_instance.public_ip_address,
ip_address,
lifecycle_color(asg_instance.lifecycle_state),
health_color(asg_instance.health_status),
uptime_format(ec2_instance.launch_time)
uptime
]
end

Expand Down

0 comments on commit d2ce007

Please sign in to comment.