hybrid_platforms_conductor 32.4.0 → 32.4.1

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: 51da406ed4d19996c3802636ee0b1f9034b7c4505e746a11863f42e24dd7e81e
4
- data.tar.gz: bc39ae4e01d39dd9468baac3ee370abf63de7f0313882d5bf84ea75850da6a01
3
+ metadata.gz: 4e0dfe56d0297ba7c9c90dfbf4737cd6b4754b20a36f7dec0962d62a19b5bf2b
4
+ data.tar.gz: 3a0363efcb7dc771c9cf41911d3012fae0a764a465e4bd925f241a422d5f11b0
5
5
  SHA512:
6
- metadata.gz: 3363c4a1314e44fd3ebf0fc87943b49124b1c751e9e136357f7e8497b4d7b76b9f8e312831391bf85a6aa5b97d568937a44dbada7ae2deecbfe64be8a00e08da
7
- data.tar.gz: 711f95a3e86978cf362589724ad9cbc4729811f5870cbce77b3b78c334f2100ae1039628368b931430e3f94fdd9acc72888a339fbc6a2f8102c9679fc39563a5
6
+ metadata.gz: e1dae403085c924a043dfee0185b46478eff9c99fa1d69848f5e92b571e4dfb1dc62ab1f80792d3b1928323eecf72a8f0904317b17facf3b92b6a07b82381112
7
+ data.tar.gz: 6156b57048a690c5bc6e91ffd61a8276b84b2a2196206a8b77779ee25fe559aa4a4ec21bf741f015736cb3796b9bf4c33d9ec0203b4e4ff7c44a77c1d06fbe83
data/bin/nodes_to_deploy CHANGED
@@ -72,11 +72,17 @@ unless ignore_deploy_info
72
72
  commit_id = node_deploy_info["commit_id_#{repo_idx}".to_sym]
73
73
  impacted_nodes = cache_impacted_nodes.dig(repo_name, commit_id)
74
74
  if impacted_nodes.nil?
75
- impacted_nodes, _single_impacted_nodes, _impacted_services, _impact_global = nodes_handler.impacted_nodes_from_git_diff(
76
- repo_name,
77
- from_commit: commit_id,
78
- to_commit: 'master'
79
- )
75
+ begin
76
+ impacted_nodes, _single_impacted_nodes, _impacted_services, _impact_global = nodes_handler.impacted_nodes_from_git_diff(
77
+ repo_name,
78
+ from_commit: commit_id,
79
+ to_commit: 'master'
80
+ )
81
+ rescue HybridPlatformsConductor::NodesHandler::GitError
82
+ # Consider the node was deployed with a non-release branch commit (as it is missing)
83
+ # So we have to make sure we deploy it again
84
+ impacted_nodes = [node]
85
+ end
80
86
  cache_impacted_nodes[repo_name] = {} unless cache_impacted_nodes.key?(repo_name)
81
87
  cache_impacted_nodes[repo_name][commit_id] = impacted_nodes
82
88
  end
@@ -40,6 +40,9 @@ module HybridPlatformsConductor
40
40
 
41
41
  include LoggerHelpers, ParallelThreads
42
42
 
43
+ class GitError < RuntimeError
44
+ end
45
+
43
46
  # Constructor
44
47
  #
45
48
  # Parameters::
@@ -484,7 +487,11 @@ module HybridPlatformsConductor
484
487
  def impacted_nodes_from_git_diff(platform_name, from_commit: 'master', to_commit: nil, smallest_set: false)
485
488
  platform = @platforms_handler.platform(platform_name)
486
489
  raise "Unkown platform #{platform_name}. Possible platforms are #{@platforms_handler.known_platforms.map(&:name).sort.join(', ')}" if platform.nil?
487
- _exit_status, stdout, _stderr = @cmd_runner.run_cmd "cd #{platform.repository_path} && git --no-pager diff --no-color #{from_commit} #{to_commit.nil? ? '' : to_commit}", log_to_stdout: log_debug?
490
+ begin
491
+ _exit_status, stdout, _stderr = @cmd_runner.run_cmd "cd #{platform.repository_path} && git --no-pager diff --no-color #{from_commit} #{to_commit.nil? ? '' : to_commit}", log_to_stdout: log_debug?
492
+ rescue CmdRunner::UnexpectedExitCodeError
493
+ raise GitError, $!.to_s
494
+ end
488
495
  # Parse the git diff output to create a structured diff
