Class: Jets::Commands::Clean::Log
Instance Method Summary
collapse
#apigateway, #aws_lambda, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts
#lookup, #stack_exists?, #stack_in_progress?
included
Methods inherited from Base
autocomplete, banner, dispatch, eager_load!, help_list, inherited, klass_from_namespace, namespace_from_class, namespaced_commands, perform, subclasses
Instance Method Details
#clean ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/jets/commands/clean/log.rb', line 16
def clean
are_you_sure?("delete CloudWatch logs")
say "Removing CloudWatch logs for #{prefix_guess}..."
log_groups.each do |g|
next if keep_log_group?(g.log_group_name)
delete_log_group(g.log_group_name) unless @options[:noop]
say "Removed log group: #{g.log_group_name}"
end
say "Removed CloudWatch logs for #{prefix_guess}"
end
|
#clean_deploys ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/jets/commands/clean/log.rb', line 45
def clean_deploys
groups = deploy_log_groups.sort_by do |g|
g.log_group_name
end
groups = groups[0..-3]
groups.each do |g|
logs.delete_log_group(log_group_name: g.log_group_name) unless @options[:noop]
end
end
|
#delete_log_group(log_group_name) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/jets/commands/clean/log.rb', line 28
def delete_log_group(log_group_name)
retries = 0
logs.delete_log_group(log_group_name: log_group_name)
rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
retries += 1
seconds = 2 ** retries
puts "WARN: delete_log_group #{e.class} #{e.message}".color(:yellow)
puts "Backing off and will retry in #{seconds} seconds."
sleep(seconds)
if seconds > 90 puts "Giving up after #{retries} retries"
else
retry
end
end
|
#deploy_log_groups ⇒ Object
56
57
58
59
60
61
|
# File 'lib/jets/commands/clean/log.rb', line 56
def deploy_log_groups
log_groups.select do |g|
!keep_log_group?(g.log_group_name) &&
g.log_group_name.include?('jets-base-path')
end
end
|