Skip to content

Commit 0220921

Browse files
committed
Netris: tighten the VNET reclaim in the upgrade scripts
1 parent 6489766 commit 0220921

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎engine/schema/src/main/resources/META-INF/db/schema-42210to42220.sql‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ CALL `cloud_usage`.`IDEMPOTENT_ADD_UNIQUE_INDEX`('cloud_usage.usage_volume', 'id
3939
-- Reclaim VNETs belonging to Netris deleted networks
4040
UPDATE op_dc_vnet_alloc a
4141
JOIN networks n ON n.broadcast_uri = CONCAT('netris://', a.vnet)
42+
AND n.data_center_id = a.data_center_id
4243
SET a.account_id = NULL,
4344
a.reservation_id = NULL,
4445
a.taken = NULL
45-
WHERE n.removed IS NOT NULL;
46+
WHERE n.removed IS NOT NULL
47+
AND NOT EXISTS (SELECT 1 FROM networks l
48+
WHERE l.removed IS NULL
49+
AND l.data_center_id = a.data_center_id
50+
AND l.broadcast_uri = n.broadcast_uri)
51+
AND NOT EXISTS (SELECT 1 FROM network_details d
52+
JOIN networks l ON l.id = d.network_id
53+
WHERE d.name = 'netrisvxlanid'
54+
AND d.value = a.vnet
55+
AND l.removed IS NULL
56+
AND l.data_center_id = a.data_center_id);
4657

4758
-- Scope routed network/VPC subnets to a zone, so that the same CIDR can be used in more than one zone. See #14419.
4859
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.ip4_guest_subnet_network_map', 'data_center_id', 'bigint unsigned DEFAULT NULL COMMENT "zone it belongs to"');

0 commit comments

Comments
 (0)