MovableInkAWS 1.0.11 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2127e6bcec465975fe334b3f4f26b595df236502141a02a5f8ece04f079dd2c5
4
- data.tar.gz: 0b71197e920ef8356b92e3cb831479920f101f8f129b5b6ba745bfedc558528c
3
+ metadata.gz: 8da5fcf1d95cc4642ae47bc180040671d9baeb9bbabb3c92bdf8c7a1a387b33b
4
+ data.tar.gz: ebb0966bf640735e8e5d2e2b0903ac246a8e61f85eb3f21a2950afd935ca338d
5
5
  SHA512:
6
- metadata.gz: 49adad04149c4af1adad4638c87ccd4d746265fb1051d2dfb002bf1e941398aac584694e527f10a15b5538d80aaec3a872fdb73c771d1665fce80cec4c81a465
7
- data.tar.gz: e60ff448613bfe3199ae16d77d256ea122c7f8cba456b5a3c5dbb52f35787f6be83ea8139d569897be404d2c93cd2cf19af2d81e4120d99f8dcc83049695ce80
6
+ metadata.gz: 635c4fe35a5c3bb404ec5ea1621345a5dca26bb8e85a911e772ad2420cbd6469a0ac896a1311f4f86326948fc25298d006981451521df244333d50d2654c82b1
7
+ data.tar.gz: af18dbf13eab9fc4b06a3006c593289f7a6323afc779e08fe881f6b3e93a2ce76a0091ef36855653e848b17887d369745750c9d857085ea4816d6070e6b62053
@@ -0,0 +1,11 @@
1
+ name: PR Lint
2
+ on:
3
+ pull_request:
4
+ types: [opened, edited, reopened, synchronize]
5
+
6
+ jobs:
7
+ ch_lint_pr:
8
+ name: Clubhouse
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: movableink/pr-clubhouse-lint-action@release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (1.0.11)
4
+ MovableInkAWS (1.0.16)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -19,48 +19,48 @@ PATH
19
19
  GEM
20
20
  remote: https://rubygems.org/
21
21
  specs:
22
- aws-eventstream (1.0.3)
23
- aws-partitions (1.280.0)
24
- aws-sdk-athena (1.22.0)
22
+ aws-eventstream (1.1.0)
23
+ aws-partitions (1.322.0)
24
+ aws-sdk-athena (1.25.0)
25
25
  aws-sdk-core (~> 3, >= 3.71.0)
26
26
  aws-sigv4 (~> 1.1)
27
- aws-sdk-autoscaling (1.32.0)
27
+ aws-sdk-autoscaling (1.36.0)
28
28
  aws-sdk-core (~> 3, >= 3.71.0)
29
29
  aws-sigv4 (~> 1.1)
30
- aws-sdk-cloudwatch (1.33.0)
30
+ aws-sdk-cloudwatch (1.37.0)
31
31
  aws-sdk-core (~> 3, >= 3.71.0)
32
32
  aws-sigv4 (~> 1.1)
33
- aws-sdk-core (3.90.1)
34
- aws-eventstream (~> 1.0, >= 1.0.2)
33
+ aws-sdk-core (3.96.1)
34
+ aws-eventstream (~> 1, >= 1.0.2)
35
35
  aws-partitions (~> 1, >= 1.239.0)
36
36
  aws-sigv4 (~> 1.1)
37
37
  jmespath (~> 1.0)
38
- aws-sdk-ec2 (1.147.0)
38
+ aws-sdk-ec2 (1.163.0)
39
39
  aws-sdk-core (~> 3, >= 3.71.0)
40
40
  aws-sigv4 (~> 1.1)
41
- aws-sdk-elasticache (1.29.0)
41
+ aws-sdk-elasticache (1.34.0)
42
42
  aws-sdk-core (~> 3, >= 3.71.0)
43
43
  aws-sigv4 (~> 1.1)
44
- aws-sdk-kms (1.29.0)
44
+ aws-sdk-kms (1.31.0)
45
45
  aws-sdk-core (~> 3, >= 3.71.0)
46
46
  aws-sigv4 (~> 1.1)
47
- aws-sdk-rds (1.78.0)
47
+ aws-sdk-rds (1.84.0)
48
48
  aws-sdk-core (~> 3, >= 3.71.0)
49
49
  aws-sigv4 (~> 1.1)
50
- aws-sdk-route53 (1.30.0)
50
+ aws-sdk-route53 (1.34.0)
51
51
  aws-sdk-core (~> 3, >= 3.71.0)
52
52
  aws-sigv4 (~> 1.1)
53
- aws-sdk-s3 (1.60.2)
54
- aws-sdk-core (~> 3, >= 3.83.0)
53
+ aws-sdk-s3 (1.66.0)
54
+ aws-sdk-core (~> 3, >= 3.96.1)
55
55
  aws-sdk-kms (~> 1)
