Skip to content

Commit

Permalink
Merge pull request #842 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
one-arm LB mode: fixes for failures seen in cicd runs
  • Loading branch information
UltraInstinct14 authored Oct 16, 2024
2 parents a5c12c2 + c59d6fe commit a1f2174
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 272 deletions.
239 changes: 120 additions & 119 deletions api/loxinlp/nlp.go

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions api/restapi/handler/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
package handler

import (
"net"

"github.com/go-openapi/runtime/middleware"
"github.com/loxilb-io/loxilb/api/models"
"github.com/loxilb-io/loxilb/api/restapi/operations"
cmn "github.com/loxilb-io/loxilb/common"
tk "github.com/loxilb-io/loxilib"
"net"
)

func ConfigGetCIState(params operations.GetConfigCistateAllParams) middleware.Responder {
var result []*models.CIStatusGetEntry
result = make([]*models.CIStatusGetEntry, 0)
tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
hasMod, err := ApiHooks.NetCIStateGet()
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
for _, h := range hasMod {
Expand All @@ -45,19 +46,19 @@ func ConfigGetCIState(params operations.GetConfigCistateAllParams) middleware.Re
}

func ConfigPostCIState(params operations.PostConfigCistateParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var hasMod cmn.HASMod

// Set HA State
hasMod.Instance = params.Attr.Instance
hasMod.State = params.Attr.State
hasMod.Vip = net.ParseIP(params.Attr.Vip)
tk.LogIt(tk.LogDebug, "[API] Instance %s New HA State : %v, VIP: %s\n",
tk.LogIt(tk.LogDebug, "api: Instance %s New HA State : %v, VIP: %s\n",
hasMod.Instance, hasMod.State, hasMod.Vip)
_, err := ApiHooks.NetCIStateMod(&hasMod)
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
return &ResultResponse{Result: "Success"}
Expand All @@ -66,10 +67,10 @@ func ConfigPostCIState(params operations.PostConfigCistateParams) middleware.Res
func ConfigGetBFDSession(params operations.GetConfigBfdAllParams) middleware.Responder {
var result []*models.BfdGetEntry
result = make([]*models.BfdGetEntry, 0)
tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
bfdMod, err := ApiHooks.NetBFDGet()
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
for _, h := range bfdMod {
Expand All @@ -89,7 +90,7 @@ func ConfigGetBFDSession(params operations.GetConfigBfdAllParams) middleware.Res
}

func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var bfdMod cmn.BFDMod

Expand All @@ -100,18 +101,18 @@ func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Resp
bfdMod.Interval = params.Attr.Interval
bfdMod.RetryCount = params.Attr.RetryCount

tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session add : %s, Interval: %d, RetryCount: %d\n",
tk.LogIt(tk.LogDebug, "api: Instance %s BFD session add : %s, Interval: %d, RetryCount: %d\n",
bfdMod.Instance, bfdMod.RemoteIP, bfdMod.Interval, bfdMod.RetryCount)
_, err := ApiHooks.NetBFDAdd(&bfdMod)
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
return &ResultResponse{Result: "Success"}
}

func ConfigDeleteBFDSession(params operations.DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var bfdMod cmn.BFDMod

Expand All @@ -122,11 +123,11 @@ func ConfigDeleteBFDSession(params operations.DeleteConfigBfdRemoteIPRemoteIPPar

bfdMod.RemoteIP = net.ParseIP(params.RemoteIP)

tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session delete : %s\n",
tk.LogIt(tk.LogDebug, "api: Instance %s BFD session delete : %s\n",
bfdMod.Instance, bfdMod.RemoteIP)
_, err := ApiHooks.NetBFDDel(&bfdMod)
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
return &ResultResponse{Result: "Success"}
Expand Down
4 changes: 2 additions & 2 deletions api/restapi/handler/conntrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
)

func ConfigGetConntrack(params operations.GetConfigConntrackAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Conntrack %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Conntrack %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
// Get Conntrack informations
res, err := ApiHooks.NetCtInfoGet()
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
var result []*models.ConntrackEntry
Expand Down
8 changes: 4 additions & 4 deletions api/restapi/handler/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (

func ConfigGetEndPoint(params operations.GetConfigEndpointAllParams) middleware.Responder {
// Get endpoint rules
tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

res, err := ApiHooks.NetEpHostGet()
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error : %v\n", err)
tk.LogIt(tk.LogDebug, "api: Error : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
var result []*models.EndPointGetEntry
Expand Down Expand Up @@ -58,7 +58,7 @@ func ConfigGetEndPoint(params operations.GetConfigEndpointAllParams) middleware.
}

func ConfigPostEndPoint(params operations.PostConfigEndpointParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

EP := cmn.EndPointMod{}
EP.HostName = params.Attr.HostName
Expand All @@ -78,7 +78,7 @@ func ConfigPostEndPoint(params operations.PostConfigEndpointParams) middleware.R
}

func ConfigDeleteEndPoint(params operations.DeleteConfigEndpointEpipaddressIPAddressParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

EP := cmn.EndPointMod{}
EP.HostName = params.IPAddress
Expand Down
6 changes: 3 additions & 3 deletions api/restapi/handler/fdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func ConfigPostFDB(params operations.PostConfigFdbParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
ret := loxinlp.AddFDBNoHook(params.Attr.MacAddress, params.Attr.Dev)
if ret != 0 {
return &ResultResponse{Result: "fail"}
Expand All @@ -33,7 +33,7 @@ func ConfigPostFDB(params operations.PostConfigFdbParams) middleware.Responder {
}

func ConfigDeleteFDB(params operations.DeleteConfigFdbMacAddressDevIfNameParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
ret := loxinlp.DelFDBNoHook(params.MacAddress, params.IfName)
if ret != 0 {
return &ResultResponse{Result: "fail"}
Expand All @@ -42,7 +42,7 @@ func ConfigDeleteFDB(params operations.DeleteConfigFdbMacAddressDevIfNameParams)
}

func ConfigGetFDB(params operations.GetConfigFdbAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
fdbs, _ := loxinlp.GetFDBNoHook()
var result []*models.FDBEntry
result = make([]*models.FDBEntry, 0)
Expand Down
6 changes: 3 additions & 3 deletions api/restapi/handler/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

func ConfigPostFW(params operations.PostConfigFirewallParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)
Opts := cmn.FwOptArg{}
Rules := cmn.FwRuleArg{}
FW := cmn.FwRuleMod{}
Expand Down Expand Up @@ -80,7 +80,7 @@ func ConfigPostFW(params operations.PostConfigFirewallParams) middleware.Respond
}

func ConfigDeleteFW(params operations.DeleteConfigFirewallParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)

Rules := cmn.FwRuleArg{}
FW := cmn.FwRuleMod{}
Expand Down Expand Up @@ -144,7 +144,7 @@ func ConfigDeleteFW(params operations.DeleteConfigFirewallParams) middleware.Res
}

func ConfigGetFW(params operations.GetConfigFirewallAllParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)
tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL)
res, _ := ApiHooks.NetFwRuleGet()
var result []*models.FirewallEntry
result = make([]*models.FirewallEntry, 0)
Expand Down
Loading

0 comments on commit a1f2174

Please sign in to comment.