fix(project-cleanup): robust router + network teardown - #1
Merged
Conversation
…ge orphan ports The router branch of `project cleanup` only detached ports whose device_owner equalled `network:router_interface`. That missed DVR (`router_interface_distributed`), HA (`ha_router_replicated_interface`), the external gateway (`router_gateway`) and centralized SNAT ports, so routers with any of these failed to delete with a 409 "ports still attached"; the same port then blocked the subsequent network delete. Now `_delete_router` clears `external_gateway_info` first (releases gateway + centralized SNAT ports), lists ports by `device_id` only, and detaches every router-interface flavor in one pass. `_delete_network` also purges truly orphaned ports (empty device_owner) and stale compute VIFs before deleting the network — Neutron-owned ports (dhcp, router, floatingip) are left alone and cleaned by their own delete paths.
4 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
A real run of
orca project cleanupon a project holding 30 servers, 1 router and 1 network left the router and its network undeletable with two409 Conflicterrors:Both errors trace to the same port — the router's interface — which was never detached.
Root cause in
orca_cli/commands/project.py(old_delete_onerouter branch):This filter only matches legacy L3 routers. It misses:
network:router_interface_distributed(DVR),network:ha_router_replicated_interface(HA routers),network:router_gateway+network:router_centralized_snat(external gateway).The untouched port then transitively blocked the network delete.
Changes
_delete_router:external_gateway_infoviaupdate_routerbefore anything else (releases gateway + centralized-SNAT ports that can't be removed viaremove_router_interface).device_idonly and filters Python-side, so DVR / HA / legacy interfaces are all detached in the same pass.delete_router._delete_network:device_owner) and stale compute VIFs (compute:*) whose server is already gone.dhcp,router,floatingip) are intentionally left alone — they are released by their respective delete paths._delete_onenow delegates the router / network branches to these helpers.tests/test_project_cleanup.pywith 11 unit tests covering: gateway clearing, all three interface flavors, non-interface ports being ignored, orphan + compute-VIF purge, and full tolerance to Neutron failures at every step.Tests
ruff check .mypypytest— 2288 passedpytest --cov=orca_cli --cov-fail-under=85— 87.56% totalRisks
PUThits every router to be deleted, including those without a gateway; Neutron silently acceptsexternal_gateway_info: nullas a no-op in that case, and failures are swallowed by design.