MovableInkAWS 2.11.3 → 2.11.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/movable_ink/aws/ec2.rb +27 -6
- data/lib/movable_ink/version.rb +1 -1
- data/spec/ec2_spec.rb +36 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 361a67ed7171eeb934284d6a93146745556b502bc4e1d5bff5020a6bedf2616f
|
|
4
|
+
data.tar.gz: 28d07f7b416cd307d0d0e8eddda7f33d8cc011c47728ce4afd43046321750256
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '069a70e2f69250c0f7f3aa2deb148bf3a738ac5f6f176e7ea8f006f0ebd34dc851cb829756db3be0a33a3a94a2cdb7266e776dfa8fa9237519a6ed1c4d9f2fd9'
|
|
7
|
+
data.tar.gz: 5e4c0a3b0efe1bec352b885227b91503d59e5c97e0c3a4583492f7e630e24545100873101817de2467b43bea6f7b1677f0885b2d4918622970116e305ae2f994
|
data/Gemfile.lock
CHANGED
data/lib/movable_ink/aws/ec2.rb
CHANGED
|
@@ -161,7 +161,7 @@ module MovableInk
|
|
|
161
161
|
value: role
|
|
162
162
|
}
|
|
163
163
|
],
|
|
164
|
-
placement: { availability_zone:
|
|
164
|
+
placement: { availability_zone: endpoint.Service.dig('Meta', 'external-k8s-topology-zone') }
|
|
165
165
|
})
|
|
166
166
|
end
|
|
167
167
|
|
|
@@ -244,6 +244,23 @@ module MovableInk
|
|
|
244
244
|
redis_instances.flatten.shuffle
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
+
def describe_ip(public_ip:)
|
|
248
|
+
expected_errors = [
|
|
249
|
+
MovableInk::AWS::Errors::ExpectedError.new(Aws::EC2::Errors::InvalidAddressNotFound, [/Address \'#{public_ip}\' not found./])
|
|
250
|
+
]
|
|
251
|
+
begin
|
|
252
|
+
run_with_backoff(expected_errors: expected_errors) do
|
|
253
|
+
response = ec2_with_retries.describe_addresses({
|
|
254
|
+
public_ips: [public_ip]
|
|
255
|
+
})
|
|
256
|
+
raise MovableInk::AWS::Errors::ServiceError if response.length > 1
|
|
257
|
+
return response[0]
|
|
258
|
+
end
|
|
259
|
+
rescue MovableInk::AWS::Errors::ServiceError, Aws::EC2::Errors::InvalidAddressNotFound
|
|
260
|
+
return nil
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
247
264
|
def elastic_ips
|
|
248
265
|
@all_elastic_ips ||= run_with_backoff do
|
|
249
266
|
ec2.describe_addresses.addresses
|
|
@@ -258,20 +275,24 @@ module MovableInk
|
|
|
258
275
|
unassigned_elastic_ips.select { |address| address.tags.detect { |t| t.key == 'mi:roles' && t.value == role } }
|
|
259
276
|
end
|
|
260
277
|
|
|
261
|
-
def assign_ip_address_with_retries(role:)
|
|
278
|
+
def assign_ip_address_with_retries(role:, allow_reassociation: false)
|
|
279
|
+
response = nil
|
|
262
280
|
run_with_backoff do
|
|
263
|
-
ec2_with_retries.associate_address({
|
|
281
|
+
response = ec2_with_retries.associate_address({
|
|
264
282
|
instance_id: instance_id,
|
|
265
|
-
allocation_id: available_elastic_ips(role: role).sample.allocation_id
|
|
283
|
+
allocation_id: available_elastic_ips(role: role).sample.allocation_id,
|
|
284
|
+
allow_reassociation: allow_reassociation
|
|
266
285
|
})
|
|
267
286
|
end
|
|
287
|
+
response
|
|
268
288
|
end
|
|
269
289
|
|
|
270
|
-
def assign_ip_address(role:)
|
|
290
|
+
def assign_ip_address(role:, allow_reassociation: false)
|
|
271
291
|
run_with_backoff do
|
|
272
292
|
ec2.associate_address({
|
|
273
293
|
instance_id: instance_id,
|
|
274
|
-
allocation_id: available_elastic_ips(role: role).sample.allocation_id
|
|
294
|
+
allocation_id: available_elastic_ips(role: role).sample.allocation_id,
|
|
295
|
+
allow_reassociation: allow_reassociation
|
|
275
296
|
})
|
|
276
297
|
end
|
|
277
298
|
end
|
data/lib/movable_ink/version.rb
CHANGED
data/spec/ec2_spec.rb
CHANGED
|
@@ -418,6 +418,7 @@ describe MovableInk::AWS::EC2 do
|
|
|
418
418
|
"Meta": {
|
|
419
419
|
"external-source": "kubernetes",
|
|
420
420
|
"external-k8s-ns": "default",
|
|
421
|
+
"external-k8s-topology-zone": "us-east-1a",
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
424
|
}
|
|
@@ -484,7 +485,7 @@ describe MovableInk::AWS::EC2 do
|
|
|
484
485
|
expect(roles_tag[:value]).to eq('kubernetes-service-name')
|
|
485
486
|
expect(backend.instance_id).to eq(nil)
|
|
486
487
|
expect(backend.private_ip_address).to eq('10.0.0.1')
|
|
487
|
-
expect(backend.
|
|
488
|
+
expect(backend.placement[:availability_zone]).to eq('us-east-1a')
|
|
488
489
|
end
|
|
489
490
|
end
|
|
490
491
|
|
|
@@ -692,6 +693,40 @@ describe MovableInk::AWS::EC2 do
|
|
|
692
693
|
|
|
693
694
|
expect(aws.assign_ip_address(role: 'some_role').association_id).to eq('eipassoc-3')
|
|
694
695
|
end
|
|
696
|
+
|
|
697
|
+
it "should assign an elastic IP with allow_reassociation flag" do
|
|
698
|
+
ec2.stub_responses(:describe_addresses, elastic_ip_data)
|
|
699
|
+
ec2.stub_responses(:associate_address, associate_address_data)
|
|
700
|
+
allow(aws).to receive(:my_region).and_return('us-east-1')
|
|
701
|
+
allow(aws).to receive(:instance_id).and_return('i-12345')
|
|
702
|
+
allow(aws).to receive(:ec2).and_return(ec2)
|
|
703
|
+
|
|
704
|
+
expect(aws.assign_ip_address(role: 'some_role', allow_reassociation: true).association_id).to eq('eipassoc-3')
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
it "should assign an elastic IP with retries and return response" do
|
|
708
|
+
ec2.stub_responses(:describe_addresses, elastic_ip_data)
|
|
709
|
+
ec2.stub_responses(:associate_address, associate_address_data)
|
|
710
|
+
allow(aws).to receive(:my_region).and_return('us-east-1')
|
|
711
|
+
allow(aws).to receive(:instance_id).and_return('i-12345')
|
|
712
|
+
allow(aws).to receive(:ec2).and_return(ec2)
|
|
713
|
+
allow(aws).to receive(:ec2_with_retries).and_return(ec2)
|
|
714
|
+
|
|
715
|
+
response = aws.assign_ip_address_with_retries(role: 'some_role')
|
|
716
|
+
expect(response.association_id).to eq('eipassoc-3')
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
it "should assign an elastic IP with retries and allow_reassociation flag" do
|
|
720
|
+
ec2.stub_responses(:describe_addresses, elastic_ip_data)
|
|
721
|
+
ec2.stub_responses(:associate_address, associate_address_data)
|
|
722
|
+
allow(aws).to receive(:my_region).and_return('us-east-1')
|
|
723
|
+
allow(aws).to receive(:instance_id).and_return('i-12345')
|
|
724
|
+
allow(aws).to receive(:ec2).and_return(ec2)
|
|
725
|
+
allow(aws).to receive(:ec2_with_retries).and_return(ec2)
|
|
726
|
+
|
|
727
|
+
response = aws.assign_ip_address_with_retries(role: 'some_role', allow_reassociation: true)
|
|
728
|
+
expect(response.association_id).to eq('eipassoc-3')
|
|
729
|
+
end
|
|
695
730
|
end
|
|
696
731
|
|
|
697
732
|
context 'elastic ips' do
|
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: 2.11.
|
|
4
|
+
version: 2.11.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- MI SRE
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-12-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-core
|