hybrid_platforms_conductor 32.4.1 → 32.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e0dfe56d0297ba7c9c90dfbf4737cd6b4754b20a36f7dec0962d62a19b5bf2b
4
- data.tar.gz: 3a0363efcb7dc771c9cf41911d3012fae0a764a465e4bd925f241a422d5f11b0
3
+ metadata.gz: 544df1af20b12202d76519a9ebb2a7ea824e676fca1d04af0b546baa759d97ae
4
+ data.tar.gz: 19aa74c8d6f634d1b8618ba5b701c2b4dfb4457db8f69b2db84a8f08563bc891
5
5
  SHA512:
6
- metadata.gz: e1dae403085c924a043dfee0185b46478eff9c99fa1d69848f5e92b571e4dfb1dc62ab1f80792d3b1928323eecf72a8f0904317b17facf3b92b6a07b82381112
7
- data.tar.gz: 6156b57048a690c5bc6e91ffd61a8276b84b2a2196206a8b77779ee25fe559aa4a4ec21bf741f015736cb3796b9bf4c33d9ec0203b4e4ff7c44a77c1d06fbe83
6
+ metadata.gz: c7aeb4324286b216d36b0b3f205af58dd3a92d1655d74d05275de1c911cf0137198dda7e3c23d226e0b0a5c0b127eeef4e79a22bc1f585d4058cb2f31abfc09f
7
+ data.tar.gz: 84493300be870ee61c7f154b92eee7b27cbcbcd8af7c7fe4cbeed0f853c982e00587aa6294230552a2526bd57e76716a7b8d157097ce33c254d6f2206a9c3fa9
@@ -10,6 +10,10 @@ module HybridPlatformsConductor
10
10
  # Connect to node using SSH
11
11
  class Ssh < HybridPlatformsConductor::Connector
12
12
 
13
+ # Exception raise when a node is not connectable using SSH
14
+ class NotConnectableError < RuntimeError
15
+ end
16
+
13
17
  module PlatformsDslSsh
14
18
 
15
19
  # Initialize the DSL
@@ -329,14 +333,18 @@ module HybridPlatformsConductor
329
333
  @nodes_handler.prefetch_metadata_of nodes, %i[private_ips hostname host_ip description]
330
334
  nodes.sort.each do |node|
331
335
  # Generate the conf for the node
332
- connection, gateway, gateway_user = connection_info_for(node)
333
- config_content << "# #{node} - #{connection} - #{@nodes_handler.get_description_of(node) || ''}\n"
334
- config_content << "Host #{ssh_aliases_for(node).join(' ')}\n"
335
- config_content << " Hostname #{connection}\n"
336
- config_content << " ProxyCommand #{ssh_exec} -q -W %h:%p #{gateway_user}@#{gateway}\n" unless gateway.nil?
337
- if @passwords.key?(node)
338
- config_content << " PreferredAuthentications password\n"
339
- config_content << " PubkeyAuthentication no\n"
336
+ begin
337
+ connection, gateway, gateway_user = connection_info_for(node)
338
+ config_content << "# #{node} - #{connection} - #{@nodes_handler.get_description_of(node) || ''}\n"
339
+ config_content << "Host #{ssh_aliases_for(node).join(' ')}\n"
340
+ config_content << " Hostname #{connection}\n"
341
+ config_content << " ProxyCommand #{ssh_exec} -q -W %h:%p #{gateway_user}@#{gateway}\n" unless gateway.nil?
342
+ if @passwords.key?(node)
343
+ config_content << " PreferredAuthentications password\n"
344
+ config_content << " PubkeyAuthentication no\n"
345
+ end
346
+ rescue NotConnectableError
347
+ config_content << "# #{node} - Not connectable using SSH - #{@nodes_handler.get_description_of(node) || ''}\n"
340
348
  end
341
349
  config_content << "\n"
342
350
  end
@@ -665,7 +673,7 @@ module HybridPlatformsConductor
665
673
  elsif @nodes_handler.get_hostname_of(node)
666
674
  @nodes_handler.get_hostname_of(node)
667
675
  else
668
- raise "No connection possible to #{node}"
676
+ raise NotConnectableError, "No connection possible to #{node}"
669
677
  end
670
678
  gateway = @nodes_handler.get_gateway_of node
671
679
  gateway_user = @nodes_handler.get_gateway_user_of node
@@ -173,7 +173,7 @@ module HybridPlatformsConductor
173
173
  # * *local_environment* (Boolean): Are we deploying to a local environment?
174
174
  def package(services:, secrets:, local_environment:)
175
175
  # This method should take all actions to prepare the repository to be deployed on nodes later.
176
- File.write('temporary_secrets_to_be_deployed.json', secrets)
176
+ File.write("#{@repository_path}/temporary_secrets_to_be_deployed.json", secrets.to_json)
177
177
  # Usually it is meant to package the deployment scripts.
178
178
  @cmd_runner.run_cmd "cd #{@repository_path} && ./scripts/package_in_debian_format.sh"
179
179
  end
@@ -12,14 +12,9 @@ module HybridPlatformsConductor
12
12
 
13
13
  class << self
14
14
 
