Skip to content

Commit e704062

Browse files
committed
updated logic to check for containment
1 parent b056358 commit e704062

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cns/restserver/internalapi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ func validateCIDRSuperset(newCIDR, oldCIDR string) bool {
746746
return false
747747
}
748748

749-
// Condition 2: Check if the base IP of oldCIDR is contained in newCIDR
750-
if !newPrefix.Contains(oldPrefix.Addr()) {
749+
// Condition 2: Check for Overlap - this will also ensure containment
750+
if !newPrefix.Overlaps(oldPrefix) {
751751
return false
752752
}
753753

cns/restserver/internalapi_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestReconcileNCStatePrimaryIPChangeShouldNotFail(t *testing.T) {
133133
{"10.0.1.0/24", "10.0.2.0/22"},
134134
{"10.0.1.0/20", "10.0.1.0/18"},
135135
{"10.0.1.0/19", "10.0.0.0/15"},
136+
{"10.0.1.0/18", "10.0.1.0/18"},
136137
}
137138

138139
// Run test cases

0 commit comments

Comments
 (0)