MovableInkAWS 2.11.5 → 2.11.7

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: 361a67ed7171eeb934284d6a93146745556b502bc4e1d5bff5020a6bedf2616f
4
- data.tar.gz: 28d07f7b416cd307d0d0e8eddda7f33d8cc011c47728ce4afd43046321750256
3
+ metadata.gz: 6b00042330c59a011318a6718225fcfbaea513c07c4c92c10edc6469281b4b73
4
+ data.tar.gz: 4fb15e463994046e52e35f0d8094b2f91e9a501636a4b107eb9b75f3bcc759a6
5
5
  SHA512:
6
- metadata.gz: '069a70e2f69250c0f7f3aa2deb148bf3a738ac5f6f176e7ea8f006f0ebd34dc851cb829756db3be0a33a3a94a2cdb7266e776dfa8fa9237519a6ed1c4d9f2fd9'
7
- data.tar.gz: 5e4c0a3b0efe1bec352b885227b91503d59e5c97e0c3a4583492f7e630e24545100873101817de2467b43bea6f7b1677f0885b2d4918622970116e305ae2f994
6
+ metadata.gz: dbbbb81690b663d8388ed2dd850f9c12f81602aecfc79d9a20a62e8d7d0558088c854ede1b42a1c444721993cc1c84bdafa329d4c7176ca95c25db9032236c75
7
+ data.tar.gz: 7d43ffce9e0fdff9ea3bbb0925b5c07dcfd172363e8646dce8a54d54388a8478dd5628db20c1373a3c9e25dfa96682c028f0c391f3b19707b01e829c65b685bc
@@ -13,13 +13,13 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
16
+ ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0']
17
17
 
18
18
  steps:
19
- - uses: actions/checkout@v4
19
+ - uses: actions/checkout@v6
20
20
 
21
21
  - name: Install ruby
22
- uses: ruby/setup-ruby@v1
22
+ uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
23
23
  with:
24
24
  ruby-version: ${{ matrix.ruby-version }}
25
25
 
@@ -35,10 +35,10 @@ jobs:
35
35
  if: startsWith(github.ref, 'refs/tags/')
36
36
 
37
37
  steps:
38
- - uses: actions/checkout@v4
38
+ - uses: actions/checkout@v6
39
39
 
40
40
  - name: Install ruby
41
- uses: ruby/setup-ruby@v1
41
+ uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
42
42
  with:
43
43
  ruby-version: 3.1
44
44
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- MovableInkAWS (2.11.5)
4
+ MovableInkAWS (2.11.7)
5
5
  aws-sdk-athena (~> 1)
6
6
  aws-sdk-autoscaling (~> 1)
7
7
  aws-sdk-cloudwatch (~> 1)
@@ -20,6 +20,7 @@ PATH
20
20
  diplomat (= 2.6.4)
21
21
  faraday (~> 2)
22
22
  httparty (= 0.23.1)
23
+ ostruct
23
24
 
24
25
  GEM
25
26
  remote: https://rubygems.org/
@@ -105,6 +106,7 @@ GEM
105
106
  logger (1.7.0)
106
107
  mini_mime (1.1.5)
107
108
  multi_xml (0.6.0)
109
+ ostruct (0.5.2)
108
110
  public_suffix (5.1.1)
109
111
  rexml (3.4.1)
110
112
  rspec (3.13.1)
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_runtime_dependency 'aws-sdk-sns', '~> 1'
27
27
  s.add_runtime_dependency 'aws-sdk-ssm', '~> 1'
28
28
  s.add_runtime_dependency 'aws-sigv4', '~> 1'
29
+ s.add_runtime_dependency 'ostruct'
29
30
  s.add_runtime_dependency 'httparty', '0.23.1'
30
31
  s.add_runtime_dependency 'diplomat', '2.6.4'
31
32
 
@@ -136,7 +136,11 @@ module MovableInk
136
136
  # within MI configuration
137
137
  Diplomat::Health.service(role.gsub('_', '-'), consul_service_options).map { |endpoint|
138
138
  if endpoint.Node.dig('Meta', 'external-source') == 'kubernetes'
139
+ # Legacy catalog sync
139
140
  map_k8s_consul_endpoint(endpoint, role)
141
+ elsif endpoint.Service && endpoint.Service.dig('Meta', 'managed-by') == 'consul-k8s-endpoints-controller'
142
+ # Consul mesh with service mesh sidecar
143
+ map_k8s_consul_mesh_endpoint(endpoint, role)
140
144
  else
141
145
  map_ec2_consul_endpoint(endpoint)
142
146
  end
@@ -165,6 +169,40 @@ module MovableInk
165
169
  })
