Skip to content

Commit

Permalink
fix inuse.go, object_ref_vd.go
Browse files Browse the repository at this point in the history
Signed-off-by: dmitry.lopatin <[email protected]>
  • Loading branch information
LopatinDmitr committed Oct 20, 2024
1 parent 6d4987a commit fb9070d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ func (h InUseHandler) Handle(ctx context.Context, vd *virtv2.VirtualDisk) (recon
}
}

if inUseCondition.Status != metav1.ConditionTrue && inUseInRunningVirtualMachine {
if inUseInRunningVirtualMachine && inUseCondition.Status != metav1.ConditionTrue {
inUseCondition.Status = metav1.ConditionTrue
inUseCondition.Reason = vdcondition.InUseInRunningVirtualMachine
} else if inUseCondition.Reason == vdcondition.InUseInRunningVirtualMachine {
inUseCondition.Status = metav1.ConditionFalse
inUseCondition.Reason = vdcondition.NotInUse
}

if inUseCondition.Status != metav1.ConditionTrue && inUseForCreateImage {
if inUseForCreateImage && inUseCondition.Status != metav1.ConditionTrue {
inUseCondition.Status = metav1.ConditionTrue
inUseCondition.Reason = vdcondition.InUseForCreateImage
} else if inUseCondition.Reason == vdcondition.InUseForCreateImage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (ds ObjectRefVirtualDisk) getEnvSettings(vi *virtv2.VirtualImage, sup *supp

func (ds ObjectRefVirtualDisk) Validate(ctx context.Context, vi *virtv2.VirtualImage) error {
if vi.Spec.DataSource.ObjectRef == nil || vi.Spec.DataSource.ObjectRef.Kind != virtv2.VirtualImageObjectRefKindVirtualDisk {
return fmt.Errorf("not a %s data source", virtv2.ClusterVirtualImageObjectRefKindVirtualDisk)
return fmt.Errorf("not a %s data source", virtv2.VirtualImageObjectRefKindVirtualDisk)
}

vd, err := helper.FetchObject(ctx, types.NamespacedName{Name: vi.Spec.DataSource.ObjectRef.Name, Namespace: vi.Namespace}, ds.client, &virtv2.VirtualDisk{})
Expand Down

0 comments on commit fb9070d

Please sign in to comment.