diff --git a/images/virtualization-artifact/pkg/controller/vd/internal/inuse.go b/images/virtualization-artifact/pkg/controller/vd/internal/inuse.go index 15c5bd7c8..01a61d39c 100644 --- a/images/virtualization-artifact/pkg/controller/vd/internal/inuse.go +++ b/images/virtualization-artifact/pkg/controller/vd/internal/inuse.go @@ -130,18 +130,17 @@ func (h InUseHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (recon } } - if inUseInRunningVirtualMachine && inUseCondition.Status != metav1.ConditionTrue { + if inUseCondition.Status != metav1.ConditionTrue && inUseInRunningVirtualMachine && !inUseForCreateImage { inUseCondition.Status = metav1.ConditionTrue inUseCondition.Reason = vdcondition.InUseInRunningVirtualMachine - } else if inUseCondition.Reason == vdcondition.InUseInRunningVirtualMachine { - inUseCondition.Status = metav1.ConditionFalse - inUseCondition.Reason = vdcondition.NotInUse } - if inUseForCreateImage && inUseCondition.Status != metav1.ConditionTrue { + if inUseCondition.Status != metav1.ConditionTrue && inUseForCreateImage && !inUseInRunningVirtualMachine { inUseCondition.Status = metav1.ConditionTrue inUseCondition.Reason = vdcondition.InUseForCreateImage - } else if inUseCondition.Reason == vdcondition.InUseForCreateImage { + } + + if !inUseInRunningVirtualMachine && !inUseForCreateImage { inUseCondition.Status = metav1.ConditionFalse inUseCondition.Reason = vdcondition.NotInUse }