network: handle missing network when releasing public IP - #14133
xujiantop-crypto wants to merge 2 commits into
Conversation
Signed-off-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
Signed-off-by: xujiantop-crypto <265865031+xujiantop-crypto@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14133 +/- ##
=========================================
Coverage 17.94% 17.94%
- Complexity 16145 16151 +6
=========================================
Files 5928 5928
Lines 535174 535176 +2
Branches 65494 65495 +1
=========================================
+ Hits 96017 96057 +40
+ Misses 428228 428181 -47
- Partials 10929 10938 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the fix and the tests. I tried it on a KVM zone with the steps from #14068 (VPC offering with the Firewall service, a tier with a VM, a public IP with a port forwarding and a firewall rule, then remove the VM and the tier). Without the change, deleting the VPC fails with With the change, both work. The VPC is deleted, and the released IP goes back to Free with I was curious where the stale id comes from. On tier removal, One thing I noticed: after releasing the IP with the VPC kept, the IP is still configured on the VPC router's public interface, with an iptables rule for it, since no ipassoc is sent in the new path. As the IP is Free again, it could be given to another network while the old router still holds it. Would it make sense to apply the association through the VPC in that case, since the router is still there, or to clear the association when the tier is removed so the normal release path runs? Either way, keeping the guard as a safety net sounds good to me. |
Fixes #14068
During VPC teardown, a public IP can retain its associated network ID after the tier's network record has been deleted.
disassociatePublicIpAddresspasses the missing network toapplyIpAssociations, which dereferences it and aborts VPC deletion with aNullPointerException.Resolve the associated network before choosing the release path. When the network no longer exists, a releasing IP follows the existing quarantine and unassignment path. The association path continues to be used when the network exists.
The regression test supplies a non-null associated network ID whose DAO lookup returns null while the VPC still exists. It verifies successful release, quarantine, IP unassignment, VPC provider cleanup, annotation cleanup and lock release, without calling
applyIpAssociations. Additional tests cover successful and failed associations when the network exists, and prevent repeated quarantine/unassignment of an already free IP when the network is missing.This targets
4.22in accordance with the contribution guide's release-branch policy for bug fixes; the affected code is also present there.Validation
NullPointerExceptionon the unfixed4.22base.IpAddressManagerTestpasses: 30 tests, 0 failures/errors/skips. All 25 selected reactor modules succeed, with 0 Checkstyle violations (JDK 11).git diff --checkpasses.The Maven download plugin could not retrieve the system VM checksum file in this environment. I downloaded the unmodified official
https://download.cloudstack.org/systemvm/4.22/sha512sum.txttoengine/schema/dist/systemvm-templates/sha512sum.txtand ran:mvn -B -pl server -am -Dtest=IpAddressManagerTest -Dsurefire.failIfNoSpecifiedTests=false -Ddownload.plugin.skip=true testOnly the redundant download was skipped; compilation, Checkstyle and the selected tests ran. No build configuration changes are included.
For an environment-level check, follow the steps in #14068: create a VPC offering with firewall service enabled, deploy a tier and VM, apply a public-IP firewall rule, remove the VM and tier, then destroy the VPC. The VPC should be removed without the missing-network exception and the public IP should be released. This full VPC scenario has not been run locally.