489
496
  # Hash< String, Hash< Symbol, Object > >: List of diffs info, per file name having a diff. Diffs info have the following properties:
490
497
  # * *moved_to* (String): The new file path, in case it has been moved [optional]
@@ -1,5 +1,5 @@
1
1
  module HybridPlatformsConductor
2
2
 
3
- VERSION = '32.4.0'
3
+ VERSION = '32.4.1'
4
4
 
5
5
  end
@@ -33,6 +33,16 @@ describe HybridPlatformsConductor::NodesHandler do
33
33
  end
34
34
  end
35
35
 
36
+ it 'fails when the commit id is invalid' do
37
+ with_test_platform({}, true) do
38
+ with_cmd_runner_mocked([
39
+ [/cd .+\/my_remote_platform && git --no-pager diff --no-color invalid_id/, proc { raise HybridPlatformsConductor::CmdRunner::UnexpectedExitCodeError, 'Mocked git error due to an invalid commit id' }]
40
+ ]) do
41
+ expect { test_nodes_handler.impacted_nodes_from_git_diff('my_remote_platform', from_commit: 'invalid_id') }.to raise_error HybridPlatformsConductor::NodesHandler::GitError, 'Mocked git error due to an invalid commit id'
42
+ end
43
+ end
44
+ end
45
+
36
46
  it 'diffs to another commit if asked' do
37
47
  with_test_platform({}, true) do
38
48
  with_cmd_runner_mocked([
@@ -106,6 +106,31 @@ describe 'nodes_to_deploy executable' do
106
106
  end
107
107
  end
108
108
 
109
+ it 'considers nodes having invalid commit ids in their logs to be deployed' do
110
+ with_test_platform_for_nodes_to_deploy do
111
+ expect_actions_executor_runs([proc do |actions|
112
+ expect(actions).to eq(
113
+ 'node1' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" },
114
+ 'node2' => { remote_bash: "cd /var/log/deployments && ls -t | head -1 | xargs sed '/===== STDOUT =====/q'" }
115
+ )
116
+ {
117
+ 'node1' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef1", ''],
118
+ 'node2' => [0, "repo_name_0: platform\nexit_status: 0\ncommit_id_0: abcdef2", '']
119
+ }
120
+ end])
121
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef1', to_commit: 'master') do
122
+ raise HybridPlatformsConductor::NodesHandler::GitError, 'Mocked git error due to an invalid commit id'
123
+ end
124
+ expect(test_nodes_handler).to receive(:impacted_nodes_from_git_diff).with('platform', from_commit: 'abcdef2', to_commit: 'master') { [%w[], [], [], false] }
125
+ exit_code, stdout, stderr = run 'nodes_to_deploy'
126
+ expect(exit_code).to eq 0
127
+ expect(stdout).to eq <<~EOS
128
+ ===== Nodes to deploy =====
129
+ node1
130
+ EOS
131
+ end
132
+ end
133
+
109
134
  it 'ignores impacts if asked' do
110
135
  with_test_platform_for_nodes_to_deploy do
111
136
  exit_code, stdout, stderr = run 'nodes_to_deploy', '--ignore-deployed-info'
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.0
4
+ version: 32.4.1
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-19 00:00:00.000000000 Z
11
+ date: 2021-03-03 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
- - test
285
- - topograph
286
284
  - dump_nodes_json
287
- - free_veids
288
- - report
285
+ - test
286
+ - last_deploys
287
+ - check-node
289
288
  - setup
289
+ - free_ips
290
+ - ssh_config
290
291
  - deploy
291
- - last_deploys
292
+ - report
293
+ - free_veids
292
294
  - get_impacted_nodes
293
- - ssh_config
294
295
  - run
295
296
  - nodes_to_deploy
296
- - check-node
297
- - free_ips
297
+ - topograph
298
298
  extensions: []
299
299
  extra_rdoc_files: []
300
300
  files: