Skip to content

Commit

Permalink
Update notifications, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mchesler committed Jul 19, 2017
1 parent e834e02 commit 4196cc7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
36 changes: 22 additions & 14 deletions lib/movable_ink/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,22 @@ def sns_slack_topic_arn
end

def notify_and_sleep(seconds)
message = "Instance Id #{instance_id} has been throttled in #{region}."
sns.publish(:topic_arn => sns_slack_topic_arn, :message => message, :subject => "API Throttled")
puts "Throttled by AWS. Sleeping #{seconds} seconds."
message = "Throttled by AWS. Sleeping #{seconds} seconds"
notify_slack(subject: 'API Throttled',
message: message)
puts message
sleep seconds
end

def notify_nsq_can_not_be_drained
message = "Unable to drain nsq on instance #{instance_id}"
sns.publish(:topic_arn => sns_slack_topic_arn, :message => message, :subject => "Nsq not drained")
notify_slack(subject: 'NSQ not drained',
message: 'Unable to drain NSQ')
end

def notify_slack(subject:, message:)
sns.publish(topic_arn: sns_slack_topic_arn,
subject: "#{subject} (#{instance_id}, #{region})"
message: message)
end

def mi_env
Expand Down Expand Up @@ -125,15 +132,16 @@ def all_instances

def load_all_instances
run_with_backoff do
resp = ec2.describe_instances(filters: [{
name: 'instance-state-name',
values: ['running']
},
{
name: 'tag:mi:env',
values: [mi_env]
}
])
resp = ec2.describe_instances(filters: [
{
name: 'instance-state-name',
values: ['running']
},
{
name: 'tag:mi:env',
values: [mi_env]
}
])
reservations = resp.reservations
while (!resp.last_page?) do
resp = resp.next_page
Expand Down
2 changes: 1 addition & 1 deletion lib/movable_ink/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MovableInk
module AWS
VERSION = '0.0.3'
VERSION = '0.0.4'
end
end

0 comments on commit 4196cc7

Please sign in to comment.