hybrid_platforms_conductor 32.3.6 → 32.4.0

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: e16a6630a51ed9208fa4a3cecfce6604c65a39cb782d9efa426898ec980d5071
4
- data.tar.gz: 33f38588a1b795e323f76e909ef301905cacf9d77c0a418ac0809713960659b6
3
+ metadata.gz: 51da406ed4d19996c3802636ee0b1f9034b7c4505e746a11863f42e24dd7e81e
4
+ data.tar.gz: bc39ae4e01d39dd9468baac3ee370abf63de7f0313882d5bf84ea75850da6a01
5
5
  SHA512:
6
- metadata.gz: 16a3b130741673e1ce4bfee15a5a4d8c45c66e5712e130a746f2d6be1e9940a1052a2c9195cce748831ca1652cc52255002226b31c0494516250b5359074c592
7
- data.tar.gz: 920f8a21967bc69ecaf6072eec422e119e989415ddcd26d9e42e2d38779a35ddcfe58f5819cd3165c12799cf297dc5530da9a8d80ea6ae8c6a81c662d62c8fda
6
+ metadata.gz: 3363c4a1314e44fd3ebf0fc87943b49124b1c751e9e136357f7e8497b4d7b76b9f8e312831391bf85a6aa5b97d568937a44dbada7ae2deecbfe64be8a00e08da
7
+ data.tar.gz: 711f95a3e86978cf362589724ad9cbc4729811f5870cbce77b3b78c334f2100ae1039628368b931430e3f94fdd9acc72888a339fbc6a2f8102c9679fc39563a5
@@ -18,8 +18,31 @@ module HybridPlatformsConductor
18
18
  # Gives ways to deploy on several nodes
19
19
  class Deployer
20
20
 
21
+ # Extend the Config DSL
22
+ module ConfigDSLExtension
23
+
24
+ # Integer: Timeout (in seconds) for packaging repositories
25
+ attr_reader :packaging_timeout_secs
26
+
27
+ # Mixin initializer
28
+ def init_deployer_config
29
+ @packaging_timeout_secs = 60
30
+ end
31
+
32
+ # Set the packaging timeout
33
+ #
34
+ # Parameters::
35
+ # * *packaging_timeout_secs* (Integer): The packaging timeout, in seconds
36
+ def packaging_timeout(packaging_timeout_secs)
37
+ @packaging_timeout_secs = packaging_timeout_secs
38
+ end
39
+
40
+ end
41
+
21
42
  include LoggerHelpers
22
43
 
44
+ Config.extend_config_dsl_with ConfigDSLExtension, :init_nodes_handler_config
45
+
23
46
  # Do we use why-run mode while deploying? [default = false]
24
47
  # Boolean
25
48
  attr_accessor :use_why_run
@@ -135,9 +158,6 @@ module HybridPlatformsConductor
135
158
  # String: File used as a Futex for packaging
136
159
  PACKAGING_FUTEX_FILE = "#{Dir.tmpdir}/hpc_packaging"
137
160
 
138
- # Integer: Timeout in seconds to get the packaging Futex
139
- PACKAGING_FUTEX_TIMEOUT = 60
140
-
141
161
  # Deploy on a given list of nodes selectors.
142
162
  # The workflow is the following:
143
163
  # 1. Package the services to be deployed, considering the nodes, services and context (options, secrets, environment...)
@@ -176,7 +196,7 @@ module HybridPlatformsConductor
176
196
 
177
197
  # Package the deployment
178
198
  # Protect packaging by a Futex
179
- Futex.new(PACKAGING_FUTEX_FILE, timeout: PACKAGING_FUTEX_TIMEOUT).open do
199
+ Futex.new(PACKAGING_FUTEX_FILE, timeout: @config.packaging_timeout_secs).open do
180
200
  section 'Packaging deployment' do
