Skip to content

Commit

Permalink
Fix incorrect removal of VRF device
Browse files Browse the repository at this point in the history
This commit fixes repair method of VRF manager which is buggy
and it incorrectly removes valid VRF device associated with
a user defined network while running reconcile loop.

Signed-off-by: Periyasamy Palanisamy <[email protected]>
  • Loading branch information
pperiyasamy committed Oct 16, 2024
1 parent 93dbdf4 commit 780d007
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go-controller/pkg/node/vrfmanager/vrf_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ func (vrfm *Controller) repair(validVRFs sets.Set[string]) error {
if err != nil {
klog.Errorf("VRF Manager: error deleting stale VRF device %s, err: %v", name, err)
}
delete(vrfm.vrfs, link.Attrs().Index)
}
delete(vrfm.vrfs, link.Attrs().Index)
}
return nil
}
Expand Down
7 changes: 5 additions & 2 deletions go-controller/pkg/node/vrfmanager/vrf_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ var _ = ginkgo.Describe("VRF manager", func() {

var (
c *Controller
vrfLinkName1 = "100-vrf"
vrfLinkName1 = "mp100-udn-vrf"
enslaveLinkName1 = "dev100"
enslaveLinkName2 = "dev101"
vrfLinkName2 = "200-vrf"
vrfLinkName2 = "mp200-udn-vrf"
nlMock *mocks.NetLinkOps
vrfLinkMock1 *netlink_mocks.Link
enslaveLinkMock1 *netlink_mocks.Link
Expand Down Expand Up @@ -116,6 +116,9 @@ var _ = ginkgo.Describe("VRF manager", func() {
enslaveLinkMock1.On("Type").Return("dummy")
err = c.reconcile()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
// Invoke reconcile again to ensure both vrf links in sync.
err = c.reconcile()
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
})

ginkgo.It("repair VRFs", func() {
Expand Down

0 comments on commit 780d007

Please sign in to comment.