mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #457: making execution of remote commands tolerant to network errors by adding retry
This commit is contained in:
parent
d313af3abc
commit
fd2fe9c9e3
@ -60,8 +60,6 @@ class InformationManager < OpenNebulaDriver
|
||||
log_lambda=lambda do |message|
|
||||
log(number, message)
|
||||
end
|
||||
|
||||
retries = 2
|
||||
|
||||
if do_update == "1"
|
||||
# Use SCP to sync:
|
||||
@ -74,14 +72,8 @@ class InformationManager < OpenNebulaDriver
|
||||
|
||||
cmd_string = "#{@remote_dir}/im/run_probes #{@hypervisor} #{host}"
|
||||
|
||||
cmd = RemotesCommand.run(cmd_string, host, @remote_dir, log_lambda)
|
||||
|
||||
while cmd.code != 0 or retries != 0
|
||||
cmd = RemotesCommand.run(cmd_string, host, @remote_dir, log_lambda)
|
||||
retries = retries - 1
|
||||
sleep 1
|
||||
end
|
||||
|
||||
cmd = RemotesCommand.run(cmd_string, host, @remote_dir, log_lambda, 2)
|
||||
|
||||
if cmd.code == 0
|
||||
send_message("MONITOR", RESULT[:success], number, cmd.stdout)
|
||||
else
|
||||
|
@ -150,7 +150,7 @@ class RemotesCommand < SSHCommand
|
||||
MAGIC_RC = 42
|
||||
|
||||
# Creates a command and runs it
|
||||
def self.run(command, host, remote_dir, logger=nil, stdin=nil)
|
||||
def self.run(command, host, remote_dir, logger=nil, stdin=nil, retries=1)
|
||||
cmd_file = command.split(' ')[0]
|
||||
|
||||
cmd_string = "'if [ -x \"#{cmd_file}\" ]; then #{command}; else\
|
||||
@ -158,13 +158,19 @@ class RemotesCommand < SSHCommand
|
||||
|
||||
cmd = self.new(cmd_string, host, logger, stdin)
|
||||
cmd.run
|
||||
|
||||
|
||||
if cmd.code == MAGIC_RC
|
||||
cmd.update_remotes(host, remote_dir, logger)
|
||||
|
||||
@command = command
|
||||
cmd.run
|
||||
end
|
||||
|
||||
while cmd.code != 0 or retries != 0
|
||||
sleep 1
|
||||
cmd.run
|
||||
retries = retries - 1
|
||||
end
|
||||
|
||||
cmd
|
||||
end
|
||||
|
@ -107,9 +107,13 @@ class VirtualMachineDriver < OpenNebulaDriver
|
||||
# -------------------------------------------------------------------------
|
||||
# Execute a command associated to an action and id in a remote host.
|
||||
# -------------------------------------------------------------------------
|
||||
def remotes_action(command, id, host, action, remote_dir, std_in=nil)
|
||||
command_exe = RemotesCommand.run(
|
||||
command, host, remote_dir, log_method(id), std_in)
|
||||
def remotes_action(command, id, host, action, remote_dir, std_in=nil, retries=1)
|
||||
command_exe = RemotesCommand.run(command,
|
||||
host,
|
||||
remote_dir,
|
||||
log_method(id),
|
||||
std_in,
|
||||
retries)
|
||||
|
||||
if command_exe.code == 0
|
||||
result = :success
|
||||
|
Loading…
x
Reference in New Issue
Block a user