181
201
  @services_handler.package(
182
202
  services: services_to_deploy,
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '32.3.6'
3
+ VERSION = '32.4.0'
4
4
 
5
5
  end
@@ -0,0 +1,15 @@
1
+ describe HybridPlatformsConductor::Deployer do
2
+
3
+ context 'checking deployer specific config DSL' do
4
+
5
+ it 'declares a packaging timeout' do
6
+ with_repository do |repository|
7
+ with_platforms('packaging_timeout 666') do
8
+ expect(test_config.packaging_timeout_secs).to eq 666
9
+ end
10
+ end
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  module HybridPlatformsConductorTest
2
4
 
3
5
  module Helpers
@@ -76,6 +78,9 @@ module HybridPlatformsConductorTest
76
78
  #
77
79
  # Parameters::
78
80
  # * *nodes_info* (Hash): Node info to give the platform [default: 1 node having 1 service]
81
+ # * *expect_package* (Boolean): Should we expect packaging? [default: true]
82
+ # * *expect_prepare_for_deploy* (Boolean): Should we expect calls to prepare for deploy? [default: true]
83
+ # * *expect_connections_to_nodes* (Boolean): Should we expect connections to nodes? [default: true]
79
84
  # * *expect_default_actions* (Boolean): Should we expect default actions? [default: true]
80
85
  # * *expect_sudo* (Boolean): Do we expect sudo to be used in commands? [default: true]
81
86
  # * *expect_secrets* (Hash): Secrets to be expected during deployment [default: {}]
@@ -90,6 +95,9 @@ module HybridPlatformsConductorTest
90
95
  # * *repository* (String): Path to the repository
91
96
  def with_platform_to_deploy(
92
97
  nodes_info: { nodes: { 'node' => { services: %w[service] } } },
98
+ expect_package: true,
99
+ expect_prepare_for_deploy: true,
100
+ expect_connections_to_nodes: true,
93
101
  expect_default_actions: true,
94
102
  expect_sudo: true,
95
103
  expect_secrets: {},
@@ -102,40 +110,52 @@ module HybridPlatformsConductorTest
102
110
  )
103
111
  platform_name = check_mode ? 'platform' : 'my_remote_platform'
104
112
  with_test_platform(nodes_info, !check_mode, additional_config) do |repository|
105
- with_connections_mocked_on(nodes_info[:nodes].keys) do
106
- # Mock the ServicesHandler accesses
107
- expect_services_to_deploy = Hash[nodes_info[:nodes].map do |node, node_info|
108
- [node, node_info[:services]]
109
- end]
110
- unless check_mode
111
- expect(test_services_handler).to receive(:deploy_allowed?).with(
112
- services: expect_services_to_deploy,
113
- secrets: expect_secrets,
114
- local_environment: expect_local_environment
115
- ) do
116
- nil
117
- end
113
+ # Mock the ServicesHandler accesses
114
+ expect_services_to_deploy = Hash[nodes_info[:nodes].map do |node, node_info|
115
+ [node, node_info[:services]]
116
+ end]
117
+ unless check_mode
118
+ expect(test_services_handler).to receive(:deploy_allowed?).with(
119
+ services: expect_services_to_deploy,
120
+ secrets: expect_secrets,
121
+ local_environment: expect_local_environment
122
+ ) do
123
+ nil
118
124
  end
125
+ end
126
+ if expect_package
119
127
  expect(test_services_handler).to receive(:package).with(
120
128
  services: expect_services_to_deploy,
121
129
  secrets: expect_secrets,
122
130
  local_environment: expect_local_environment
123
131
  )
132
+ else
133
+ expect(test_services_handler).not_to receive(:package)
134
+ end
135
+ if expect_prepare_for_deploy
124
136
  expect(test_services_handler).to receive(:prepare_for_deploy).with(
125
137
  services: expect_services_to_deploy,
126
138
  secrets: expect_secrets,
127
139
  local_environment: expect_local_environment,
128
140
  why_run: check_mode
129
141
  )
130
- expect_actions_executor_runs(expected_actions_for_deploy_on(
131
- services: expect_services_to_deploy,
132
- check_mode: check_mode,
133
- sudo: expect_sudo,
134
- additional_expected_actions: expect_additional_actions,
135
- expect_concurrent_actions: expect_concurrent_actions,
136
- expect_actions_timeout: expect_actions_timeout
137
- )) if expect_default_actions
138
- test_deployer.use_why_run = true if check_mode
142
+ else
143
+ expect(test_services_handler).not_to receive(:prepare_for_deploy)
144
+ end
145
+ test_deployer.use_why_run = true if check_mode
146
+ if expect_connections_to_nodes
147
+ with_connections_mocked_on(nodes_info[:nodes].keys) do
148
+ expect_actions_executor_runs(expected_actions_for_deploy_on(
149
+ services: expect_services_to_deploy,
150
+ check_mode: check_mode,
151
+ sudo: expect_sudo,
152
+ additional_expected_actions: expect_additional_actions,
153
+ expect_concurrent_actions: expect_concurrent_actions,
154
+ expect_actions_timeout: expect_actions_timeout
155
+ )) if expect_default_actions
156
+ yield repository
157
+ end
158
+ else
139
159
  yield repository
140
160
  end
141
161
  end
@@ -360,6 +380,31 @@ module HybridPlatformsConductorTest
360
380
  end
361
381
  end
362
382
 
383
+ it 'fails when packaging timeout has been reached while taking the futex' do
384
+ with_platform_to_deploy(
385
+ additional_config: 'packaging_timeout 1',
386
+ expect_package: false,
387
+ expect_prepare_for_deploy: false,
388
+ expect_connections_to_nodes: false
389
+ ) do
390
+ # Simulate another process taking the packaging futex
391
+ futex_file = HybridPlatformsConductor::Deployer.const_get(:PACKAGING_FUTEX_FILE)
392
+ Futex.new(futex_file).open do
393
+ # Expect the error to be raised within 2 seconds (as it should timeout after 1 second)
394
+ begin
395
+ Timeout::timeout(2) {
396
+ expect { test_deployer.deploy_on('node') }.to raise_error(
397
+ Futex::CantLock,
398
+ /can't get exclusive access to the file #{Regexp.escape(futex_file)} because of the lock at #{Regexp.escape(futex_file)}\.lock, after 1\.\d+s of waiting/
399
+ )
400
+ }
401
+ rescue Timeout::Error
402
+ raise 'The packaging timeout (set to 1 seconds) did not fire within 2 seconds. Looks like it is not working properly.'
403
+ end
404
+ end
405
+ end
406
+ end
407
+
363
408
  context 'checking deployment retries' do
364
409
 
365
410
  # Prepare a platform ready to test deployments' retries on.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hybrid_platforms_conductor
3
3
  version: !ruby/object:Gem::Version
4
- version: 32.3.6
4
+ version: 32.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: range_operators
@@ -281,20 +281,20 @@ description: Provides a complete toolset to help DevOps maintain, deploy, monito
281
281
  email:
282
282
  - muriel@x-aeon.com
283
283
  executables:
284
- - run
285
- - last_deploys
286
- - dump_nodes_json
287
284
  - test
288
- - nodes_to_deploy
289
- - check-node
290
- - deploy
285
+ - topograph
286
+ - dump_nodes_json
291
287
  - free_veids
292
- - ssh_config
293
288
  - report
294
- - topograph
295
289
  - setup
296
- - free_ips
290
+ - deploy
291
+ - last_deploys
297
292
  - get_impacted_nodes
293
+ - ssh_config
294
+ - run
295
+ - nodes_to_deploy
296
+ - check-node
297
+ - free_ips
298
298
  extensions: []
299
299
  extra_rdoc_files: []
300
300
  files:
@@ -435,6 +435,7 @@ files:
435
435
  - spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb
436
436
  - spec/hybrid_platforms_conductor_test/api/config_spec.rb
437
437
  - spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb
438
+ - spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb
438
439
  - spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb
439
440
  - spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb
440
441
  - spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb