File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -840,6 +840,9 @@ func (nInfo *secondaryNetInfo) canReconcile(other NetInfo) bool {
840840 if nInfo .primaryNetwork != other .IsPrimaryNetwork () {
841841 return false
842842 }
843+ if nInfo .physicalNetworkName != other .PhysicalNetworkName () {
844+ return false
845+ }
843846
844847 lessCIDRNetworkEntry := func (a , b config.CIDRNetworkEntry ) bool { return a .String () < b .String () }
845848 if ! cmp .Equal (nInfo .subnets , other .Subnets (), cmpopts .SortSlices (lessCIDRNetworkEntry )) {
Original file line number Diff line number Diff line change @@ -1260,6 +1260,34 @@ func TestNewNetInfo(t *testing.T) {
12601260 }
12611261}
12621262
1263+ func TestAreNetworksCompatible (t * testing.T ) {
1264+ tests := []struct {
1265+ desc string
1266+ aNetwork NetInfo
1267+ anotherNetwork NetInfo
1268+ expectedResult bool
1269+ expectationDescription string
1270+ }{
1271+ {
1272+ desc : "physical network name update" ,
1273+ aNetwork : & secondaryNetInfo {physicalNetworkName : "A" },
1274+ anotherNetwork : & secondaryNetInfo {physicalNetworkName : "B" },
1275+ expectedResult : false ,
1276+ expectationDescription : "we should reconcile on physical network name updates" ,
1277+ },
1278+ }
1279+
1280+ for _ , test := range tests {
1281+ t .Run (test .desc , func (t * testing.T ) {
1282+ g := gomega .NewWithT (t )
1283+ g .Expect (AreNetworksCompatible (test .aNetwork , test .anotherNetwork )).To (
1284+ gomega .Equal (test .expectedResult ),
1285+ test .expectationDescription ,
1286+ )
1287+ })
1288+ }
1289+ }
1290+
12631291func applyNADDefaults (nad * nadv1.NetworkAttachmentDefinition ) * nadv1.NetworkAttachmentDefinition {
12641292 const (
12651293 name = "nad1"
You can’t perform that action at this time.
0 commit comments