mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-11 08:42:54 -05:00
[GH-ISSUE #3048] Deleting a site doesn't cascade to its site-resources; alias stays reserved → 409 on recreate #23594
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @maisim on GitHub (May 11, 2026).
Original GitHub issue: https://github.com/fosrl/pangolin/issues/3048
Describe the Bug
DELETE /site/{id} leaves the child site-resource in DB with its alias still globally reserved. The orphan has no parent site, so it doesn't show up in site-scoped listings, and there's no GET /site-resource?alias=… endpoint to discover the conflicting id. State is unrecoverable through normal flows.
Root cause is in the data model: siteResources.networkId uses onDelete: "set null" instead of onDelete: "cascade", and orphaned networks (no longer referenced by any siteNetworks row after a site deletion) are never cleaned up. The fix seems requires both a schema migration (change onDelete on siteResources.networkId) and cleanup logic in deleteSite to remove networks that become unreferenced.
Environment
To Reproduce
Expected Behavior
Either cascade-delete child site-resources, or refuse DELETE /site/{id} with 409 while children exist. In both cases, the alias should be released when its resource is gone.
@maisim commented on GitHub (May 11, 2026):
Here a script to reproduce the problem:
https://gist.github.com/maisim/6e6f12ad274f909fb6855df71c5faea6
@maisim commented on GitHub (May 11, 2026):
Fisrt, big thank you for this awesome tool :)
I can try to propose a fix for this, but I would appreciate some feedback first, since I do not have a global view of the project and I may be missing some design constraints.
From what I understand, there are at least two possible approaches:
siteResourceswhen their parent network/site is deleted.DELETE /site/{id}while related resources still exist, and return a409instead.My current assumption is that cascading the deletion is the expected behavior, because after the site is deleted the resource is no longer reachable through normal API flows, while its alias remains globally reserved.
If that direction sounds correct, I can try to open a PR with:
onDeletebehavior;deleteSitefor networks that become unreferenced;Please let me know if there is a preferred approach or any project-specific constraint I should take into account before working on it.
@AstralDestiny commented on GitHub (May 11, 2026):
Well deletion of site shouldn't delete resources as they can be moved to different sites and whatnot
@oschwartz10612 commented on GitHub (May 11, 2026):
Agreed with @AstralDestiny. This was a change in 1.18 when we introduced HA - we wanted to decouple the private resources from the sites in the same way the public resources are. When you delete a site it just deletes the target on the public resource not the resource itself. Similarly when deleting a site it just unregisters it from the private resource so you can choose other ones.