Skip to content

Commit

Permalink
fix(vm): unfreeze fs after snapshot
Browse files Browse the repository at this point in the history
Signed-off-by: Daniil Antoshin <[email protected]>
  • Loading branch information
danilrwx committed Dec 9, 2024
1 parent 64effd2 commit 295c19a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ func (s *SnapshotService) CanUnfreeze(ctx context.Context, vdSnapshotName string

_, ok := vdByName[vdSnapshot.Spec.VirtualDiskName]
if ok {
return false, nil
if vdSnapshot.Status.Phase != virtv2.VirtualDiskSnapshotPhaseReady && vdSnapshot.Status.Phase != virtv2.VirtualDiskSnapshotPhaseFailed {
return false, nil
}
}
}

Expand All @@ -119,7 +121,9 @@ func (s *SnapshotService) CanUnfreeze(ctx context.Context, vdSnapshotName string

for _, vmSnapshot := range vmSnapshots.Items {
if vmSnapshot.Spec.VirtualMachineName == vm.Name {
return false, nil
if vmSnapshot.Status.Phase != virtv2.VirtualMachineSnapshotPhaseReady && vmSnapshot.Status.Phase != virtv2.VirtualMachineSnapshotPhaseFailed {
return false, nil
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vmSnapshot *virtv2.Virtual
switch vmSnapshot.Status.Phase {
case "":
vmSnapshot.Status.Phase = virtv2.VirtualMachineSnapshotPhasePending
case virtv2.VirtualMachineSnapshotPhaseFailed:
vmSnapshotCondition, _ := conditions.GetCondition(vmscondition.VirtualMachineSnapshotReadyType, vmSnapshot.Status.Conditions)

cb.
Status(metav1.ConditionFalse).
Reason(conditions.CommonReason(vmSnapshotCondition.Reason)).
Message(vmSnapshotCondition.Message)

return reconcile.Result{}, nil
case virtv2.VirtualMachineSnapshotPhaseReady:
// Ensure vd snapshots aren't lost.
var lostVDSnapshots []string
Expand Down

0 comments on commit 295c19a

Please sign in to comment.