diff --git a/images/virtualization-artifact/pkg/controller/service/snapshot_service.go b/images/virtualization-artifact/pkg/controller/service/snapshot_service.go index d3bc03e5e..0eb764778 100644 --- a/images/virtualization-artifact/pkg/controller/service/snapshot_service.go +++ b/images/virtualization-artifact/pkg/controller/service/snapshot_service.go @@ -104,7 +104,10 @@ func (s *SnapshotService) CanUnfreeze(ctx context.Context, vdSnapshotName string } _, ok := vdByName[vdSnapshot.Spec.VirtualDiskName] - if ok { + if ok && + vdSnapshot.Status.Phase != virtv2.VirtualDiskSnapshotPhaseReady && + vdSnapshot.Status.Phase != virtv2.VirtualDiskSnapshotPhaseFailed && + vdSnapshot.Status.Phase != virtv2.VirtualDiskSnapshotPhaseTerminating { return false, nil } } @@ -118,7 +121,10 @@ func (s *SnapshotService) CanUnfreeze(ctx context.Context, vdSnapshotName string } for _, vmSnapshot := range vmSnapshots.Items { - if vmSnapshot.Spec.VirtualMachineName == vm.Name { + if vmSnapshot.Spec.VirtualMachineName == vm.Name && + vmSnapshot.Status.Phase != virtv2.VirtualMachineSnapshotPhaseReady && + vmSnapshot.Status.Phase != virtv2.VirtualMachineSnapshotPhaseFailed && + vmSnapshot.Status.Phase != virtv2.VirtualMachineSnapshotPhaseTerminating { return false, nil } } diff --git a/images/virtualization-artifact/pkg/controller/vdsnapshot/internal/life_cycle.go b/images/virtualization-artifact/pkg/controller/vdsnapshot/internal/life_cycle.go index 30aba4297..a0fc9fc1b 100644 --- a/images/virtualization-artifact/pkg/controller/vdsnapshot/internal/life_cycle.go +++ b/images/virtualization-artifact/pkg/controller/vdsnapshot/internal/life_cycle.go @@ -82,6 +82,16 @@ func (h LifeCycleHandler) Handle(ctx context.Context, vdSnapshot *virtv2.Virtual switch vdSnapshot.Status.Phase { case "": vdSnapshot.Status.Phase = virtv2.VirtualDiskSnapshotPhasePending + + case virtv2.VirtualDiskSnapshotPhaseFailed: + vdSnapshotCondition, _ := conditions.GetCondition(vdscondition.VirtualDiskSnapshotReadyType, vdSnapshot.Status.Conditions) + + cb. + Status(metav1.ConditionFalse). + Reason(conditions.CommonReason(vdSnapshotCondition.Reason)). + Message(vdSnapshotCondition.Message) + + return reconcile.Result{}, nil case virtv2.VirtualDiskSnapshotPhaseReady: if vs == nil || vs.Status == nil || vs.Status.ReadyToUse == nil || !*vs.Status.ReadyToUse { vdSnapshot.Status.Phase = virtv2.VirtualDiskSnapshotPhaseFailed diff --git a/images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle.go b/images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle.go index 66430c280..2ccbb5267 100644 --- a/images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle.go +++ b/images/virtualization-artifact/pkg/controller/vmsnapshot/internal/life_cycle.go @@ -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