Skip to content

Commit 0f13b4a

Browse files
VPC restart cleanup for Public networks with multi-CIDR data (#12622)
* Fix VPC restart with multi-CIDR networks: handle comma-separated CIDR in NetworkVO.equals() When a network has multiple CIDRs (e.g. '192.168.2.0/24,160.0.0.0/24'), NetworkVO.equals() passes the raw comma-separated string to NetUtils.isNetworkAWithinNetworkB() which expects a single CIDR, causing 'cidr is not formatted correctly' error during VPC restart with cleanup=true. Extract only the first CIDR value before passing to NetUtils. * Fix root cause: skip CIDR/gateway updates for Public traffic type networks addCidrAndGatewayForIpv4/Ipv6 (introduced by PR #11249) was called for all network types without checking if the network is Public. This caused comma-separated CIDRs to be stored on Public networks, which then triggered 'cidr is not formatted correctly' errors during VPC restart. Add TrafficType.Public guard in both the VLAN creation (addCidr) and VLAN deletion (removeCidr) paths in ConfigurationManagerImpl. * Sanitize legacy network-level addressing fields for Public networks --------- Co-authored-by: dahn <daan@onecht.net>
1 parent b02b652 commit 0f13b4a

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name = 'ALERT.VR.PRIVATE.IFACE.MTU';
3434
-- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields
3535
UPDATE `cloud`.`configuration` SET description = 'True if the management server will restart the agent service via SSH into the KVM hosts after or during maintenance operations', is_dynamic = 1 WHERE name = 'kvm.ssh.to.agent';
3636

37+
-- Sanitize legacy network-level addressing fields for Public networks
38+
UPDATE `cloud`.`networks`
39+
SET `broadcast_uri` = NULL,
40+
`gateway` = NULL,
41+
`cidr` = NULL,
42+
`ip6_gateway` = NULL,
43+
`ip6_cidr` = NULL
44+
WHERE `traffic_type` = 'Public';
45+
3746
UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name = 'kvm-default-vm-import-dummy-template';
3847

3948
-- Update existing vm_template records with NULL type to "USER"

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5429,7 +5429,7 @@ public Vlan createVlanAndPublicIpRange(final long zoneId, final long networkId,
54295429
final VlanVO vlan = commitVlanAndIpRange(zoneId, networkId, physicalNetworkId, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId, domain, vlanOwner, vlanIp6Gateway, vlanIp6Cidr,
54305430
ipv4, zone, vlanType, ipv6Range, ipRange, forSystemVms, provider);
54315431

5432-
if (vlan != null) {
5432+
if (vlan != null && network.getTrafficType() != TrafficType.Public) {
54335433
if (ipv4) {
54345434
addCidrAndGatewayForIpv4(networkId, vlanGateway, vlanNetmask);
54355435
} else if (ipv6) {
@@ -6533,11 +6533,14 @@ private boolean deleteAndPublishVlanAndPublicIpRange(final long userId, final lo
65336533
final boolean ipv4 = deletedVlan.getVlanGateway() != null;
65346534
final boolean ipv6 = deletedVlan.getIp6Gateway() != null;
65356535
final long networkId = deletedVlan.getNetworkId();
6536+
final NetworkVO networkVO = _networkDao.findById(networkId);
65366537

6537-
if (ipv4) {
6538-
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
6539-
} else if (ipv6) {
6540-
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
6538+
if (networkVO != null && networkVO.getTrafficType() != TrafficType.Public) {
6539+
if (ipv4) {
6540+
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
6541+
} else if (ipv6) {
6542+
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
6543+
}
65416544
}
65426545

65436546
messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, deletedVlan);

0 commit comments

Comments
 (0)