56
56
  aws-sigv4 (~> 1.1)
57
- aws-sdk-sns (1.21.0)
57
+ aws-sdk-sns (1.23.0)
58
58
  aws-sdk-core (~> 3, >= 3.71.0)
59
59
  aws-sigv4 (~> 1.1)
60
- aws-sdk-ssm (1.71.0)
60
+ aws-sdk-ssm (1.78.0)
61
61
  aws-sdk-core (~> 3, >= 3.71.0)
62
62
  aws-sigv4 (~> 1.1)
63
- aws-sigv4 (1.1.1)
63
+ aws-sigv4 (1.1.3)
64
64
  aws-eventstream (~> 1.0, >= 1.0.2)
65
65
  diff-lcs (1.3)
66
66
  httparty (0.16.3)
@@ -69,7 +69,7 @@ GEM
69
69
  jmespath (1.4.0)
70
70
  mime-types (3.3.1)
71
71
  mime-types-data (~> 3.2015)
72
- mime-types-data (3.2019.1009)
72
+ mime-types-data (3.2020.0512)
73
73
  multi_xml (0.6.0)
74
74
  rspec (3.9.0)
75
75
  rspec-core (~> 3.9.0)
@@ -93,4 +93,4 @@ DEPENDENCIES
93
93
  rspec (~> 3.6)
94
94
 
95
95
  BUNDLED WITH
96
- 1.17.1
96
+ 1.17.3
@@ -0,0 +1,15 @@
1
+ ## Current Behavior
2
+
3
+
4
+
5
+ ## Why do we need this change?
6
+
7
+
8
+
9
+ ## Implementation Details
10
+
11
+
12
+
13
+ #### Dependencies (if any)
14
+
15
+ :house: [chXXXX](https://app.clubhouse.io/movableink/story/XXXX)
@@ -59,6 +59,7 @@ module MovableInk
59
59
  return yield
60
60
  rescue Aws::EC2::Errors::RequestLimitExceeded,
61
61
  Aws::EC2::Errors::ResourceAlreadyAssociated,
62
+ Aws::EC2::Errors::Unavailable,
62
63
  Aws::SNS::Errors::ThrottledException,
63
64
  Aws::AutoScaling::Errors::ThrottledException,
64
65
  Aws::S3::Errors::SlowDown,
@@ -76,12 +77,15 @@ module MovableInk
76
77
  notify_and_sleep(sleep_time, $!.class)
77
78
  end
78
79
  rescue Aws::Errors::ServiceError => e
79
- message = "#{e.class}: #{e.message}\nFrom `#{e.backtrace.last.gsub("`","'")}`"
80
+ message = "#{e.class}: #{e.message}\nFrom #{$0}\n```\n#{e.backtrace.first(3).join("\n").gsub("`","'")}\n```"
80
81
  notify_slack(subject: 'Unhandled AWS API Error', message: message)
81
82
  puts message
82
83
  raise MovableInk::AWS::Errors::ServiceError
83
84
  end
84
85
  end
86
+ message = "From: #{$0}\n```\n#{Thread.current.backtrace.first(3).join("\n").gsub("`","'")}\n```"
87
+ notify_slack(subject: "AWS API failed after #{tries} attempts", message: message)
88
+ puts message
85
89
  raise MovableInk::AWS::Errors::FailedWithBackoff
86
90
  end
87
91
 
@@ -8,8 +8,17 @@ module MovableInk
8
8
  @ec2_client[region] ||= Aws::EC2::Client.new(region: region)
9
9
  end
10
10
 
11
+ def mi_env_cache_file_path
12
+ '/etc/movableink/mi_env'
13
+ end
14
+
11
15
  def mi_env
12
- @mi_env ||= load_mi_env
16
+ @mi_env ||= if File.exist?(mi_env_cache_file_path)
17
+ value = File.read(mi_env_cache_file_path)
18
+ value.empty? ? load_mi_env : value
19
+ else
20
+ load_mi_env
21
+ end
13
22
  end
14
23
 
15
24
  def load_mi_env
@@ -20,23 +29,12 @@ module MovableInk
20
29
  raise MovableInk::AWS::Errors::NoEnvironmentTagError
21
30
  end
22
31
 
23
- def thopter_filter
24
- [{
25
- name: 'tag:mi:roles',
26
- values: ['*thopter*']
27
- },
28
- {
29
- name: 'tag:mi:env',
30
- values: [mi_env]
31
- },
32
- {
33
- name: 'instance-state-name',
34
- values: ['running']
35
- }]
36
- end
37
-
38
32
  def thopter_instance
39
- @thopter_instance ||= load_all_instances('us-east-1', filter: thopter_filter)
33
+ @thopter_instance ||= all_instances(region: 'us-east-1').select do |instance|
34
+ instance.tags.select{ |tag| tag.key == 'mi:roles' }.detect do |tag|
35
+ tag.value.include?('thopter')
36
+ end
37
+ end
40
38
  end
41
39
 
42
40
  def all_instances(region: my_region, no_filter: false)
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '1.0.11'
3
+ VERSION = '1.0.16'
4
4
  end
5
5
  end
@@ -42,9 +42,9 @@ describe MovableInk::AWS do
42
42
  ec2 = Aws::EC2::Client.new(stub_responses: true)
43
43
  ec2.stub_responses(:describe_instances, 'RequestLimitExceeded')
44
44
 
45
- expect(aws).to receive(:notify_slack).exactly(9).times
45
+ expect(aws).to receive(:notify_slack).exactly(10).times
46
46
  expect(aws).to receive(:sleep).exactly(9).times.and_return(true)
47
- expect(STDOUT).to receive(:puts).exactly(9).times
47
+ expect(STDOUT).to receive(:puts).exactly(10).times
48
48
 
49
49
  aws.run_with_backoff { ec2.describe_instances } rescue nil
50
50
  end
@@ -64,9 +64,9 @@ describe MovableInk::AWS do
64
64
  ec2 = Aws::EC2::Client.new(stub_responses: true)
65
65
  ec2.stub_responses(:describe_instances, 'RequestLimitExceeded')
66
66
 
67
- expect(aws).to receive(:notify_slack).exactly(1).times
67
+ expect(aws).to receive(:notify_slack).exactly(2).times
68
68
  expect(aws).to receive(:sleep).exactly(9).times.and_return(true)
69
- expect(STDOUT).to receive(:puts).exactly(1).times
69
+ expect(STDOUT).to receive(:puts).exactly(2).times
70
70
 
71
71
  aws.run_with_backoff(quiet: true) { ec2.describe_instances } rescue nil
72
72
  end
@@ -77,6 +77,8 @@ describe MovableInk::AWS do
77
77
  ec2.stub_responses(:describe_instances, 'RequestLimitExceeded')
78
78
 
79
79
  expect(aws).to receive(:notify_and_sleep).exactly(9).times
80
+ expect(aws).to receive(:notify_slack).exactly(1).times
81
+ expect(STDOUT).to receive(:puts).exactly(1).times
80
82
  expect{ aws.run_with_backoff { ec2.describe_instances } }.to raise_error(MovableInk::AWS::Errors::FailedWithBackoff)
81
83
  end
82
84
  end
@@ -37,6 +37,27 @@ describe MovableInk::AWS::EC2 do
37
37
  ])
