Skip to content

Commit

Permalink
wip: remove volatile just gone
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Jul 2, 2024
1 parent 83b1361 commit 23f9dcd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
14 changes: 10 additions & 4 deletions lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5011,7 +5011,12 @@ sub _cmd_start {
my $domain;
$domain = $self->search_domain($name) if $name;
$domain = Ravada::Domain->open($id_domain) if $id_domain;
die "Unknown domain '".($name or $id_domain)."'" if !$domain;

if(!$domain) {
$self->_remove_inactive_gone($id_domain);
die "Unknown machine '".($name or $id_domain)."'\n";
}

$domain->status('starting');

my $uid = $request->args('uid');
Expand Down Expand Up @@ -5683,7 +5688,7 @@ sub _cmd_check_storage($self, $request) {
}
}

sub _remove_inactive_gone($id_domain) {
sub _remove_inactive_gone($self,$id_domain) {
my $sth = $CONNECTOR->dbh->prepare(
"SELECT name,is_volatile "
." FROM domains "
Expand All @@ -5692,10 +5697,11 @@ sub _remove_inactive_gone($id_domain) {
$sth->execute($id_domain);
my ($name,$is_volatile) = $sth->fetchrow;
if ($is_volatile) {
Ravada::Request->remove_domain(
my $req = Ravada::Request->remove_domain(
name => $name
,uid => Ravada::Utils::user_daemon->id
);
$self->_cmd_remove($req);
}
}

Expand All @@ -5707,7 +5713,7 @@ sub _cmd_refresh_machine($self, $request) {
# it may have been removed on shutdown when volatile
my $domain = Ravada::Domain->open($id_domain);

return _remove_inactive_gone($id_domain) if !$domain;
return $self->_remove_inactive_gone($id_domain) if !$domain;

$domain->check_status();
$domain->list_volumes_info();
Expand Down
3 changes: 3 additions & 0 deletions public/js/ravada.js
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@
var data = JSON.parse(event.data);
$scope.$apply(function () {
$scope.request = data;
if (/Unknown (domain|machine)/i.exec($scope.request.error)) {
$scope.domain=undefined;
}
});
if ( data.id_domain && ! already_subscribed_to_domain ) {
already_subscribed_to_domain = true;
Expand Down
8 changes: 1 addition & 7 deletions t/device/50_nodes.t
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ sub _create_host_devices($node,$number, $type=undef) {
$hd->remove;
return;
}
diag("creating mock devices because not enough found");
my ($list_command,$list_filter) = _create_mock_devices($node->[0], $number->[0], "USB" );
for my $i (1..scalar(@$node)-1) {
die "Error, missing number[$i] ".Dumper($number) unless defined $number->[$i];
Expand Down Expand Up @@ -195,7 +194,6 @@ sub test_devices($vm, $node, $n_local=3, $n_node=3) {
}

sub test_assign_v2($hd, $node, $number, $volatile=0) {
diag("test ssign v2 number=".join(",",@$number)." volatile=$volatile");
my $vm = $node->[0];
my $base = create_domain($vm);
$base->add_host_device($hd);
Expand All @@ -221,7 +219,6 @@ sub test_assign_v2($hd, $node, $number, $volatile=0) {
,uid => user_admin->id
);
wait_request(debug => 0);
diag($req->error);
}

wait_request(debug=>0);
Expand All @@ -243,12 +240,10 @@ sub test_assign_v2($hd, $node, $number, $volatile=0) {
$fd = Ravada::WebSocket::_list_host_devices(rvd_front(),$ws);

my $name = new_domain_name;
diag("Starting $name");
my $domain = _req_clone($base, $name);
is($domain->is_active,1) if $vm->type eq 'Void';
check_hd_from_node($domain,\%devices_nodes);
my $hd_checked = check_host_device($domain);
warn $hd_checked;
push(@{$dupe{$hd_checked}},($domain->name." ".$base->id));
my $id_vm = $domain->_data('id_vm');
$found{$id_vm}++;
Expand Down Expand Up @@ -367,7 +362,7 @@ sub _req_clone($base, $name=undef) {
);
wait_request(debug => 0, check_error => 0);
if ($base->type eq 'KVM' && $MOCK_DEVICES) {
diag($req->error);
diag($req->error) if $req->error;
} else {
is($req->error, '') or confess;
}
Expand Down Expand Up @@ -472,7 +467,6 @@ sub test_clone_nohd($hd, $base) {

my ($name, $req, $domain0);
for ( 1 .. _count_devices($hd) ) {
diag("trying to overflow");
$name = new_domain_name();
my $req0 = Ravada::Request->clone(
uid => user_admin->id
Expand Down
4 changes: 1 addition & 3 deletions templates/main/run_request.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
<h2><%=l 'Running' %> {{domain.alias}}
<span ng-show="domain.is_volatile"><%=l 'Volatile' %></span>
</h2>
<%= $request->id %>
<div class="alert alert-warning">
<%=l 'A viewer is required to run the virtual machines.' %>
<a href="/requirements"><%=l 'Read more.' %></a>
</div>

{{request}}
<div ng-show="request.status != 'done'
|| (domain && domain.is_base )
|| (domain && domain.is_active==0 && count_start<=2)"
><%=l 'Waiting for machine to start' %> <i class="fas fa-sync-alt fa-spin"></i></div>
<div ng-show="domain">
<div ng-show="domain && !(domain.is_volatile && request.error) ">
<div ng-show="domain.description ||(domain.is_active && domain.msg_timeout)">
<span ng-bind-html="domain.description"
ng-show="domain.description">{{domain.description}}
Expand Down

0 comments on commit 23f9dcd

Please sign in to comment.