prashanthr2 opened a new pull request, #14421: URL: https://github.com/apache/cloudstack/pull/14421
### Description Fixes #14419. `ip4_guest_subnet_network_map` has no zone column, so the subnet bookkeeping for routed networks and VPCs is global. Creating a routed VPC or network with a CIDR that is already used in another zone fails with `The subnet is in use`, even though the two zones are independent. This adds a nullable `data_center_id` to the table and scopes both the subnet lookup (`findBySubnetAndDataCenterId`) and the parentless overlap check (`listAllNoParentByDataCenterId`) by zone, so the same CIDR can be used once per zone. Existing rows are backfilled from their parent zone subnet, their VPC's `zone_id`, or their network's `data_center_id`. Notes for reviewers: - The new FK gets `ON DELETE CASCADE` because `IDEMPOTENT_ADD_FOREIGN_KEY` hardcodes it. That matches `networks`, `vpc`, `user_ip_address` and most of the schema, though the sibling table `dc_ip4_guest_subnets` uses a plain FK. - Rows with no parent, no VPC and no network cannot be attributed to a zone and keep `data_center_id = NULL`. Those are leftovers from failed network/VPC creates (`state = Free`, unreferenced) and no longer take part in any zone's overlap check, which is the intended direction. ### Types of changes - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] New feature (non-breaking change which adds functionality) - [x] Bug fix (non-breaking change which fixes an issue) - [ ] Enhancement (improves an existing feature and functionality) - [ ] Cleanup (Code refactoring and cleanup, that may add test cases) - [ ] build/CI - [ ] test (unit or integration test code) ### Feature/Enhancement Scale or Bug Severity #### Bug Severity - [ ] BLOCKER - [ ] Critical - [x] Major - [ ] Minor - [ ] Trivial ### How Has This Been Tested? Unit tests in `RoutedIpv4ManagerImplTest` updated for the new DAO signatures, plus a new `testGetOrCreateIpv4SubnetForGuestNetworkOrVpcInternalByCidrInAnotherZone` covering the cross-zone case. Manual: create a routed VPC with `10.0.0.0/8` in zone 1, then a second routed VPC with the same CIDR in zone 2. Before this change the second create fails with "The subnet is in use"; after it, both succeed and each row in `ip4_guest_subnet_network_map` carries its own `data_center_id`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017rnv8vT6LQSKfwkzp8tvg9 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
