1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #6406: Retry vm_info in flow deployment

After a VM Template is instantiated, the associated VM info is
retreived. This commit retries in case of failure up to 3 times with
linear spacing. If VM info cannot be retreived flow deployment fails
This commit is contained in:
Ruben S. Montero 2023-11-23 14:37:05 +01:00
parent c9ed2fe5df
commit 4b73241133
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -468,8 +468,7 @@ module OpenNebula
@body['last_vmname'] += 1
Log.debug LOG_COMP,
"Role #{name} : Trying to instantiate " \
"template #{template_id}, with name #{vm_name}",
"Role #{name} : Instantiate template #{template_id}, name #{vm_name}",
@service.id
vm_id = template.instantiate(vm_name, on_hold?, extra_template)
@ -481,33 +480,52 @@ module OpenNebula
"#{template_id}; #{vm_id.message}"
Log.error LOG_COMP, msg, @service.id
@service.log_error(msg)
return [false, 'Error trying to instantiate the VM ' \
"Template #{template_id} in Role " \
return [false, "Error instantiating VM Template #{template_id} in Role " \
"#{name}: #{vm_id.message}"]
end
Log.debug LOG_COMP, "Role #{name} : Instantiate success," \
" VM ID #{vm_id}", @service.id
node = {
'deploy_id' => vm_id
}
Log.debug LOG_COMP,
"Role #{name} : Instantiate success, VM ID #{vm_id}",
@service.id
vm = OpenNebula::VirtualMachine.new_with_id(vm_id,
@service.client)
rc = vm.info
node = { 'deploy_id' => vm_id }
vm = OpenNebula::VirtualMachine.new_with_id(vm_id, @service.client)
if OpenNebula.is_error?(rc)
node['vm_info'] = nil
else
hash_vm = vm.to_hash['VM']
vm_info = {}
vm_info['VM'] = hash_vm.select {|v| VM_INFO.include?(v) }
tries = 0
loop do
break if tries == 3
node['vm_info'] = vm_info
tries += 1
rc = vm.info
break unless OpenNebula.is_error?(rc)
sleep(tries * 0.5)
end
if tries == 3
node['vm_info'] = nil
msg = "Role #{name} : Cannot get info for VM #{vm_id}"
Log.error LOG_COMP, msg, @service.id
@service.log_error(msg)
return [false,
"Error getting VM #{vm_id} info in Role #{name}: #{vm_id.message}"]
end
hash_vm = vm.to_hash['VM']
vm_info = {}
vm_info['VM'] = hash_vm.select {|v| VM_INFO.include?(v) }
node['vm_info'] = vm_info
@body['nodes'] << node
end