Skip to content

Commit

Permalink
MTV-1477 | Add DataVolume deletion when archiving
Browse files Browse the repository at this point in the history
Issue:
When running the migration archive we do not delete the DataVolumes.

Fix:
Add deletion of the DataVolumes when running the archive and the VM
migration failed.
At some cases the migration in the context is missing the migration ID
so we can use the plan instead to find the DataVolume.

Fixes: https://issues.redhat.com/browse/MTV-1477

Signed-off-by: Martin Necas <[email protected]>
  • Loading branch information
mnecas committed Oct 8, 2024
1 parent 8a8c742 commit 8cb56bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func (r *KubeVirt) getDVs(vm *plan.VMStatus) (edvs []ExtendedDataVolume, err err
context.TODO(),
dvsList,
&client.ListOptions{
LabelSelector: k8slabels.SelectorFromSet(r.vmLabels(vm.Ref)),
LabelSelector: k8slabels.SelectorFromSet(r.vmAllButMigrationLabels(vm.Ref)),
Namespace: r.Plan.Spec.TargetNamespace,
})

Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/plan/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ func (r *Migration) cleanup(vm *plan.VMStatus, failOnErr func(error) bool) error
if err := r.deletePopulatorPVCs(vm); failOnErr(err) {
return err
}
if err := r.kubevirt.DeleteDataVolumes(vm); failOnErr(err) {
return err
}
}
if err := r.deleteImporterPods(vm); failOnErr(err) {
return err
Expand Down

0 comments on commit 8cb56bb

Please sign in to comment.