Skip to content

Commit

Permalink
fix(evpn): addressing reviews third attempt
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitrios Markou <[email protected]>
  • Loading branch information
mardim91 authored and artek-koltun committed Oct 11, 2024
1 parent ec7a59c commit 37653fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pkg/frr/frr.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func handlesvi(objectData *eventbus.ObjectData) {
log.Printf("%+v\n", comp)

// Checking the timer to decide if we need to replay or not
comp.Replay = utils.CheckReplayThreshold(comp.Timer, replayThreshold)
comp.CheckReplayThreshold(replayThreshold)

err := infradb.UpdateSviStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
Expand All @@ -240,7 +240,7 @@ func handlesvi(objectData *eventbus.ObjectData) {
log.Printf("%+v\n", comp)

// Checking the timer to decide if we need to replay or not
comp.Replay = utils.CheckReplayThreshold(comp.Timer, replayThreshold)
comp.CheckReplayThreshold(replayThreshold)

err := infradb.UpdateSviStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
Expand Down Expand Up @@ -318,7 +318,7 @@ func handlevrf(objectData *eventbus.ObjectData) {
log.Printf("%+v\n", comp)

// Checking the timer to decide if we need to replay or not
comp.Replay = utils.CheckReplayThreshold(comp.Timer, replayThreshold)
comp.CheckReplayThreshold(replayThreshold)

err := infradb.UpdateVrfStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
Expand All @@ -341,7 +341,7 @@ func handlevrf(objectData *eventbus.ObjectData) {
log.Printf("%+v\n", comp)

// Checking the timer to decide if we need to replay or not
comp.Replay = utils.CheckReplayThreshold(comp.Timer, replayThreshold)
comp.CheckReplayThreshold(replayThreshold)

err := infradb.UpdateVrfStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/infradb/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ type Component struct {
Replay bool
}

// CheckReplayThreshold checks if the replay threshold has been exceeded
func (c *Component) CheckReplayThreshold(replayThreshold time.Duration) {
c.Replay = (c.Timer > replayThreshold)
}

func ip4ToInt(ip net.IP) uint32 {
if !reflect.ValueOf(ip).IsZero() {
return uint32(ip[0])<<24 | uint32(ip[1])<<16 | uint32(ip[2])<<8 | uint32(ip[3])
Expand Down
6 changes: 0 additions & 6 deletions pkg/utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"net"
"os/exec"
"regexp"
"time"

"github.com/vishvananda/netlink"
"go.einride.tech/aip/fieldmask"
Expand Down Expand Up @@ -79,11 +78,6 @@ func GetIPAddress(dev string) net.IPNet {
return *validIps[0].IPNet
}

// CheckReplayThreshold checks if the replay threshold has been exceeded
func CheckReplayThreshold(currentTimer, replayThreshold time.Duration) bool {
return (currentTimer > replayThreshold)
}

// ComposeHandlerName this function concatenates the module name and type
func ComposeHandlerName(moduleName, kindOfType string) string {
return moduleName + "." + kindOfType
Expand Down

0 comments on commit 37653fb

Please sign in to comment.