Skip to content

Commit

Permalink
refactor: clean only automatic shutdowns (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol authored May 14, 2021
1 parent 75b5853 commit 58aa832
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4164,8 +4164,10 @@ sub _refresh_down_domains($self, $active_domain, $active_vm) {
sub _remove_unnecessary_downs($self, $domain) {

my @requests = $domain->list_requests(1);
my $uid_daemon = Ravada::Utils::user_daemon->id();
for my $req (@requests) {
$req->status('done') if $req->command =~ /shutdown/ && !$req->at_time;
$req->status('done') if $req->command =~ /shutdown/
&& (!$req->at_time || $req->defined_arg('uid') == $uid_daemon );
$req->_remove_messages();
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Ravada/Domain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2553,7 +2553,7 @@ sub _post_shutdown {
my $req = Ravada::Request->force_shutdown_domain(
id_domain => $self->id
,id_vm => $self->_vm->id
, uid => $arg{user}->id
, uid => Ravada::Utils::user_daemon->id
, at => time+$timeout
);
}
Expand Down
5 changes: 4 additions & 1 deletion t/vm/10_domain.t
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ sub test_shutdown {

my @reqs = $domain->list_requests(1);
ok(scalar @reqs,$domain->name);
my @req_shutdown = grep { $_->command eq 'force_shutdown' } @reqs;
is(scalar(@req_shutdown),1)
and is($req_shutdown[0]->defined_arg('uid'), Ravada::Utils::user_daemon->id);

$domain->shutdown_now(user_admin);

Expand All @@ -296,7 +299,7 @@ sub test_shutdown {
my @req_other = grep { $_->command ne 'refresh_machine' } @reqs;
is(scalar(@req_other),0);

is(scalar @reqs,1,$domain->name) or die Dumper([ map { [$_->id,$_->command,$_->status,$_->error] } @reqs]);
is(scalar @reqs,1,$domain->name) or die Dumper([ map { [$_->id,$_->command,$_->defined_arg('uid'),$_->status,$_->error] } @reqs]);

$domain->remove(user_admin);
}
Expand Down

0 comments on commit 58aa832

Please sign in to comment.