Unverified Commit 53a33641 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Fix/focal md5 (#1421)

fix(ISO): properly use SHA256 file
parent 3655deb6
......@@ -255,7 +255,7 @@ sub _update_isos {
,xml_volume => 'focal_fossa64-volume.xml'
,url => 'http://releases.ubuntu.com/20.04/'
,file_re => '^ubuntu-20.04.*desktop-amd64.iso'
,md5_url => '$url/MD5SUMS'
,sha256_url => '$url/SHA256SUMS'
,min_disk_size => '9'
}
......@@ -886,6 +886,8 @@ sub _remove_old_isos {
." WHERE name like 'Debian Buster 32%'"
." AND file_re like '%xfce-CD-1.iso'"
,"DELETE FROM iso_images "
." WHERE name like 'Ubuntu Focal%'"
) {
my $sth = $CONNECTOR->dbh->prepare($sql);
$sth->execute();
......@@ -2207,6 +2209,7 @@ sub list_domains_data($self, %args ) {
my $sth = $CONNECTOR->dbh->prepare($query);
$sth->execute(@values);
while (my $row = $sth->fetchrow_hashref) {
$row->{date_changed} = 0 if !defined $row->{date_changed};
lock_hash(%$row);
push @domains,($row);
}
......@@ -3882,14 +3885,18 @@ sub _refresh_active_domains($self, $request=undef) {
$self->_refresh_active_domain($domain, \%active_domain) if $domain;
} else {
my @domains;
eval { @domains = $self->list_domains };
eval { @domains = $self->list_domains_data };
warn $@ if $@;
for my $domain (@domains) {
next if $active_domain{$domain->id};
next if $domain->is_hibernated;
for my $domain_data (sort { $b->{date_changed} cmp $a->{date_changed} }
@domains) {
$request->error("checking $domain_data->{name}") if $request;
next if $active_domain{$domain_data->{id}};
my $domain = Ravada::Domain->open($domain_data->{id});
next if !$domain || $domain->is_hibernated;
$self->_refresh_active_domain($domain, \%active_domain);
$self->_remove_unnecessary_downs($domain) if !$domain->is_active;
}
$request->error("checked ".scalar(@domains)) if $request;
}
return \%active_domain;
}
......
......@@ -3955,7 +3955,8 @@ sub rsync($self, @args) {
or confess "No Connection to ".$self->_vm->host;
}
my $vm_local = $self->_vm->new( host => 'localhost' );
my $rsync = File::Rsync->new(update => 1, sparse => 1, times => 1);
my $rsync = File::Rsync->new(update => 1, sparse => 1, archive => 1);
my $time_rsync = time;
for my $file ( @$files ) {
my ($path) = $file =~ m{(.*)/};
my ($out, $err) = $node->run_command("/bin/mkdir","-p",$path);
......@@ -3972,19 +3973,24 @@ sub rsync($self, @args) {
next if _check_stat($file, $vm_local, $node);
my $msg = $self->_msg_log_rsync($file, $node, "rsync", $request);
$request->status("syncing",$msg) if $request;
$request->status("syncing") if $request;
$request->error($msg) if $request;
warn "$msg\n" if $DEBUG_RSYNC;
my $t0 = time;
$rsync->exec(src => $src, dest => $dst);
warn "Domain::rsync ".(time - $t0)." seconds $file" if $DEBUG_RSYNC;
$msg = "Domain::rsync ".(time - $t0)." seconds $file";
warn $msg if $DEBUG_RSYNC;
$request->error($msg) if $request;
}
if ($rsync->err) {
$request->status("done",join(" ",@{$rsync->err})) if $request;
$request->status("done") if $request;
$request->error(join(" ",@{$rsync->err})) if $request;
confess "error syncing to ".$node->host."\n"
.Dumper($files)."\n"
.join(' ',@{$rsync->err});
}
$request->error("rsync done ".(time - $time_rsync)." seconds");
$node->refresh_storage_pools();
}
......@@ -4009,7 +4015,7 @@ sub _msg_log_rsync($self, $file, $node, $sub, $request) {
}
sub _rsync_volumes_back($self, $node, $request=undef) {
my $rsync = File::Rsync->new(update => 1, sparse => 1, times => 1);
my $rsync = File::Rsync->new(update => 1, sparse => 1, archive => 1);
my $vm_local = $self->_vm->new( host => 'localhost' );
for my $file ( $self->list_volumes() ) {
my ($dir) = $file =~ m{(.*)/.*};
......@@ -4017,7 +4023,8 @@ sub _rsync_volumes_back($self, $node, $request=undef) {
my $msg = $self->_msg_log_rsync($file, $node, "rsync_back", $request);
$request->status("syncing",$msg) if $request;
$request->status("syncing") if $request;
$request->error($msg) if $request;
warn "$msg\n" if $DEBUG_RSYNC;
my $t0 = time;
$rsync->exec(src => 'root@'.$node->host.":".$file ,dest => $file );
......
......@@ -917,7 +917,6 @@ sub list_requests($self, $id_domain_req=undef, $seconds=60) {
}
}
next if $command eq 'enforce_limits'
|| $command eq 'refresh_vms'
|| $command eq 'refresh_storage'
|| $command eq 'refresh_machine'
|| $command eq 'ping_backend'
......
......@@ -977,8 +977,6 @@ sub refresh_vms {
return if done_recently(undef,60,'refresh_vms') || _requested('refresh_vms');
}
$args->{timeout} = 120 if ! $args->{timeout};
my $self = {};
bless($self,$class);
......
......@@ -1893,6 +1893,19 @@ sub mangle_volume($vm,$name,@vol) {
}
}
sub _lsof_nbd($vm, $dev_nbd) {
my ($out, $err) = $vm->run_command("ls","/dev");
die $err if $err;
my ($nbd) = $dev_nbd =~ m{^/dev/(.*)};
for my $dev (split /\n/,$out) {
next if $dev !~ /^$nbd/;
my ($out2, $err2) = $vm->run_command("lsof","/dev/$dev");
my @line = split /\n/,$out2;
return 1 if scalar(@line) >= 2;
}
return 0;
}
sub _load_nbd($vm) {
my ($in, $out, $err);
if (!$MOD_NBD++) {
......@@ -1904,9 +1917,7 @@ sub _load_nbd($vm) {
($out,$err) = $vm->run_command(@cmd);
die "@cmd : $err" if $err;
($out, $err) = $vm->run_command("lsof",$DEV_NBD);
my @line = split /\n/,$out;
return if scalar(@line) < 2;
return if !_lsof_nbd($vm, $DEV_NBD);
my ($dev,$n) = $DEV_NBD =~ /(.*?)(\d+)$/;
$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