hybrid_platforms_conductor 32.3.6 → 32.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hybrid_platforms_conductor/deployer.rb +24 -4
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +15 -0
- data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +67 -22
- metadata +12 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51da406ed4d19996c3802636ee0b1f9034b7c4505e746a11863f42e24dd7e81e
|
4
|
+
data.tar.gz: bc39ae4e01d39dd9468baac3ee370abf63de7f0313882d5bf84ea75850da6a01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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,
|
@@ -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
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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.
|
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-
|
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
|
-
-
|
289
|
-
-
|
290
|
-
- deploy
|
285
|
+
- topograph
|
286
|
+
- dump_nodes_json
|
291
287
|
- free_veids
|
292
|
-
- ssh_config
|
293
288
|
- report
|
294
|
-
- topograph
|
295
289
|
- setup
|
296
|
-
-
|
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
|