hybrid_platforms_conductor 32.9.0 → 32.9.1
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 +4 -4
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +11 -0
- data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +3 -0
- data/lib/hybrid_platforms_conductor/version.rb +1 -1
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +44 -0
- data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +0 -14
- data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f1beb4de64ac4dcdc1de3e5063980ea4dab1b8ceef204baae0a9f4bf209f1f3
|
|
4
|
+
data.tar.gz: 0c5e65553da39646554d737c8a690939497a8c89f602a4eae01a4987fff994b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3129d3b37140c6488b2b6a8b6c1c8cb22ce745181a643925d9bb2fdc77de97a331660c8d5193dde940535d58b545576796d22a29008d181c73bbf7bb384c2251
|
|
7
|
+
data.tar.gz: 187c6215c37e89b924693c1819fea12f8cc444858ac575f9445b535ae9866a396b01dbc5baaf85ca4e8163d60c8865c931eca319c4824148fdd06029920b9710
|
|
@@ -23,6 +23,13 @@ module HybridPlatformsConductor
|
|
|
23
23
|
super
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
+
# Re-authenticate the Proxmox instance
|
|
27
|
+
# This can be useful when the API returns errors due to invalidated tokens
|
|
28
|
+
def reauthenticate
|
|
29
|
+
log_info 'Force re-authentication to Proxmox'
|
|
30
|
+
@auth_params = create_ticket
|
|
31
|
+
end
|
|
32
|
+
|
|
26
33
|
end
|
|
27
34
|
::Proxmox::Proxmox.prepend ProxmoxPatches
|
|
28
35
|
|
|
@@ -309,6 +316,8 @@ module HybridPlatformsConductor
|
|
|
309
316
|
log_warn "[ #{@node}/#{@environment} ] - Proxmox API call get #{path} returned error #{response} (attempt ##{idx_try}/#{proxmox_test_info[:api_max_retries]})"
|
|
310
317
|
raise "[ #{@node}/#{@environment} ] - Proxmox API call get #{path} returns #{response} continuously (tried #{idx_try + 1} times)" if idx_try >= proxmox_test_info[:api_max_retries]
|
|
311
318
|
idx_try += 1
|
|
319
|
+
# We have to reauthenticate: error 500 raised by Proxmox are often due to token being invalidated wrongly
|
|
320
|
+
proxmox.reauthenticate
|
|
312
321
|
sleep proxmox_test_info[:api_wait_between_retries_secs] + rand(5)
|
|
313
322
|
end
|
|
314
323
|
response
|
|
@@ -333,6 +342,8 @@ module HybridPlatformsConductor
|
|
|
333
342
|
task = nil
|
|
334
343
|
break if idx_try >= proxmox_test_info[:api_max_retries]
|
|
335
344
|
idx_try += 1
|
|
345
|
+
# We have to reauthenticate: error 500 raised by Proxmox are often due to token being invalidated wrongly
|
|
346
|
+
proxmox.reauthenticate
|
|
336
347
|
sleep proxmox_test_info[:api_wait_between_retries_secs] + rand(5)
|
|
337
348
|
end
|
|
338
349
|
end
|
|
@@ -653,6 +653,9 @@ class ProxmoxWaiter
|
|
|
653
653
|
break unless @gets_cache[path].is_a?(String) && @gets_cache[path] =~ /^NOK: error code = 5\d\d$/
|
|
654
654
|
raise "Proxmox API get #{path} returns #{@gets_cache[path]} continuously (tried #{idx_try + 1} times)" if idx_try >= @config['api_max_retries']
|
|
655
655
|
idx_try += 1
|
|
656
|
+
# We have to reauthenticate: error 500 raised by Proxmox are often due to token being invalidated wrongly
|
|
657
|
+
# TODO: Provide a way to do it properly in the official gem
|
|
658
|
+
@proxmox.instance_variable_set(:@auth_params, @proxmox.send(:create_ticket))
|
|
656
659
|
sleep @config['api_wait_between_retries_secs']
|
|
657
660
|
end
|
|
658
661
|
end
|
|
@@ -10,6 +10,7 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
|
|
|
10
10
|
with_sync_node do
|
|
11
11
|
mock_proxmox(mocked_pve_nodes: [{ 'pve_node_name' => {} }] * 5)
|
|
12
12
|
expect(call_reserve_proxmox_container(2, 128 * 1024, 4, max_retries: 5)).to eq(error: 'not_enough_resources')
|
|
13
|
+
expect_proxmox_actions_to_be []
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
|
|
@@ -25,6 +26,23 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
|
|
|
25
26
|
vm_id: 1000,
|
|
26
27
|
vm_ip: '192.168.0.100'
|
|
27
28
|
)
|
|
29
|
+
expect_proxmox_actions_to_be [
|
|
30
|
+
[
|
|
31
|
+
:post,
|
|
32
|
+
'nodes/pve_node_name/lxc',
|
|
33
|
+
{
|
|
34
|
+
'ostemplate' => 'test_template.iso',
|
|
35
|
+
'hostname' => 'test.hostname.my-domain.com',
|
|
36
|
+
'description' => /node: test_node\nenvironment: test_env/,
|
|
37
|
+
'cores' => 2,
|
|
38
|
+
'cpulimit' => 2,
|
|
39
|
+
'memory' => 1024,
|
|
40
|
+
'rootfs' => 'local-lvm:4',
|
|
41
|
+
'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.100/32',
|
|
42
|
+
'vmid' => 1000
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
]
|
|
28
46
|
end
|
|
29
47
|
end
|
|
30
48
|
|
|
@@ -34,6 +52,12 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
|
|
|
34
52
|
result = call_reserve_proxmox_container(2, 1024, 4, config: { api_max_retries: 4 })
|
|
35
53
|
expect(result[:error]).not_to eq nil
|
|
36
54
|
expect(result[:error]).to match /Unhandled exception from reserve_proxmox_container: Proxmox API get nodes\/pve_node_name\/lxc returns NOK: error code = 500 continuously \(tried 5 times\)/
|
|
55
|
+
expect_proxmox_actions_to_be [
|
|
56
|
+
[:create_ticket],
|
|
57
|
+
[:create_ticket],
|
|
58
|
+
[:create_ticket],
|
|
59
|
+
[:create_ticket]
|
|
60
|
+
]
|
|
37
61
|
end
|
|
38
62
|
end
|
|
39
63
|
|
|
@@ -45,6 +69,26 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
|
|
|
45
69
|
vm_id: 1000,
|
|
46
70
|
vm_ip: '192.168.0.100'
|
|
47
71
|
)
|
|
72
|
+
expect_proxmox_actions_to_be [
|
|
73
|
+
[:create_ticket],
|
|
74
|
+
[:create_ticket],
|
|
75
|
+
[:create_ticket],
|
|
76
|
+
[
|
|
77
|
+
:post,
|
|
78
|
+
'nodes/pve_node_name/lxc',
|
|
79
|
+
{
|
|
80
|
+
'ostemplate' => 'test_template.iso',
|
|
81
|
+
'hostname' => 'test.hostname.my-domain.com',
|
|
82
|
+
'description' => /node: test_node\nenvironment: test_env/,
|
|
83
|
+
'cores' => 2,
|
|
84
|
+
'cpulimit' => 2,
|
|
85
|
+
'memory' => 1024,
|
|
86
|
+
'rootfs' => 'local-lvm:4',
|
|
87
|
+
'net0' => 'name=eth0,bridge=vmbr0,gw=172.16.16.16,ip=192.168.0.100/32',
|
|
88
|
+
'vmid' => 1000
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
]
|
|
48
92
|
end
|
|
49
93
|
end
|
|
50
94
|
|
|
@@ -23,20 +23,6 @@ describe HybridPlatformsConductor::HpcPlugins::Provisioner::Proxmox do
|
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
it '' do
|
|
28
|
-
with_test_proxmox_platform do |instance|
|
|
29
|
-
mock_proxmox_calls_with [
|
|
30
|
-
# 1 - The info on existing containers
|
|
31
|
-
mock_proxmox_to_get_nodes_info,
|
|
32
|
-
# 2 - The start of the container - fail a few times
|
|
33
|
-
mock_proxmox_to_start_node(nbr_api_errors: 2)
|
|
34
|
-
]
|
|
35
|
-
instance.create
|
|
36
|
-
instance.start
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
26
|
it 'retries calls to the API when getting back errors 5xx' do
|
|
41
27
|
with_test_proxmox_platform do |instance|
|
|
42
28
|
mock_proxmox_calls_with [
|
|
@@ -156,6 +156,7 @@ module HybridPlatformsConductorTest
|
|
|
156
156
|
idx_try += 1
|
|
157
157
|
idx_try <= nbr_api_errors ? 'NOK: error code = 500' : task_name
|
|
158
158
|
end
|
|
159
|
+
expect(proxmox).to receive(:reauthenticate).exactly(nbr_api_errors - (task_status.nil? ? 1 : 0)).times
|
|
159
160
|
# Mock checking task status
|
|
160
161
|
unless task_status.nil?
|
|
161
162
|
# Mock checking task status
|
|
@@ -294,6 +295,7 @@ module HybridPlatformsConductorTest
|
|
|
294
295
|
]
|
|
295
296
|
end
|
|
296
297
|
end
|
|
298
|
+
expect(proxmox).to receive(:reauthenticate).exactly(nbr_api_errors - (status.nil? ? 1 : 0)).times
|
|
297
299
|
unless status.nil?
|
|
298
300
|
expect(proxmox).to receive(:get).with('nodes/pve_node_name/lxc/1024/status/current') do
|
|
299
301
|
{
|
|
@@ -641,6 +643,10 @@ module HybridPlatformsConductorTest
|
|
|
641
643
|
raise "Unknown Proxmox API post call: #{path}. Please adapt the test framework."
|
|
642
644
|
end
|
|
643
645
|
end
|
|
646
|
+
# Mock create_ticket
|
|
647
|
+
allow(proxmox).to receive(:create_ticket) do
|
|
648
|
+
@proxmox_actions << [:create_ticket]
|
|
649
|
+
end
|
|
644
650
|
proxmox
|
|
645
651
|
end
|
|
646
652
|
end,
|
|
@@ -808,7 +814,13 @@ module HybridPlatformsConductorTest
|
|
|
808
814
|
# Parameters::
|
|
809
815
|
# * *expected_proxmox_actions* (Array<Array>): Expected Proxmox actions
|
|
810
816
|
def expect_proxmox_actions_to_be(expected_proxmox_actions)
|
|
811
|
-
expect(@proxmox_actions.size).to eq
|
|
817
|
+
expect(@proxmox_actions.size).to eq(expected_proxmox_actions.size), <<~EOS
|
|
818
|
+
Expected #{expected_proxmox_actions.size} Proxmox actions, but got #{@proxmox_actions.size} instead:
|
|
819
|
+
----- Received:
|
|
820
|
+
#{@proxmox_actions.map(&:inspect).join("\n")}
|
|
821
|
+
----- Expected:
|
|
822
|
+
#{expected_proxmox_actions.map(&:inspect).join("\n")}
|
|
823
|
+
EOS
|
|
812
824
|
@proxmox_actions.zip(expected_proxmox_actions).each do |proxmox_action, expected_proxmox_action|
|
|
813
825
|
expect(proxmox_action.size).to eq expected_proxmox_action.size
|
|
814
826
|
expect(proxmox_action[0..1]).to eq expected_proxmox_action[0..1]
|
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.9.
|
|
4
|
+
version: 32.9.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-03-
|
|
11
|
+
date: 2021-03-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: range_operators
|