-
Notifications
You must be signed in to change notification settings - Fork 36
Storage-network NAD can be deleted from kubectl directly #235
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR updates the NAD validating webhook to prevent deletion of NetworkAttachmentDefinitions that are used for Harvester’s storage network, addressing harvester/harvester#9623.
Changes:
- Add a storage-network check to the NAD delete admission path to deny deletion of storage-network NADs.
- Fix the delete path to wrap NAD config decode errors with the correct delete-specific error format.
- Extend delete validator unit tests to cover storage-network NAD deletion denial (annotation-based and prefix-based).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| pkg/webhook/nad/validator.go | Adds storage-network deletion protection and corrects delete error wrapping for config decode failures. |
| pkg/webhook/nad/validator_test.go | Adds new delete test cases asserting storage-network NADs cannot be deleted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pkg/webhook/nad/validator.go
Outdated
| if err := v.checkStorageNetwork(nad); err != nil { | ||
| return fmt.Errorf(deleteErr, nad.Namespace, nad.Name, err) | ||
| } |
Copilot
AI
Feb 11, 2026
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.
The delete path now surfaces the storage-network protection error to end users. The current message text (via storageNetworkErr) says "storagenetwork" which is a bit opaque/inconsistent with the user-facing term "storage-network" used elsewhere; consider updating the underlying error text to be more explicit (e.g., mention "storage-network NAD" and/or use "storage network" wording) so kubectl users understand why deletion is denied.
starbops
left a comment
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.
Thanks for the PR. I have a question: does the change affect how the storage network setting behaves? For instance, restore the setting to the default value, i.e., no dedicated storage network.
Deny deletion of a NAD if it is used for storage-network. Related to: harvester/harvester#9623 Signed-off-by: Volker Theile <[email protected]>
f682c42 to
d3e9230
Compare
|
OK, I think we need to take the following approach, as we certainly don't want to import Harvester into Alternatively relocate the validation into Harvester where we have full access to the settings: harvester/harvester#10042 |
Signed-off-by: Volker Theile <[email protected]>
Problem:
Storage-network NAD can be deleted from kubectl directly.
Solution:
Deny deletion of a NAD if it is used for storage-network.
Related Issue:
harvester/harvester#9623
Test plan:
Case 1
storage-network. You may use the following settings:Note, all VMs need to be stopped to apply the settings.
The resource is not allowed to be deleted.
Case 2
storage-network.Use the default valuebutton. TheDisabledcheckbox is selected. ClickSave.