Skip to content

Commit

Permalink
Trigger final cleanup when the migration fails
Browse files Browse the repository at this point in the history
Also increase verbosity and focus for test purposes

Signed-off-by: fossedihelm <[email protected]>
  • Loading branch information
fossedihelm committed Nov 7, 2024
1 parent c34534d commit 7a49f26
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/virt-handler/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2718,6 +2718,8 @@ func (d *VirtualMachineController) vmUpdateHelperMigrationTarget(origVMI *v1.Vir
}
log.Log.Object(vmi).Infof("Signaled target pod for failed migration to clean up")
// nothing left to do here if the migration failed.
// Re-enqueue to trigger final cleanup
d.Queue.AddAfter(controller.VirtualMachineInstanceKey(vmi), time.Second)
return nil
} else if migrations.IsMigrating(vmi) {
// If the migration has already started,
Expand Down
8 changes: 8 additions & 0 deletions tests/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,13 @@ var _ = SIGMigrationDescribe("VM Live Migration", func() {
})

It("old finalized migrations should get garbage collected", func() {
kvConfig := getCurrentKvConfig(virtClient)
kvConfig.DeveloperConfiguration.LogVerbosity = &v1.LogVerbosity{
VirtController: 9,
VirtHandler: 9,
VirtLauncher: 9,
}
tests.UpdateKubeVirtConfigValueAndWait(kvConfig)
vmi := tests.NewRandomFedoraVMI()
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("1Gi")

Expand Down Expand Up @@ -1959,6 +1966,7 @@ var _ = SIGMigrationDescribe("VM Live Migration", func() {
migrations, err := virtClient.VirtualMachineInstanceMigration(vmi.Namespace).List(context.Background(), metav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(migrations.Items).To(HaveLen(5))
Fail("Failing on purpose")
})

It("[test_id:6979]Target pod should exit after failed migration", func() {
Expand Down

0 comments on commit 7a49f26

Please sign in to comment.