-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closes #12135: Prevent the deletion of interfaces with children #14091
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
Conversation
Feedback from the issue thread:
The same applies for modules and while not sure how common; entire racks/sites as well. |
@kkthxbye-code Could you please elaborate on your reason for downvoting this PR? Is your opposition limited to the need to work around this limitation when deleting devices/VMs? |
Mostly yes. If it can be limited to only applying when deleting the parent interface, I think it at least not majorly impacts usability. Do note that the current implementation also breaks bulk deletion of interfaces if any of the devices selected has a parent and the parent is also included in the list. |
I think we can use |
We can mostly work around the bulk deletion issue by ordering interfaces by Another tact would be to sort interfaces to be deleted in reverse order by primary key, as we'd typically expect child interfaces to always be created after their parents. However, there exists a corner case with this approach too, where a new interface is created and then an existing child interface is assigned to it. Combining both approaches (by overriding |
Fixes: #12135
on_delete
behavior forparent
field Interface and VMInterface fromSET_NULL
toRESTRICT
get_bulk_update_queryset()
andget_bulk_destroy_queryset()
methods to API viewset mixins to allow overriding the default querysets for bulk operations