Skip to content

Commit 1fd9d3a

Browse files
authored
Merge pull request #5125 from maiqueb/reconcile-network-on-physical-net-name-updates
net controller: reconcile on physical net name updates
2 parents 95b6ca5 + 4c9fa19 commit 1fd9d3a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

go-controller/pkg/util/multi_network.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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)) {

go-controller/pkg/util/multi_network_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
12631291
func applyNADDefaults(nad *nadv1.NetworkAttachmentDefinition) *nadv1.NetworkAttachmentDefinition {
12641292
const (
12651293
name = "nad1"

0 commit comments

Comments
 (0)