1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

B #5569: manage onedb live errors (#1512)

This commit is contained in:
Alejandro Huertas Herrero 2021-10-08 09:49:06 +02:00 committed by GitHub
parent 2e2f145507
commit 59cd0e1a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 17 deletions

View File

@ -261,6 +261,8 @@ module OpenNebula
size = OpenNebula.pool_page_size if (!size || size == 0) size = OpenNebula.pool_page_size if (!size || size == 0)
rc = @client.call(method, @user_id, current, -size, state) rc = @client.call(method, @user_id, current, -size, state)
return rc if OpenNebula.is_error?(rc)
initialize_xml(rc, @pool_name) initialize_xml(rc, @pool_name)
else else
rc = info rc = info
@ -276,11 +278,11 @@ module OpenNebula
page = OpenNebula::XMLElement.new page = OpenNebula::XMLElement.new
loop do loop do
page.initialize_xml(get_page(size, rc = get_page(size, current, extended, state)
current,
extended, break rc if OpenNebula.is_error?(rc)
state),
@pool_name) page.initialize_xml(rc, @pool_name)
break if page["//#{element}"].nil? break if page["//#{element}"].nil?

View File

@ -561,7 +561,12 @@ CommandParser::CmdParser.new(ARGV) do
:options => [START_TIME, END_TIME] do :options => [START_TIME, END_TIME] do
begin begin
action = OneDBLive.new action = OneDBLive.new
action.purge_history(options) rc = action.purge_history(options)
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
pp e.backtrace pp e.backtrace
@ -584,7 +589,12 @@ CommandParser::CmdParser.new(ARGV) do
:options => [START_TIME, END_TIME, PAGES] do :options => [START_TIME, END_TIME, PAGES] do
begin begin
action = OneDBLive.new action = OneDBLive.new
action.purge_done_vm(options) rc = action.purge_done_vm(options)
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.name puts e.name
pp e.backtrace pp e.backtrace
@ -649,7 +659,12 @@ CommandParser::CmdParser.new(ARGV) do
OpenNebulaHelper::APPEND] do OpenNebulaHelper::APPEND] do
begin begin
action = OneDBLive.new action = OneDBLive.new
action.change_body(args[0], args[1], args[2], options) rc = action.change_body(args[0], args[1], args[2], options)
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]
@ -688,7 +703,12 @@ CommandParser::CmdParser.new(ARGV) do
end end
action = OneDBLive.new action = OneDBLive.new
action.change_history(vid, seq, args[0], args[1], options) rc = action.change_history(vid, seq, args[0], args[1], options)
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]
@ -721,7 +741,12 @@ CommandParser::CmdParser.new(ARGV) do
end end
action = OneDBLive.new action = OneDBLive.new
action.update_body_cli(args[0], options[:id]) rc = action.update_body_cli(args[0], options[:id])
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]
@ -754,7 +779,12 @@ CommandParser::CmdParser.new(ARGV) do
end end
action = OneDBLive.new action = OneDBLive.new
action.update_history_cli(options[:id], options[:seq]) rc = action.update_history_cli(options[:id], options[:seq])
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]
@ -787,7 +817,14 @@ CommandParser::CmdParser.new(ARGV) do
end end
action = OneDBLive.new action = OneDBLive.new
STDOUT.puts action.show_body_cli(args[0], options[:id]) rc = action.show_body_cli(args[0], options[:id])
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
else
puts rc if rc
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]
@ -820,7 +857,14 @@ CommandParser::CmdParser.new(ARGV) do
end end
action = OneDBLive.new action = OneDBLive.new
STDOUT.puts action.show_history_cli(options[:id], options[:seq]) rc = action.show_history_cli(options[:id], options[:seq])
if OpenNebula.is_error?(rc)
STDERR.puts "ERROR: #{rc.message}"
exit(-1)
else
puts rc if rc
end
rescue StandardError => e rescue StandardError => e
puts e.message puts e.message
[-1, e.message] [-1, e.message]

View File

@ -118,7 +118,9 @@ class OneDBLive
def purge_history(options = {}) def purge_history(options = {})
vmpool = OpenNebula::VirtualMachinePool.new(client) vmpool = OpenNebula::VirtualMachinePool.new(client)
vmpool.info_all rc = vmpool.info_all
return rc if OpenNebula.is_error?(rc)
ops = { ops = {
:start_time => 0, :start_time => 0,
@ -217,7 +219,7 @@ class OneDBLive
end_time = ops[:end_time].to_i end_time = ops[:end_time].to_i
done = OpenNebula::VirtualMachine::VM_STATE.index('DONE') done = OpenNebula::VirtualMachine::VM_STATE.index('DONE')
vmpool.each_page_delete(ops[:pages], done, false) do |obj| rc = vmpool.each_page_delete(ops[:pages], done, false) do |obj|
time = obj['ETIME'].to_i time = obj['ETIME'].to_i
# return false because the VM wasn't deleted # return false because the VM wasn't deleted
@ -230,6 +232,8 @@ class OneDBLive
true true
end end
return rc if OpenNebula.is_error?(rc)
end end
def check_expr(object, expr) def check_expr(object, expr)
@ -409,7 +413,7 @@ class OneDBLive
rescue StandardError => e rescue StandardError => e
STDERR.puts "Error getting object id #{o.id}" STDERR.puts "Error getting object id #{o.id}"
STDERR.puts e.message STDERR.puts e.message
next return
end end
row = db_data.first row = db_data.first
@ -555,6 +559,7 @@ class OneDBLive
rescue StandardError => e rescue StandardError => e
STDERR.puts "Error getting object id #{id}" STDERR.puts "Error getting object id #{id}"
STDERR.puts e.message STDERR.puts e.message
return
end end
row = db_data.first row = db_data.first
@ -582,7 +587,7 @@ class OneDBLive
begin begin
db_data = select('history', "vid = #{vid} and seq = #{seq}") db_data = select('history', "vid = #{vid} and seq = #{seq}")
rescue StandardError => e rescue StandardError => e
error_str = "Error getting history record #{seq} for VM #{vid}" error_str = "Error getting history record #{seq} for VM #{vid}\n"
error_str << e.message error_str << e.message
raise error_str raise error_str