-
Notifications
You must be signed in to change notification settings - Fork 31
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
Use VMCache instead of VMICache to judge if the NAD is in use #131
base: master
Are you sure you want to change the base?
Conversation
@mingshuoqiu can you also add steps in Testplan for verifying deletion of vlan config as well with stopped vm. |
@@ -218,20 +217,13 @@ func (v *Validator) checkVmi(vc *networkv1.VlanConfig, nodes mapset.Set[string]) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since NAD deletion is validating for the presence of stopped vms, vlan config deletion could just validate the presence of NADs attached to the cluster network.Checking the presence of vms again could be redundant in vlanconfig deletion
pkg/webhook/nad/validator.go
Outdated
@@ -135,7 +138,7 @@ func (v *Validator) checkVmi(nad *cniv1.NetworkAttachmentDefinition) error { | |||
if len(vmis) > 0 { | |||
vmiNameList := make([]string, 0, len(vmis)) | |||
for _, vmi := range vmis { | |||
vmiNameList = append(vmiNameList, vmi.Namespace+"/"+vmi.Name) | |||
vmiNameList = append(vmiNameList, vmi) | |||
} | |||
return fmt.Errorf("it's still used by VM(s) %s which must be stopped at first", strings.Join(vmiNameList, ", ")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error msg should be different for update and delete case.
"It is still used by vms, vms must be stopped first" - for update NAD
"nad cannot be deleted as it is still attached to vms" - for delete NAD
bdf0dbd
to
bec79e5
Compare
The VMI status will be none if the VM is turned off from the GUI. The VMI information can't not be relied to make sure if particular NAD is attched to any VM or not. Use VMCache instead to prevent from deleting the NAD if the VM is turned off. Signed-off-by: Chris Chiu <[email protected]>
bec79e5
to
1477278
Compare
The VMI status will be none if the VM is turned off from the GUI. The VMI information can't not be relied to make sure if particular NAD is attched to any VM or not. Use VMCache instead to prevent from deleting the NAD if the VM is turned off.
Problem:
Fail to delete an Off VM if its network was deleted. The VM network can be deleted if the attached VM is off. It will be a problem if user try to turn the VM back to on.
Solution:
Do not allow VM network removing if the VM still exists, even it is OFF.
Related Issue:
harvester/harvester#6961
Test plan: