Skip to content

Commit

Permalink
fix(evpn-bridge): missing resource version check for the objects, als…
Browse files Browse the repository at this point in the history
…o return no subscribers found for object if not found any

Signed-off-by: Saikumar, Banoth <[email protected]>
  • Loading branch information
Inbanoth committed Apr 17, 2024
1 parent 1ee4c48 commit 2816819
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
15 changes: 15 additions & 0 deletions pkg/LinuxCIModule/lci.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ func handlebp(objectData *eventbus.ObjectData) {
log.Printf("LCI : GetBP error: %s\n", err)
return
}
if objectData.ResourceVersion != BP.ResourceVersion {
log.Printf("LVM: Mismatch in resoruce version %+v\n and bp resource version %+v\n", objectData.ResourceVersion, BP.ResourceVersion)
comp.Name = lciComp
comp.CompStatus = common.ComponentStatusError
if comp.Timer == 0 {
comp.Timer = 2 * time.Second
} else {
comp.Timer *= 2
}
err := infradb.UpdateBPStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
log.Printf("error in updating bp status: %s\n", err)
}
return
}
if len(BP.Status.Components) != 0 {
for i := 0; i < len(BP.Status.Components); i++ {
if BP.Status.Components[i].Name == "lci" {
Expand Down
27 changes: 18 additions & 9 deletions pkg/LinuxGeneralModule/lgm.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,25 @@ func (h *ModulelgmHandler) HandleEvent(eventType string, objectData *eventbus.Ob
func handleLB(objectData *eventbus.ObjectData) {
var comp common.Component
lb, err := infradb.GetLB(objectData.Name)
if err == nil {
log.Printf("LGM : GetLB Name: %s\n", lb.Name)
} else {
if err != nil {
log.Printf("LGM: GetLB error: %s %s\n", err, objectData.Name)
return
}
if objectData.ResourceVersion != lb.ResourceVersion {
log.Printf("LGM: Mismatch in resoruce version %+v\n and lb resource version %+v\n", objectData.ResourceVersion, lb.ResourceVersion)
comp.Name = lgmComp
comp.CompStatus = common.ComponentStatusError
if comp.Timer == 0 {
comp.Timer = 2 * time.Second
} else {
comp.Timer *= 2
}
err := infradb.UpdateLBStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
log.Printf("error in updating lb status: %s\n", err)
}
return
}
if len(lb.Status.Components) != 0 {
for i := 0; i < len(lb.Status.Components); i++ {
if lb.Status.Components[i].Name == lgmComp {
Expand Down Expand Up @@ -148,9 +161,7 @@ func handleLB(objectData *eventbus.ObjectData) {
func handlesvi(objectData *eventbus.ObjectData) {
var comp common.Component
svi, err := infradb.GetSvi(objectData.Name)
if err == nil {
log.Printf("LGM : GetSvi Name: %s\n", svi.Name)
} else {
if err != nil {
log.Printf("LGM: GetSvi error: %s %s\n", err, objectData.Name)
return
}
Expand Down Expand Up @@ -221,9 +232,7 @@ func handlesvi(objectData *eventbus.ObjectData) {
func handlevrf(objectData *eventbus.ObjectData) {
var comp common.Component
vrf, err := infradb.GetVrf(objectData.Name)
if err == nil {
log.Printf("LGM : GetVRF Name: %s\n", vrf.Name)
} else {
if err != nil {
log.Printf("LGM: GetVRF error: %s %s\n", err, objectData.Name)
return
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/LinuxVendorModule/ipu/ipu.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ func handlebp(objectData *eventbus.ObjectData) {
log.Printf("LVM : GetBP error: %s\n", err)
return
}
if objectData.ResourceVersion != bp.ResourceVersion {
log.Printf("LVM: Mismatch in resoruce version %+v\n and bp resource version %+v\n", objectData.ResourceVersion, bp.ResourceVersion)
comp.Name = lvmComp
comp.CompStatus = common.ComponentStatusError
if comp.Timer == 0 {
comp.Timer = 2 * time.Second
} else {
comp.Timer *= 2
}
err := infradb.UpdateBPStatus(objectData.Name, objectData.ResourceVersion, objectData.NotificationID, nil, comp)
if err != nil {
log.Printf("error in updating bp status: %s\n", err)
}
return
}
if len(bp.Status.Components) != 0 {
for i := 0; i < len(bp.Status.Components); i++ {
if bp.Status.Components[i].Name == lvmComp {
Expand Down
4 changes: 0 additions & 4 deletions pkg/frr/frr.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ func handlesvi(objectData *eventbus.ObjectData) {
return
}

log.Printf("FRR :GetSvi Name: %s\n", svi.Name)

if objectData.ResourceVersion != svi.ResourceVersion {
log.Printf("FRR: Mismatch in resoruce version %+v\n and svi resource version %+v\n", objectData.ResourceVersion, svi.ResourceVersion)
comp.Name = frrComp
Expand Down Expand Up @@ -132,8 +130,6 @@ func handlevrf(objectData *eventbus.ObjectData) {
return
}

log.Printf("FRR :GetVRF Name: %s\n", vrf.Name)

if len(vrf.Status.Components) != 0 {
for i := 0; i < len(vrf.Status.Components); i++ {
if vrf.Status.Components[i].Name == frrComp {
Expand Down
12 changes: 12 additions & 0 deletions pkg/infradb/infradb.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func CreateLB(lb *LogicalBridge) error {
subscribers := eventbus.EBus.GetSubscribers("logical-bridge")
if subscribers == nil {
log.Println("CreateLB(): No subscribers for Logical Bridge objects")
return errors.New("no subscribers found for logical bridge")
}

log.Printf("CreateLB(): Create Logical Bridge: %+v\n", lb)
Expand Down Expand Up @@ -144,6 +145,7 @@ func DeleteLB(name string) error {
subscribers := eventbus.EBus.GetSubscribers("logical-bridge")
if subscribers == nil {
log.Println("DeleteLB(): No subscribers for Logical Bridge objects")
return errors.New("no subscribers found for logical bridge")
}

lb := LogicalBridge{}
Expand Down Expand Up @@ -242,6 +244,7 @@ func UpdateLB(lb *LogicalBridge) error {
subscribers := eventbus.EBus.GetSubscribers("logical-bridge")
if subscribers == nil {
log.Println("UpdateLB(): No subscribers for Logical Bridge objects")
return errors.New("no subscribers found for logical bridge")
}

err := infradb.client.Set(lb.Name, lb)
Expand Down Expand Up @@ -386,6 +389,7 @@ func CreateBP(bp *BridgePort) error {
subscribers := eventbus.EBus.GetSubscribers("bridge-port")
if subscribers == nil {
log.Println("CreateBP(): No subscribers for Bridge Port objects")
return errors.New("no subscribers found for bridge port")
}

// Dimitris: Do I need to add here a check for MAC uniquness in of BP ?
Expand Down Expand Up @@ -481,6 +485,7 @@ func DeleteBP(name string) error {
subscribers := eventbus.EBus.GetSubscribers("bridge-port")
if subscribers == nil {
log.Println("DeleteBP(): No subscribers for Bridge Port objects")
return errors.New("no subscribers found for bridge port")
}

bp := BridgePort{}
Expand Down Expand Up @@ -571,6 +576,7 @@ func UpdateBP(bp *BridgePort) error {
subscribers := eventbus.EBus.GetSubscribers("bridge-port")
if subscribers == nil {
log.Println("UpdateBP(): No subscribers for Bridge Port objects")
return errors.New("no subscribers found for bridge port")
}

err := infradb.client.Set(bp.Name, bp)
Expand Down Expand Up @@ -726,6 +732,7 @@ func CreateVrf(vrf *Vrf) error {
subscribers := eventbus.EBus.GetSubscribers("vrf")
if subscribers == nil {
log.Println("CreateVrf(): No subscribers for Vrf objects")
return errors.New("no subscribers found for vrf")
}

log.Printf("CreateVrf(): Create Vrf: %+v\n", vrf)
Expand Down Expand Up @@ -798,6 +805,7 @@ func DeleteVrf(name string) error {
subscribers := eventbus.EBus.GetSubscribers("vrf")
if subscribers == nil {
log.Println("DeleteVrf(): No subscribers for Vrf objects")
return errors.New("no subscribers found for vrf")
}

vrf := Vrf{}
Expand Down Expand Up @@ -890,6 +898,7 @@ func UpdateVrf(vrf *Vrf) error {
subscribers := eventbus.EBus.GetSubscribers("vrf")
if subscribers == nil {
log.Println("CreateVrf(): No subscribers for Vrf objects")
return errors.New("no subscribers found for vrf")
}

err := infradb.client.Set(vrf.Name, vrf)
Expand Down Expand Up @@ -1035,6 +1044,7 @@ func CreateSvi(svi *Svi) error {
subscribers := eventbus.EBus.GetSubscribers("svi")
if subscribers == nil {
log.Println("CreateSvi(): No subscribers for SVI objects")
return errors.New("no subscribers found for svi")
}

log.Printf("CreateSvi(): Create SVI: %+v\n", svi)
Expand Down Expand Up @@ -1125,6 +1135,7 @@ func DeleteSvi(name string) error {
subscribers := eventbus.EBus.GetSubscribers("svi")
if subscribers == nil {
log.Println("DeleteSvi(): No subscribers for SVI objects")
return errors.New("no subscribers found for svi")
}

svi := Svi{}
Expand Down Expand Up @@ -1212,6 +1223,7 @@ func UpdateSvi(svi *Svi) error {
subscribers := eventbus.EBus.GetSubscribers("svi")
if subscribers == nil {
log.Println("UpdateSvi(): No subscribers for SVI objects")
return errors.New("no subscribers found for svi")
}

err := infradb.client.Set(svi.Name, svi)
Expand Down

0 comments on commit 2816819

Please sign in to comment.