Skip to content

Commit 4c9fa19

Browse files
committed
net controller: reconcile on physical net name updates
Marking `physicalNetworkName` changes as not reconcilable will lead the network controller to dispose of the old network controller, and instantiate a new one, thus reacting to the configuration update - [0]. [0] - https://github.com/ovn-kubernetes/ovn-kubernetes/blob/562f752b01c5d4a1d8ee4b5b3cfebb047f4cad7a/go-controller/pkg/networkmanager/network_controller.go#L281 Signed-off-by: Miguel Duarte Barroso <[email protected]>
1 parent ebc1d53 commit 4c9fa19

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)