Copilot commented on code in PR #14851:
URL: https://github.com/apache/cloudstack/pull/14851#discussion_r4700488512


##########
engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql:
##########
@@ -32,6 +47,37 @@ UPDATE op_dc_vnet_alloc a
         a.taken = NULL
 WHERE n.removed IS NOT NULL;
 
+-- Scope routed network/VPC subnets to a zone, so that the same CIDR can be 
used in more than one zone. See #14419.
+CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ip4_guest_subnet_network_map', 
'data_center_id', 'bigint unsigned DEFAULT NULL COMMENT "zone it belongs to"');
+
+UPDATE `cloud`.`ip4_guest_subnet_network_map` m
+    JOIN `cloud`.`dc_ip4_guest_subnets` p ON p.id = m.parent_id
+    SET m.data_center_id = p.data_center_id
+WHERE m.data_center_id IS NULL;
+
+UPDATE `cloud`.`ip4_guest_subnet_network_map` m
+    JOIN `cloud`.`vpc` v ON v.id = m.vpc_id
+    SET m.data_center_id = v.zone_id
+WHERE m.data_center_id IS NULL;
+
+UPDATE `cloud`.`ip4_guest_subnet_network_map` m
+    JOIN `cloud`.`networks` n ON n.id = m.network_id
+    SET m.data_center_id = n.data_center_id
+WHERE m.data_center_id IS NULL;
+
+CALL 
`cloud`.`IDEMPOTENT_DROP_FOREIGN_KEY`('cloud.ip4_guest_subnet_network_map', 
'fk_ip4_guest_subnet_network_map__data_center_id');
+CALL 
`cloud`.`IDEMPOTENT_ADD_FOREIGN_KEY`('cloud.ip4_guest_subnet_network_map', 
'fk_ip4_guest_subnet_network_map__data_center_id', '(`data_center_id`)', 
'`data_center`(`id`)');
+
+--- Add existing cross zone templates to the missing edge zones
+INSERT INTO cloud.template_zone_ref (zone_id, template_id, created, 
last_updated)
+SELECT dc.id, vt.id, NOW(), NOW()
+FROM cloud.data_center dc
+JOIN cloud.vm_template vt ON vt.cross_zones = 1 AND vt.removed IS NULL
+WHERE dc.type = 'Edge' AND dc.removed IS NULL
+  AND NOT EXISTS (SELECT 1 FROM cloud.template_zone_ref tzr
+                  WHERE tzr.zone_id = dc.id AND tzr.template_id = vt.id AND 
tzr.removed IS NULL);
+------------------------------------------------------------------------------------------------

Review Comment:
   The 4.22.2 object-store allocation backfill is still missing here. Databases 
initialized by `schema-42040to42100.sql:742–749` can therefore keep GiB counts 
in the byte-valued `allocated_size` field, causing bucket capacity checks to 
undercount reservations and allow over-allocation. Carry over the recalculation 
from `schema-42210to42220.sql`, using `SUM(quota) * 1024 * 1024 * 1024`.



##########
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java:
##########
@@ -249,7 +249,7 @@ public DatabaseUpgradeChecker() {
                 .next("4.21.0.0", new Upgrade42100to42200())
                 .next("4.22.0.0", new Upgrade42200to42210())
                 .next("4.22.1.0", new Upgrade42210to42300())
-                .next("4.22.2.0", new Upgrade42300to2400())
+                .next("4.22.2.0", new Upgrade42210to42300())

Review Comment:
   This changes the route that previously skipped the 4.23 migration, but the 
existing upgrade-path tests do not cover either affected starting version. 
`DatabaseUpgradeCheckerTest.testCalculateUpgradePath42300to2400` only exercises 
the unchanged 4.23 route. Please add tests starting at `4.22.2.0` and 
`4.22.3.0`, asserting exactly `Upgrade42210to42300` followed by 
`Upgrade42300to2400`, and cover `4.22.1.0` to ensure the duplicate registration 
does not execute the 4.23 migration twice.



-- 
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]

Reply via email to