Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ 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';
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration nulls cidr/gateway (and broadcast_uri) for all traffic_type='Public' networks. With the current NetworkVO.equals() implementation, two Public networks with cidr == null compare as equal, while NetworkVO.hashCode() is based on id; this violates the equals/hashCode contract and can break HashSet/Map behavior (and may become more likely after this UPDATE makes cidr null everywhere). Consider either (a) updating NetworkVO.equals()/hashCode() to be consistent (and to handle comma-separated CIDRs as described in the PR), or (b) narrowing this UPDATE to only sanitize rows that actually contain legacy comma-separated values so you don’t increase the number of cidr == null Public networks.

Suggested change
WHERE `traffic_type` = 'Public';
WHERE `traffic_type` = 'Public`
AND (
`cidr` LIKE '%,%'
OR `ip6_cidr` LIKE '%,%'
OR `gateway` LIKE '%,%'
OR `ip6_gateway` LIKE '%,%'
);

Copilot uses AI. Check for mistakes.

UPDATE `cloud`.`vm_template` SET guest_os_id = 99 WHERE name = 'kvm-default-vm-import-dummy-template';
Original file line number Diff line number Diff line change
Expand Up @@ -5428,7 +5428,7 @@ public Vlan createVlanAndPublicIpRange(final long zoneId, final long networkId,
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) {
Expand Down Expand Up @@ -6507,11 +6507,14 @@ private boolean deleteAndPublishVlanAndPublicIpRange(final long userId, final lo
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);
Comment on lines +6510 to +6514
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

networkVO is fetched here to check traffic type, but removeCidrAndGatewayForIpv4/Ipv6 immediately re-fetch the same NetworkVO again. To avoid the extra DB hit (and keep the code easier to follow), consider passing the already-fetched NetworkVO into the remove* helpers or moving the traffic-type guard into those helpers.

Copilot uses AI. Check for mistakes.
} else if (ipv6) {
removeCidrAndGatewayForIpv6(networkId, deletedVlan);
}
}

messageBus.publish(_name, MESSAGE_DELETE_VLAN_IP_RANGE_EVENT, PublishScope.LOCAL, deletedVlan);
Expand Down
Loading