Ensure target pod is prepared only once
Do not migrate when migrating.
Remove code stub
@@ -642,6 +642,25 @@ func (d *VirtualMachineController) migrationOrphanedSourceNodeExecute(key string
return nil
}
+func isMigrating(vmi *v1.VirtualMachineInstance) bool {
+
+ now := v12.Now()
+
+ running := false
+ if vmi.Status.MigrationState != nil {
+ start := vmi.Status.MigrationState.StartTimestamp
+ stop := vmi.Status.MigrationState.EndTimestamp
+ if start != nil && (now.After(start.Time) || now.Equal(start)) {
+ running = true
+ }
+
+ if stop != nil && (now.After(stop.Time) || now.Equal(stop)) {
+ running = false
+ }
+ }
+ return running
+}
+
func (d *VirtualMachineController) migrationTargetExecute(key string,
vmi *v1.VirtualMachineInstance,
vmiExists bool,
@@ -1362,6 +1381,7 @@ func (d *VirtualMachineController) processVmUpdate(origVMI *v1.VirtualMachineIns
}
if d.isPreMigrationTarget(vmi) {
+ if !isMigrating(vmi) {
// Mount container disks
if err := d.containerDiskMounter.Mount(vmi, false); err != nil {
@@ -1378,6 +1398,7 @@ func (d *VirtualMachineController) processVmUpdate(origVMI *v1.VirtualMachineIns
if err != nil {
return fmt.Errorf("failed to handle post sync migration proxy: %v", err)
}
+ }
} else if d.isMigrationSource(vmi) {
if vmi.Status.MigrationState.AbortRequested {
if vmi.Status.MigrationState.AbortStatus != v1.MigrationAbortInProgress {