38
38
  }
39
39
 
40
+ it 'will read mi_env from disk when the cache file exists' do
41
+ f = Tempfile.new('cache')
42
+ f.write('staging')
43
+ f.close
44
+ allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
45
+ expect(aws.mi_env).to eq('staging')
46
+ end
47
+
48
+ it 'will read tag data if the cache file is empty' do
49
+ ec2.stub_responses(:describe_tags, tag_data)
50
+ allow(aws).to receive(:my_region).and_return('us-east-1')
51
+ allow(aws).to receive(:instance_id).and_return('i-12345')
52
+ allow(aws).to receive(:ec2).and_return(ec2)
53
+
54
+ f = Tempfile.new('cache')
55
+ f.write('')
56
+ f.close
57
+ allow(aws).to receive(:mi_env_cache_file_path).and_return(f.path)
58
+ expect(aws.mi_env).to eq('test')
59
+ end
60
+
40
61
  it "should find the environment from the current instance's tags" do
41
62
  ec2.stub_responses(:describe_tags, tag_data)
42
63
  allow(aws).to receive(:my_region).and_return('us-east-1')
@@ -82,6 +82,8 @@ describe MovableInk::AWS::SSM do
82
82
  allow(aws).to receive(:ssm_client).and_return(1)
83
83
  allow(aws).to receive(:ssm_client_failover).and_return(2)
84
84
  allow(aws).to receive(:notify_and_sleep).and_return(nil)
85
+ allow(aws).to receive(:notify_slack).and_return(nil)
86
+ allow(STDOUT).to receive(:puts).and_return(nil)
85
87
 
86
88
  results = []
87
89
  calls = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MovableInkAWS
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Chesler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-06 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -198,10 +198,12 @@ executables: []
198
198
  extensions: []
199
199
  extra_rdoc_files: []
200
200
  files:
201
+ - ".github/workflows/pr-lint.yaml"
201
202
  - ".travis.yml"
202
203
  - Gemfile
203
204
  - Gemfile.lock
204
205
  - MovableInkAWS.gemspec
206
+ - PULL_REQUEST_TEMPLATE.md
205
207
  - README.md
206
208
  - lib/movable_ink/aws.rb
207
209
  - lib/movable_ink/aws/api_gateway.rb