Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ func (h *MigratingHandler) getVMOPCandidate(ctx context.Context, s state.Virtual
func (h *MigratingHandler) syncMigratable(ctx context.Context, s state.VirtualMachineState, vm *v1alpha2.VirtualMachine, kvvm *virtv1.VirtualMachine, kvvmi *virtv1.VirtualMachineInstance) error {
cb := conditions.NewConditionBuilder(vmcondition.TypeMigratable).Generation(vm.GetGeneration())

snapshotting, _ := conditions.GetCondition(vmcondition.TypeSnapshotting, vm.Status.Conditions)
if snapshotting.Status == metav1.ConditionTrue {
cb.Status(metav1.ConditionFalse).
Reason(vmcondition.ReasonNonMigratable).
Message("Cannot migrate the machine while a snapshot is in progress.")
conditions.SetCondition(cb, &vm.Status.Conditions)
return nil
}

if kvvm != nil {
liveMigratable := service.GetKVVMCondition(string(virtv1.VirtualMachineInstanceIsMigratable), kvvm.Status.Conditions)
switch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (h LifecycleHandler) canExecute(vmop *v1alpha2.VirtualMachineOperation, vm
Generation(vmop.GetGeneration()).
Reason(vmopcondition.ReasonOperationFailed).
Status(metav1.ConditionFalse).
Message("VirtualMachine is not migratable, cannot be processed."),
Message(fmt.Sprintf("VirtualMachine is not migratable, cannot be processed: %s", migratable.Message)),
&vmop.Status.Conditions)
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ func (h VirtualMachineReadyHandler) Handle(ctx context.Context, vmSnapshot *v1al
return reconcile.Result{}, nil
}

_, migratingConditionExists := conditions.GetCondition(vmcondition.TypeMigrating, vm.Status.Conditions)
if migratingConditionExists {
cb.
Status(metav1.ConditionFalse).
Reason(vmscondition.VirtualMachineNotReadyForSnapshotting).
Message("Snapshot cannot be taken: the virtual machine is currently migrating.")
return reconcile.Result{}, nil
}

switch vm.Status.Phase {
case v1alpha2.MachineRunning, v1alpha2.MachineStopped:
// If the snapshotting condition is not found, it means that the vm is ready for snapshotting.
Expand Down
Loading