This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.22 by this push:
new 0f13b4a79b1 VPC restart cleanup for Public networks with multi-CIDR
data (#12622)
0f13b4a79b1 is described below
commit 0f13b4a79b11251fcad4b9f09e40cfb6e95c797f
Author: Jtolelo <[email protected]>
AuthorDate: Mon Apr 13 09:18:29 2026 -0300
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 <[email protected]>
---
.../src/main/resources/META-INF/db/schema-42200to42210.sql | 9 +++++++++
.../com/cloud/configuration/ConfigurationManagerImpl.java | 13 ++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git
a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
index 96522375962..42d806b0ed4 100644
--- a/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
+++ b/engine/schema/src/main/resources/META-INF/db/schema-42200to42210.sql
@@ -34,6 +34,15 @@ UPDATE `cloud`.`alert` SET type = 34 WHERE name =
'ALERT.VR.PRIVATE.IFACE.MTU';
-- Update configuration 'kvm.ssh.to.agent' description and is_dynamic fields
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';
+-- Sanitize legacy network-level addressing fields for Public networks
+UPDATE `cloud`.`networks`
+SET `broadcast_uri` = NULL,
+ `gateway` = NULL,
+ `cidr` = NULL,
+ `ip6_gateway` = NULL,
+ `ip6_cidr` = NULL
+WHERE `traffic_type` = 'Public';
+
UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name =
'kvm-default-vm-import-dummy-template';
-- Update existing vm_template records with NULL type to "USER"
diff --git
a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
index f8bf1dca056..c8c70b257cd 100644
--- a/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -5429,7 +5429,7 @@ public class ConfigurationManagerImpl extends ManagerBase
implements Configurati
final VlanVO vlan = commitVlanAndIpRange(zoneId, networkId,
physicalNetworkId, podId, startIP, endIP, vlanGateway, vlanNetmask, vlanId,
domain, vlanOwner, vlanIp6Gateway, vlanIp6Cidr,
ipv4, zone, vlanType, ipv6Range, ipRange, forSystemVms,
provider);
- if (vlan != null) {
+ if (vlan != null && network.getTrafficType() != TrafficType.Public) {
if (ipv4) {
addCidrAndGatewayForIpv4(networkId, vlanGateway, vlanNetmask);
} else if (ipv6) {
@@ -6533,11 +6533,14 @@ public class ConfigurationManagerImpl extends
ManagerBase implements Configurati
final boolean ipv4 = deletedVlan.getVlanGateway() != null;
final boolean ipv6 = deletedVlan.getIp6Gateway() != null;
final long networkId = deletedVlan.getNetworkId();
+ final NetworkVO networkVO = _networkDao.findById(networkId);
- if (ipv4) {
- removeCidrAndGatewayForIpv4(networkId, deletedVlan);
- } else if (ipv6) {
- removeCidrAndGatewayForIpv6(networkId, deletedVlan);
+ if (networkVO != null && networkVO.getTrafficType() !=
TrafficType.Public) {
+ if (ipv4) {
+ removeCidrAndGatewayForIpv4(networkId, deletedVlan);
+ } else if (ipv6) {
+ removeCidrAndGatewayForIpv6(networkId, deletedVlan);
+ }
}
messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT,
PublishScope.LOCAL, deletedVlan);