Skip to content

Commit

Permalink
use the migration config in migration monitor
Browse files Browse the repository at this point in the history
Signed-off-by: Vladik Romanovsky <[email protected]>
  • Loading branch information
vladikr committed Mar 1, 2019
1 parent da12ac3 commit 69a22e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
16 changes: 13 additions & 3 deletions pkg/virt-launcher/virtwrap/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,21 @@ func liveMigrationMonitor(vmi *v1.VirtualMachineInstance, dom cli.VirDomain, l *
start := time.Now().UTC().Unix()
lastProgressUpdate := start
progressWatermark := int64(0)
// TODO:(vladikr) move to configMap
progressTimeout := int64(150)

// TODO:(vladikr) move to configMap
progressTimeout := int64(150)
completionTimeoutPerGiB := int64(800)

// update timeouts from migration config
conf := vmi.Status.MigrationState
if conf != nil {
if conf.CompletionTimeoutPerGiB != 0 {
completionTimeoutPerGiB = conf.CompletionTimeoutPerGiB
}
if conf.ProgressTimeout != 0 {
progressTimeout = conf.ProgressTimeout
}
}

acceptableCompletionTime := completionTimeoutPerGiB * getVMIMigrationDataSize(vmi)
monitorLoop:
for {
Expand Down
18 changes: 7 additions & 11 deletions pkg/virt-launcher/virtwrap/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,9 @@ var _ = Describe("Manager", func() {

vmi := newVMI(testNamespace, testVmName)
vmi.Status.MigrationState = &v1.VirtualMachineInstanceMigrationState{
MigrationUID: "111222333",
}
migrationConfig := &v1.MigrationConfig{
CompletionTimeoutPerGiB: 800,
MigrationUID: "111222333",
ProgressTimeout: 2,
CompletionTimeoutPerGiB: 300,
}

domainSpec := expectIsolationDetectionForVMI(vmi)
Expand All @@ -244,7 +242,7 @@ var _ = Describe("Manager", func() {
mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_MIGRATABLE)).Return(string(xml), nil)
mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_INACTIVE)).Return(string(xml), nil)

liveMigrationMonitor(vmi, mockDomain, manager, migrationConfig)
liveMigrationMonitor(vmi, mockDomain, manager)
})
It("migration should be canceled if timeout has been reached", func() {
// Make sure that we always free the domain after use
Expand All @@ -260,11 +258,9 @@ var _ = Describe("Manager", func() {

vmi := newVMI(testNamespace, testVmName)
vmi.Status.MigrationState = &v1.VirtualMachineInstanceMigrationState{
MigrationUID: "111222333",
}
migrationConfig := &v1.MigrationConfig{
CompletionTimeoutPerGiB: 3,
ProgressTimeout: 150,
MigrationUID: "111222333",
ProgressTimeout: 3,
CompletionTimeoutPerGiB: 150,
}

domainSpec := expectIsolationDetectionForVMI(vmi)
Expand All @@ -283,7 +279,7 @@ var _ = Describe("Manager", func() {
mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_MIGRATABLE)).Return(string(xml), nil)
mockDomain.EXPECT().GetXMLDesc(gomock.Eq(libvirt.DOMAIN_XML_INACTIVE)).Return(string(xml), nil)

liveMigrationMonitor(vmi, mockDomain, manager, migrationConfig)
liveMigrationMonitor(vmi, mockDomain, manager)
})

})
Expand Down

0 comments on commit 69a22e9

Please sign in to comment.