Skip to content

Commit ae455ee

Browse files
jeanvetorelloDaanHoogland
authored andcommitted
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 47c5bb8 commit ae455ee

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
@@ -5428,7 +5428,7 @@ public Vlan createVlanAndPublicIpRange(final long zoneId, final long networkId,
54285428
final VlanVO vlan = commitVlanAndIpRange(zoneId, networkId, physicalNetworkId, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId, domain, vlanOwner, vlanIp6Gateway, vlanIp6Cidr,
54295429
ipv4, zone, vlanType, ipv6Range, ipRange, forSystemVms, provider);
54305430

5431-
if (vlan != null) {
5431+
if (vlan != null && network.getTrafficType() != TrafficType.Public) {
54325432
if (ipv4) {
54335433
addCidrAndGatewayForIpv4(networkId, vlanGateway, vlanNetmask);
54345434
} else if (ipv6) {
@@ -6507,11 +6507,14 @@ private boolean deleteAndPublishVlanAndPublicIpRange(final long userId, final lo
65076507
final boolean ipv4 = deletedVlan.getVlanGateway() != null;
65086508
final boolean ipv6 = deletedVlan.getIp6Gateway() != null;
65096509
final long networkId = deletedVlan.getNetworkId();
6510+
final NetworkVO networkVO = _networkDao.findById(networkId);
65106511

6511-
if (ipv4) {
6512-
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
6513-
} else if (ipv6) {
6514-
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
6512+
if (networkVO != null && networkVO.getTrafficType() != TrafficType.Public) {
6513+
if (ipv4) {
6514+
removeCidrAndGatewayForIpv4(networkId, deletedVlan);
6515+
} else if (ipv6) {
6516+
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
6517+
}
65156518
}
65166519

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

0 commit comments

Comments
 (0)