15
- # List of deployments that have been packaged.
16
- # Each deployment has the following info:
17
- # * *platform_name* (String): The platform name
18
- # * *services* (Hash< String, Array<String> >): Services to be deployed, per node
19
- # * *secrets* (Hash): Secrets for which this has been packaged
20
- # * *local_environment* (Boolean): Has it been packaged for local environment?
15
+ # List of package IDs that have been packaged.
21
16
  # Make this at class level as several Deployer instances can be used in a multi-thread environmnent.
22
- # Array< Hash<Symbol, Object> >
17
+ # Array<Object>
23
18
  attr_reader :packaged_deployments
24
19
 
25
20
  end
@@ -114,21 +109,22 @@ module HybridPlatformsConductor
114
109
  )
115
110
  platforms_for(services).each do |platform, platform_services|
116
111
  platform_name = platform.name
117
- deployment_info = {
112
+ # Compute the package ID that is unique to this packaging, so that we don't mix it with others if needed.
113
+ package_id = {
118
114
  platform_name: platform_name,
119
- services: platform_services,
120
- secrets: secrets,
115
+ services: Hash[platform_services.map { |node, node_services| [node, node_services.sort] }].sort,
116
+ secrets: secrets.sort,
121
117
  local_environment: local_environment
122
118
  }
123
- if ServicesHandler.packaged_deployments.include?(deployment_info)
124
- log_debug "Platform #{platform_name} has already been packaged for this deployment. Won't package it another time."
119
+ if ServicesHandler.packaged_deployments.include?(package_id)
120
+ log_debug "Platform #{platform_name} has already been packaged for this deployment (package ID #{package_id}). Won't package it another time."
125
121
  else
126
122
  platform.package(
127
123
  services: platform_services,
128
124
  secrets: secrets,
129
125
  local_environment: local_environment
130
126
  )
131
- ServicesHandler.packaged_deployments << deployment_info
127
+ ServicesHandler.packaged_deployments << package_id
132
128
  end
133
129
  end
134
130
  end
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '32.4.1'
3
+ VERSION = '32.4.2'
4
4
 
5
5
  end
@@ -153,6 +153,24 @@ describe HybridPlatformsConductor::ActionsExecutor do
153
153
  end
154
154
  end
155
155
 
156
+ it 'generates a simple config for several nodes even when some of them can\'t be connected' do
157
+ with_test_platform(nodes: {
158
+ 'node1' => { meta: { host_ip: '192.168.42.1' } },
159
+ 'node2' => { meta: {} },
160
+ 'node3' => { meta: { host_ip: '192.168.42.3' } }
161
+ }) do
162
+ expect(ssh_config_for('node1')).to eq <<~EOS
163
+ Host hpc.node1
164
+ Hostname 192.168.42.1
165
+ EOS
166
+ expect(ssh_config_for('node2')).to eq "\n"
167
+ expect(ssh_config_for('node3')).to eq <<~EOS
168
+ Host hpc.node3
169
+ Hostname 192.168.42.3
170
+ EOS
171
+ end
172
+ end
173
+
156
174
  it 'selects nodes when generating the config' do
157
175
  with_test_platform(nodes: {
158
176
  'node1' => { meta: { host_ip: '192.168.42.1' } },
@@ -167,12 +185,6 @@ describe HybridPlatformsConductor::ActionsExecutor do
167
185
  end
168
186
  end
169
187
 
170
- it 'fails if a node can\'t be connected to' do
171
- with_test_platform(nodes: { 'node' => {} }) do
172
- expect { ssh_config_for('node') }.to raise_error(/No connection possible to node/)
173
- end
174
- end
175
-
176
188
  it 'generates an alias if the node has a hostname' do
177
189
  with_test_platform(nodes: { 'node' => { meta: { host_ip: '192.168.42.42', hostname: 'my_hostname.my_domain' } } }) do
178
190
  expect(ssh_config_for('node')).to eq <<~EOS
@@ -58,7 +58,7 @@ module HybridPlatformsConductorTest
58
58
  #
59
59
  # Parameters::
60
60
  # * *content* (String): hpc_config.rb's content
61
- # * Proc: Code called with the platforms.rb file created.
61
+ # * Proc: Code called with the hpc_config.rb file created.
62
62
  # * Parameters::
63
63
  # * *hybrid_platforms_dir* (String): The hybrid-platforms directory
64
64
  def with_platforms(content)
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.1
4
+ version: 32.4.2
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-03-03 00:00:00.000000000 Z
11
+ date: 2021-03-05 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
- - dump_nodes_json
284
+ - topograph
285
285
  - test
286
+ - free_veids
287
+ - free_ips
288
+ - nodes_to_deploy
286
289
  - last_deploys
287
290
  - check-node
288
- - setup
289
- - free_ips
290
- - ssh_config
291
- - deploy
291
+ - run
292
292
  - report
293
- - free_veids
294
293
  - get_impacted_nodes
295
- - run
296
- - nodes_to_deploy
297
- - topograph
294
+ - ssh_config
295
+ - deploy
296
+ - setup
297
+ - dump_nodes_json
298
298
  extensions: []
299
299
  extra_rdoc_files: []
300
300
  files: