jets 3.0.15 → 3.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58e203dbd0ee79c9e7287badab576597b08f0b3f5fd3f1b5309bfa910cbf2858
4
- data.tar.gz: 1a29ba9a72f042b156312d47acdeebee565f6dc4a5c3d3ee109931723e59b583
3
+ metadata.gz: e612ac00d993cb94a8458bbf238abc72e898ddbb4b6205c9d0d7a8d2e5388a6c
4
+ data.tar.gz: e2d13089ca64351b1b4c0c8672b31b17e0708e1caf817eab40abc957775fccf5
5
5
  SHA512:
6
- metadata.gz: 6c6f2d06e54b0837f30c9a064e48252330a72a770b1b0f51e1884ab4820291220565b696f505cfe5645a3de2d428a3c380bc2c7f8d8873ae8819f2f5f0c0a6ef
7
- data.tar.gz: 95a8262ad30c8a593a2c23fed954528e4d0801cd8260ae81e7c974f89d1e8c05c34c3778a7422f356de30c410bae9a9313ebf677e440d7b06d379aa7580421f8
6
+ metadata.gz: 4db9003f65f11b9a47101159dd80e6576bb12a34989de95227b27882db575d5b61b8d2c2b11965fd933f50156e7197ae80e30da498c12a10bcd868934e96a2b9
7
+ data.tar.gz: ca781f60467a266f48abb452cbb1f1aa0ee7c5734315e9d3886786c37d2519466749dc04e28aca50ba470c6260763dc3ef5c2e34ad0a8ee1f883f231db623d0d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [3.0.16] - 2021-09-10
7
+ - [#590](https://github.com/boltops-tools/jets/pull/590) Improve Rate Limit Handling
8
+
6
9
  ## [3.0.15] - 2021-09-05
7
10
  - [#587](https://github.com/boltops-tools/jets/pull/587) Fix private method names
8
11
  - [#588](https://github.com/boltops-tools/jets/pull/588) custom domain: adjust rate limit for base mapping
@@ -16,52 +16,80 @@ module Jets::AwsServices
16
16
  include StackStatus
17
17
 
18
18
  def apigateway
19
- Aws::APIGateway::Client.new
19
+ Aws::APIGateway::Client.new(aws_options)
20
20
  end
21
21
  global_memoize :apigateway
22
22
 
23
23
  def cfn
24
- Aws::CloudFormation::Client.new
24
+ Aws::CloudFormation::Client.new(aws_options)
25
25
  end
26
26
  global_memoize :cfn
27
27
 
28
28
  def dynamodb
29
- Aws::DynamoDB::Client.new
29
+ Aws::DynamoDB::Client.new(aws_options)
30
30
  end
31
31
  global_memoize :dynamodb
32
32
 
33
33
  def aws_lambda
34
- Aws::Lambda::Client.new
34
+ Aws::Lambda::Client.new(aws_options)
35
35
  end
36
36
  global_memoize :aws_lambda
37
37
 
38
38
  def logs
39
- Aws::CloudWatchLogs::Client.new
39
+ Aws::CloudWatchLogs::Client.new(aws_options)
40
40
  end
41
41
  global_memoize :logs
42
42
 
43
43
  def s3
44
- Aws::S3::Client.new
44
+ Aws::S3::Client.new(aws_options)
45
45
  end
46
46
  global_memoize :s3
47
47
 
48
48
  def s3_resource
49
- Aws::S3::Resource.new
49
+ Aws::S3::Resource.new(aws_options)
50
50
  end
51
51
  global_memoize :s3_resource
52
52
 
53
53
  def sns
54
- Aws::SNS::Client.new
54
+ Aws::SNS::Client.new(aws_options)
55
55
  end
56
56
  global_memoize :sns
57
57
 
58
58
  def sqs
59
- Aws::SQS::Client.new
59
+ Aws::SQS::Client.new(aws_options)
60
60
  end
61
61
  global_memoize :sqs
62
62
 
63
63
  def sts
64
- Aws::STS::Client.new
64
+ Aws::STS::Client.new(aws_options)
65
65
  end
66
66
  global_memoize :sts
67
+
68
+ # Override the AWS retry settings with Jets AWS clients.
69
+ #
70
+ # The aws-sdk-core has exponential backup with this formula:
71
+ #
72
+ # 2 ** c.retries * c.config.retry_base_delay
73
+ #
74
+ # So the max delay will be 2 ** 7 * 0.6 = 76.8s
75
+ #
76
+ # Only scoping this to deploy because dont want to affect people's application that use the aws sdk.
77
+ #
78
+ # There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.
79
+ #
80
+ # Useful links:
81
+ # https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
82
+ # https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
83
+ #
84
+ def aws_options
85
+ options = {
86
+ retry_limit: 7, # default: 3
87
+ retry_base_delay: 0.6, # default: 0.3
88
+ }
89
+ options.merge!(
90
+ log_level: :debug,
91
+ logger: Logger.new($stdout),
92
+ ) if ENV['JETS_DEBUG_AWS_SDK']
93
+ options
94
+ end
67
95
  end
@@ -26,20 +26,7 @@ class Jets::Commands::Clean
26
26
  end
27
27
 
28
28
  def delete_log_group(log_group_name)
29
- retries = 0
30
29
  logs.delete_log_group(log_group_name: log_group_name)
31
- rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
32
- retries += 1
33
- seconds = 2 ** retries
34
-
35
- puts "WARN: delete_log_group #{e.class} #{e.message}".color(:yellow)
36
- puts "Backing off and will retry in #{seconds} seconds."
37
- sleep(seconds)
38
- if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
39
- puts "Giving up after #{retries} retries"
40
- else
41
- retry
42
- end
43
30
  end
44
31
 
45
32
  def clean_deploys
@@ -44,27 +44,7 @@ class Jets::Commands::Delete
44
44
  end
45
45
 
46
46
  def confirm_project_exists
47
- retries = 0
48
- begin
49
- cfn.describe_stacks(stack_name: parent_stack_name)
50
- rescue Aws::CloudFormation::Errors::ValidationError
51
- # Aws::CloudFormation::Errors::ValidationError is thrown when the stack
52
- # does not exist
53
- puts "The parent stack #{Jets.config.project_namespace.color(:green)} for the project #{Jets.config.project_name.color(:green)} does not exist. So it cannot be deleted."
54
- exit 0
55
- rescue Aws::CloudFormation::Errors::Throttling => e
56
- retries += 1
57
- seconds = 2 ** retries
58
-
59
- puts "WARN: confirm_project_exists #{e.class} #{e.message}".color(:yellow)
60
- puts "Backing off and will retry in #{seconds} seconds."
61
- sleep(seconds)
62
- if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
63
- puts "Giving up after #{retries} retries"
64
- else
65
- retry
66
- end
67
- end
47
+ cfn.describe_stacks(stack_name: parent_stack_name)
68
48
  end
69
49
 
70
50
  def empty_s3_bucket
@@ -9,7 +9,6 @@ module Jets::Commands
9
9
  end
10
10
 
11
11
  def run
12
- aws_config_update!
13
12
  deployment_env = Jets.config.project_namespace.color(:green)
14
13
  puts "Deploying to Lambda #{deployment_env} environment..."
15
14
  return if @options[:noop]
@@ -37,29 +36,6 @@ module Jets::Commands
37
36
  ship(stack_type: :full, s3_bucket: s3_bucket)
38
37
  end
39
38
 
40
- # Override the AWS retry settings during a deploy.
41
- #
42
- # The aws-sdk-core has expondential backup with this formula:
43
- #
44
- # 2 ** c.retries * c.config.retry_base_delay
45
- #
46
- # So the max delay will be 2 ** 7 * 0.6 = 76.8s
47
- #
48
- # Only scoping this to deploy because dont want to affect people's application that use the aws sdk.
49
- #
50
- # There is also additional rate backoff logic elsewhere, since this is only scoped to deploys.
51
- #
52
- # Useful links:
53
- # https://github.com/aws/aws-sdk-ruby/blob/master/gems/aws-sdk-core/lib/aws-sdk-core/plugins/retry_errors.rb
54
- # https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
55
- #
56
- def aws_config_update!
57
- Aws.config.update(
58
- retry_limit: 7, # default: 3
59
- retry_base_delay: 0.6, # default: 0.3
60
- )
61
- end
62
-
63
39
  def create_s3_event_buckets
64
40
  buckets = Jets::Job::Base.s3_events.keys
65
41
  buckets.each do |bucket|
@@ -126,28 +102,8 @@ module Jets::Commands
126
102
  end
127
103
 
128
104
  def find_stack(stack_name)
129
- retries = 0
130
105
  resp = cfn.describe_stacks(stack_name: stack_name)
131
106
  resp.stacks.first
132
- rescue Aws::CloudFormation::Errors::ValidationError => e
133
- # example: Stack with id demo-dev does not exist
134
- if e.message =~ /Stack with/ && e.message =~ /does not exist/
135
- nil
136
- else
137
- raise
138
- end
139
- rescue Aws::CloudFormation::Errors::Throttling => e
140
- retries += 1
141
- seconds = 2 ** retries
142
-
143
- puts "WARN: find_stack #{e.class} #{e.message}".color(:yellow)
144
- puts "Backing off and will retry in #{seconds} seconds."
145
- sleep(seconds)
146
- if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
147
- puts "Giving up after #{retries} retries"
148
- else
149
- retry
150
- end
151
107
  end
152
108
 
153
109
  # All CloudFormation states listed here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
@@ -59,26 +59,11 @@ class Jets::Resource::ApiGateway::RestApi::Routes::Change
59
59
 
60
60
  def method_uri(resource_id, http_method)
61
61
  # https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
62
- retries = 0
63
- begin
64
- resp = apigateway.get_method(
65
- rest_api_id: rest_api_id,
66
- resource_id: resource_id,
67
- http_method: http_method
68
- )
69
- rescue Aws::APIGateway::Errors::TooManyRequestsException => e
70
- retries += 1
71
- seconds = 2 ** retries
72
-
73
- puts "WARN: method_uri #{e.class} #{e.message}".color(:yellow)
74
- puts "Backing off and will retry in #{seconds} seconds."
75
- sleep(seconds)
76
- if seconds > 90 # 2 ** 6 is 64 so will give up after 6 retries
77
- puts "Giving up after #{retries} retries"
78
- else
79
- retry
80
- end
81
- end
62
+ resp = apigateway.get_method(
63
+ rest_api_id: rest_api_id,
64
+ resource_id: resource_id,
65
+ http_method: http_method
66
+ )
82
67
  resp.method_integration.uri
83
68
  end
84
69
 
data/lib/jets/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jets
2
- VERSION = "3.0.15"
2
+ VERSION = "3.0.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.15
4
+ version: 3.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer