Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vd): Allow change Virtual Disk spec after connect to Virtual Machine while Virtual Disk is not ready #461

Merged
merged 5 commits into from
Oct 21, 2024
Merged
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 @@ -47,21 +47,11 @@ func (v *SpecChangesValidator) ValidateUpdate(_ context.Context, oldVD, newVD *v
ready, _ := service.GetCondition(vdcondition.ReadyType, newVD.Status.Conditions)
if ready.Status == metav1.ConditionTrue || newVD.Status.Phase == virtv2.DiskReady || newVD.Status.Phase == virtv2.DiskLost || newVD.Status.Phase == virtv2.DiskTerminating {
if !reflect.DeepEqual(oldVD.Spec.DataSource, newVD.Spec.DataSource) {
return nil, fmt.Errorf("VirtualDisk has already been created: data source cannot be changed after disk is created")
return nil, fmt.Errorf("VirtualDisk has already been attached: data source cannot be changed while disk is attached to VirtualMachine")
}

if !reflect.DeepEqual(oldVD.Spec.PersistentVolumeClaim.StorageClass, newVD.Spec.PersistentVolumeClaim.StorageClass) {
return nil, fmt.Errorf("VirtualDisk has already been created: storage class cannot be changed after disk is created")
}
}

if len(newVD.Status.AttachedToVirtualMachines) > 0 {
if !reflect.DeepEqual(oldVD.Spec.DataSource, newVD.Spec.DataSource) {
return nil, fmt.Errorf("VirtualDisk has already been attached to the virtual machine: data source cannot be changed after disk is attached")
}

if !reflect.DeepEqual(oldVD.Spec.PersistentVolumeClaim.StorageClass, newVD.Spec.PersistentVolumeClaim.StorageClass) {
return nil, fmt.Errorf("VirtualDisk has already been attached to the virtual machine: storage class cannot be changed after disk is attached")
return nil, fmt.Errorf("VirtualDisk has already been attached: storage class cannot be changed while disk is attached to VirtualMachine")
}
}

Expand Down
Loading