Added alarms around remote calls to better handle dropped networks.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 10 months ago
parent 480745c889
commit 0f1ff02e78
  1. 2
      Anvil/Tools/Database.pm
  2. 6
      Anvil/Tools/Remote.pm
  3. 3
      tools/scancore

@ -20394,8 +20394,10 @@ sub _test_access
} }
# Check using ping. Returns '1' on success, '0' on fail. # Check using ping. Returns '1' on success, '0' on fail.
alarm(10);
my $connected = $anvil->data->{cache}{database_handle}{$uuid}->ping(); my $connected = $anvil->data->{cache}{database_handle}{$uuid}->ping();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { connected => $connected }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { connected => $connected }});
alarm(0);
if (not $connected) if (not $connected)
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0192", variables => { server => $say_server }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0192", variables => { server => $say_server }});

@ -510,6 +510,7 @@ sub call
's3:remote_user' => $remote_user, 's3:remote_user' => $remote_user,
's4:port' => $port, 's4:port' => $port,
}}); }});
alarm(10);
($connect_output) = capture_merged { ($connect_output) = capture_merged {
$ssh_fh = Net::OpenSSH->new($target, $ssh_fh = Net::OpenSSH->new($target,
user => $remote_user, user => $remote_user,
@ -525,6 +526,7 @@ sub call
's2:ssh_fh->error' => $ssh_fh->error, 's2:ssh_fh->error' => $ssh_fh->error,
's3:connect_output' => $connect_output, 's3:connect_output' => $connect_output,
}}); }});
alarm(0);
# Any fatal issues reaching the target? # Any fatal issues reaching the target?
if ($connect_output =~ /Could not resolve hostname/i) if ($connect_output =~ /Could not resolve hostname/i)
@ -703,10 +705,12 @@ sub call
$error = ""; $error = "";
if ($timeout) if ($timeout)
{ {
# Call with a timeout # Call with a timeout. Use alarm also, as capture2's timeout is questionaly reliable.
alarm($timeout + 2);
($output, $error) = $ssh_fh->capture2({timeout => $timeout}, $shell_call); ($output, $error) = $ssh_fh->capture2({timeout => $timeout}, $shell_call);
$output = "" if not defined $output; $output = "" if not defined $output;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => $secure, list => { 'ssh_fh->error' => $ssh_fh->error }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => $secure, list => { 'ssh_fh->error' => $ssh_fh->error }});
alarm(0);
} }
else else
{ {

@ -144,6 +144,9 @@ while(1)
# Do we have at least one database? # Do we have at least one database?
my $agent_runtime = 0; my $agent_runtime = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::database::connections" => $anvil->data->{sys}{database}{connections},
}});
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# Run the normal tasks # Run the normal tasks

Loading…
Cancel
Save