Commit 73b78de4 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(ports): retry more when unreachable

parent f9ddfe17
......@@ -4420,7 +4420,8 @@ sub _cmd_refresh_machine($self, $request) {
$domain->info($user);
$domain->client_status(1) if $is_active;
Ravada::Request->refresh_machine_ports(id_domain => $domain->id, uid => $user->id)
Ravada::Request->refresh_machine_ports(id_domain => $domain->id, uid => $user->id
,retry => 20)
if $is_active && $domain->ip;
}
......@@ -5424,7 +5425,7 @@ sub _cmd_open_exposed_ports($self, $request) {
Ravada::Request->refresh_machine_ports(
uid => $request->args('uid'),
,id_domain => $domain->id
,retry => 10
,retry => 100
);
}
......
......@@ -6313,7 +6313,7 @@ sub purge($self, $request=undef) {
sub _check_port($self, $port, $ip=$self->ip, $request=undef) {
my ($out, $err) = $self->_vm->run_command("nc","-z","-v",$ip,$port);
$request->error($err) if $err;
return 1 if $err =~ /succeeded!/;
return 0 if $err =~ /failed/;
warn $err;
......@@ -6357,14 +6357,16 @@ sub refresh_ports($self, $request=undef) {
$is_port_active = $self->_check_port($port->{internal_port}, $ip, $request);
} else {
$is_port_active = 0;
$port_down++;
}
$port_down++ if !$is_port_active;
$sth_update->execute($is_port_active, $self->id, $port->{id});
$sth_update_display->execute($is_port_active, $port->{id})
if $port->{name};
$msg .= " , " if $msg;
$msg .= " $port->{internal_port} $is_port_active";
my $is_port_active_txt = "up";
$is_port_active_txt = "down" if !$is_port_active;
$msg .= " $port->{internal_port}:$is_port_active_txt";
}
die "Virtual machine ".$self->name." is not up. retry.\n"if !$ip;
die "Virtual machine ".$self->name." $ip has ports down: $msg. retry.\n"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment