Skip to content

Commit 6dbc9e2

Browse files
committed
[CNS] Overlay Expansion Subnet Update Job Bug Fix (#4103)
hot fix
1 parent b2762a3 commit 6dbc9e2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cns/restserver/internalapi.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,19 @@ func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.
600600
if ok {
601601
existingReq := existingNCInfo.CreateNetworkContainerRequest
602602
if !reflect.DeepEqual(existingReq.IPConfiguration.IPSubnet, req.IPConfiguration.IPSubnet) {
603-
logger.Errorf("[Azure CNS] Error. PrimaryCA is not same, NCId %s, old CA %s/%d, new CA %s/%d",
604-
req.NetworkContainerid,
605-
existingReq.IPConfiguration.IPSubnet.IPAddress,
606-
existingReq.IPConfiguration.IPSubnet.PrefixLength,
607-
req.IPConfiguration.IPSubnet.IPAddress,
608-
req.IPConfiguration.IPSubnet.PrefixLength)
609-
return types.PrimaryCANotSame
603+
// check for potential overlay subnet expansion - checking if new subnet is a superset of old subnet
604+
isCIDRSuperset := validateCIDRSuperset(
605+
fmt.Sprintf("%s/%d", req.IPConfiguration.IPSubnet.IPAddress, req.IPConfiguration.IPSubnet.PrefixLength),
606+
fmt.Sprintf("%s/%d", existingReq.IPConfiguration.IPSubnet.IPAddress, existingReq.IPConfiguration.IPSubnet.PrefixLength))
607+
if !isCIDRSuperset {
608+
logger.Errorf("[Azure CNS] Error. PrimaryCA is not same, NCId %s, old CA %s/%d, new CA %s/%d", //nolint:staticcheck // Suppress SA1019: logger.Errorf is deprecated
609+
req.NetworkContainerid,
610+
existingReq.IPConfiguration.IPSubnet.IPAddress,
611+
existingReq.IPConfiguration.IPSubnet.PrefixLength,
612+
req.IPConfiguration.IPSubnet.IPAddress,
613+
req.IPConfiguration.IPSubnet.PrefixLength)
614+
return types.PrimaryCANotSame
615+
}
610616
}
611617
}
612618

0 commit comments

Comments
 (0)