Unverified Commit 1eba13f0 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Fix do not remove volume (#1341)

fix(backend): only clean when no base

* test(backend): volumes not removed after change hardware

fixes issue #1340
parent ca4a1b7d
...@@ -4488,7 +4488,10 @@ sub _post_change_hardware($self, $hardware, $index, $data=undef) { ...@@ -4488,7 +4488,10 @@ sub _post_change_hardware($self, $hardware, $index, $data=undef) {
my @volumes = $self->list_volumes_info(); my @volumes = $self->list_volumes_info();
} }
$self->info(Ravada::Utils::user_daemon) if $self->is_known(); $self->info(Ravada::Utils::user_daemon) if $self->is_known();
$self->_remove_domain_cascade(Ravada::Utils::user_daemon,1) if $self->is_known();
$self->_remove_domain_cascade(Ravada::Utils::user_daemon,1)
if $self->is_known() && !$self->is_base;
$self->needs_restart(1) if $self->is_known && $self->_data('status') eq 'active'; $self->needs_restart(1) if $self->is_known && $self->_data('status') eq 'active';
} }
......
...@@ -855,6 +855,62 @@ sub test_base_unset($vm, $node) { ...@@ -855,6 +855,62 @@ sub test_base_unset($vm, $node) {
_remove_domain($base); _remove_domain($base);
} }
sub test_change_base($vm, $node) {
my $base = create_domain($vm);
$base->prepare_base(user_admin);
$base->set_base_vm(vm => $node, user => user_admin);
my @volumes = ($base->list_files_base(), $base->list_volumes);
my $req = Ravada::Request->change_hardware(
uid => 1
,id_domain => $base->id
,hardware => 'memory'
,data => { memory => 100 }
);
wait_request();
is($req->status,'done');
is($req->error,'');
for my $vol (@volumes) {
ok(-e $vol,$vol);
ok($node->file_exists($vol), $vol) if $vol !~ /iso$/;
}
$base->remove(user_admin);
}
sub test_change_clone($vm, $node) {
my $base = create_domain($vm);
$base->prepare_base(user_admin);
$base->set_base_vm(vm => $node, user => user_admin);
my @volumes_base = ($base->list_files_base() ,$base->list_volumes);
my $clone = $base->clone( user => user_admin,name => new_domain_name());
my @volumes_clone = ($clone->list_files_base(), $clone->list_volumes);
my @args = (
uid => 1
,hardware => 'memory'
,data => { memory => 100 }
);
my $reqb = Ravada::Request->change_hardware(@args ,id_domain => $base->id);
my $reqc = Ravada::Request->change_hardware(@args ,id_domain => $clone->id);
wait_request();
is($reqb->status,'done');
is($reqb->error,'');
is($reqc->status,'done');
is($reqc->error,'');
for my $vol (@volumes_base) {
ok(-e $vol);
ok($node->file_exists($vol), $vol) if $vol !~ /iso$/;
}
for my $vol (@volumes_clone) {
ok(-e $vol, $vol);
ok(!$node->file_exists($vol), $vol) if $vol !~ /iso$/;
}
$clone->remove(user_admin);
$base->remove(user_admin);
}
sub test_fill_memory($vm, $node, $migrate) { sub test_fill_memory($vm, $node, $migrate) {
#TODO: Void VMs #TODO: Void VMs
return if $vm->type eq 'Void'; return if $vm->type eq 'Void';
...@@ -943,6 +999,10 @@ for my $vm_name ( 'Void', 'KVM') { ...@@ -943,6 +999,10 @@ for my $vm_name ( 'Void', 'KVM') {
is($node->is_local,0,"Expecting ".$node->name." ".$node->ip." is remote" ) or BAIL_OUT(); is($node->is_local,0,"Expecting ".$node->name." ".$node->ip." is remote" ) or BAIL_OUT();
start_node($node); start_node($node);
test_change_base($vm, $node);
test_change_clone($vm, $node);
test_fill_memory($vm, $node, 0); # balance test_fill_memory($vm, $node, 0); # balance
test_fill_memory($vm, $node, 1); # migrate test_fill_memory($vm, $node, 1); # migrate
test_create_active($vm, $node); test_create_active($vm, $node);
......
Supports Markdown
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