166
170
  end
167
171
 
172
+ def map_k8s_consul_mesh_endpoint(endpoint, role)
173
+ OpenStruct.new ({
174
+ private_ip_address: endpoint.Service.dig('Address'),
175
+ instance_id: nil,
176
+ tags: [
177
+ {
178
+ key: 'Name',
179
+ value: endpoint.Service.dig('Meta', 'pod-name')
180
+ },
181
+ {
182
+ key: 'mi:roles',
183
+ value: role
184
+ },
185
+ {
186
+ key: 'mi:monitoring_roles',
187
+ value: role
188
+ },
189
+ {
190
+ key: 'k8s:namespace',
191
+ value: endpoint.Service.dig('Meta', 'k8s-namespace')
192
+ },
193
+ {
194
+ key: 'k8s:service',
195
+ value: endpoint.Service.dig('Meta', 'k8s-service-name')
196
+ },
197
+ {
198
+ key: 'k8s:pod-uid',
199
+ value: endpoint.Service.dig('Meta', 'pod-uid')
200
+ }
201
+ ],
202
+ placement: { availability_zone: endpoint.Service.dig('Locality', 'Zone') }
203
+ })
204
+ end
205
+
168
206
  def map_ec2_consul_endpoint(endpoint)
169
207
  OpenStruct.new ({
170
208
  private_ip_address: endpoint.Node.dig('Address'),
@@ -271,27 +309,31 @@ module MovableInk
271
309
  @unassigned_elastic_ips ||= elastic_ips.select { |address| address.association_id.nil? }
272
310
  end
273
311
 
274
- def available_elastic_ips(role:)
275
- unassigned_elastic_ips.select { |address| address.tags.detect { |t| t.key == 'mi:roles' && t.value == role } }
312
+ def available_elastic_ips(role:, eip_pool: nil)
313
+ if eip_pool
314
+ unassigned_elastic_ips.select { |address| address.tags.detect { |t| t.key == 'mi:eip-pool' && t.value == eip_pool } }
315
+ else
316
+ unassigned_elastic_ips.select { |address| address.tags.detect { |t| t.key == 'mi:roles' && t.value == role } }
317
+ end
276
318
  end
277
319
 
278
- def assign_ip_address_with_retries(role:, allow_reassociation: false)
320
+ def assign_ip_address_with_retries(role:, eip_pool: nil, allow_reassociation: false)
279
321
  response = nil
280
322
  run_with_backoff do
281
323
  response = ec2_with_retries.associate_address({
282
324
  instance_id: instance_id,
283
- allocation_id: available_elastic_ips(role: role).sample.allocation_id,
325
+ allocation_id: available_elastic_ips(role: role, eip_pool: eip_pool).sample.allocation_id,
284
326
  allow_reassociation: allow_reassociation
285
327
  })
286
328
  end
287
329
  response
288
330
  end
289
331
 
290
- def assign_ip_address(role:, allow_reassociation: false)
332
+ def assign_ip_address(role:, eip_pool: nil, allow_reassociation: false)
291
333
  run_with_backoff do
292
334
  ec2.associate_address({
293
335
  instance_id: instance_id,
294
- allocation_id: available_elastic_ips(role: role).sample.allocation_id,
336
+ allocation_id: available_elastic_ips(role: role, eip_pool: eip_pool).sample.allocation_id,
295
337
  allow_reassociation: allow_reassociation
296
338
  })
297
339
  end
@@ -1,5 +1,5 @@
1
1
  module MovableInk
2
2
  class AWS
3
- VERSION = '2.11.5'
3
+ VERSION = '2.11.7'
4
4
  end
5
5
  end
data/spec/ec2_spec.rb CHANGED
@@ -487,6 +487,99 @@ describe MovableInk::AWS::EC2 do
487
487
  expect(backend.private_ip_address).to eq('10.0.0.1')
488
488
  expect(backend.placement[:availability_zone]).to eq('us-east-1a')
489
489
  end
490
+
491
+ it "returns backends that are synced from consul mesh with service mesh sidecar" do
492
+ consul_mesh_service_instances = [
493
+ {
494
+ "Node": {
495
+ "ID": "",
496
+ "Node": "k8s-mesh-virtual-node",
497
+ "Address": "10.0.0.10",
498
+ "Datacenter": my_datacenter,
499
+ "TaggedAddresses": nil,
500
+ "Meta": {
501
+ "synthetic-node": "true"
502
+ },
503
+ "CreateIndex": 12345,
504
+ "ModifyIndex": 12345
505
+ },
506
+ "Service": {
507
+ "ID": "test-service-abc123-xyz-test-service",
508
+ "Service": "test-service",
509
+ "Tags": [],
510
+ "Address": "10.0.0.11",
511
+ "Meta": {
512
+ "k8s-namespace": "default",
513
+ "k8s-service-name": "test-service",
514
+ "managed-by": "consul-k8s-endpoints-controller",
515
+ "pod-name": "test-service-abc123-xyz",
516
+ "pod-uid": "00000000-0000-0000-0000-000000000000",
517
+ "synthetic-node": "true"
518
+ },
519
+ "Port": 8080,
520
+ "Weights": {
521
+ "Passing": 1,
522
+ "Warning": 1
523
+ },
524
+ "EnableTagOverride": false,
525
+ "Locality": {
526
+ "Region": "us-east-1",
527
+ "Zone": "us-east-1b"
528
+ },
529
+ "Proxy": {
530
+ "Mode": "",
531
+ "MeshGateway": {},
532
+ "Expose": {}
533
+ },
534
+ "Connect": {},
535
+ "PeerName": "",
536
+ "CreateIndex": 12345,
537
+ "ModifyIndex": 12345
538
+ },
539
+ "Checks": [
540
+ {
541
+ "Node": "k8s-mesh-virtual-node",
542
+ "CheckID": "default/test-service-abc123-xyz-test-service",
543
+ "Name": "Kubernetes Readiness Check",
544
+ "Status": "passing",
545
+ "Notes": "",
546
+ "Output": "Kubernetes health checks passing",
547
+ "ServiceID": "test-service-abc123-xyz-test-service",
548
+ "ServiceName": "test-service",
549
+ "ServiceTags": [],
550
+ "Type": "kubernetes-readiness",
551
+ "Interval": "",
552
+ "Timeout": "",
553
+ "ExposedPort": 0,
554
+ "Definition": {},
555
+ "CreateIndex": 12345,
556
+ "ModifyIndex": 12345
557
+ }
558
+ ]
559
+ }
560
+ ]
561
+
562
+ json = JSON.generate(consul_mesh_service_instances)
563
+ stub_request(:get, "https://localhost:8501/v1/health/service/test-service?cached=true&dc=#{my_datacenter}&passing=true&stale=true")
564
+ .to_return(status: 200, body: json, headers: {})
565
+
566
+ resp_instances = aws.instances(role: 'test-service', discovery_type: 'consul')
567
+ backend = resp_instances.first
568
+ name_tag = backend.tags.find {|t| t[:key] == 'Name' }
569
+ roles_tag = backend.tags.find {|t| t[:key] == 'mi:roles' }
570
+ k8s_namespace_tag = backend.tags.find {|t| t[:key] == 'k8s:namespace' }
571
+ k8s_service_tag = backend.tags.find {|t| t[:key] == 'k8s:service' }
572
+ k8s_pod_uid_tag = backend.tags.find {|t| t[:key] == 'k8s:pod-uid' }
573
+
574
+ expect(name_tag[:value]).to eq('test-service-abc123-xyz')
575
+ expect(roles_tag[:value]).to eq('test-service')
576
+ expect(k8s_namespace_tag[:value]).to eq('default')
577
+ expect(k8s_service_tag[:value]).to eq('test-service')
578
+ expect(k8s_pod_uid_tag[:value]).to eq('00000000-0000-0000-0000-000000000000')
579
+ expect(backend.instance_id).to eq(nil)
580
+ expect(backend.private_ip_address).to eq('10.0.0.11')
581
+ expect(backend.placement[:availability_zone]).to eq('us-east-1b')
582
+ end
490
583
  end
491
584
 
492
585
  context "ordered roles" 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.5
4
+ version: 2.11.7
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-12-21 00:00:00.000000000 Z
11
+ date: 2026-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '1'
223
+ - !ruby/object:Gem::Dependency
224
+ name: ostruct
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  - !ruby/object:Gem::Dependency
224
238
  name: httparty
225
239
  requirement: !ruby/object:Gem::Requirement