Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-48 Add support for url-path in LB args #732

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/models/loadbalance_entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/restapi/configure_loxilb_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler {

// Load balancer add and delete and get
api.PostConfigLoadbalancerHandler = operations.PostConfigLoadbalancerHandlerFunc(handler.ConfigPostLoadbalancer)
api.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancer)
api.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancer)
api.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandler = operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoHandlerFunc(handler.ConfigDeleteLoadbalancerWithoutPath)
api.GetConfigLoadbalancerAllHandler = operations.GetConfigLoadbalancerAllHandlerFunc(handler.ConfigGetLoadbalancer)
api.DeleteConfigLoadbalancerAllHandler = operations.DeleteConfigLoadbalancerAllHandlerFunc(handler.ConfigDeleteAllLoadbalancer)
api.DeleteConfigLoadbalancerNameLbNameHandler = operations.DeleteConfigLoadbalancerNameLbNameHandlerFunc(handler.ConfigDeleteLoadbalancerByName)
Expand Down
202 changes: 202 additions & 0 deletions api/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion api/restapi/handler/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd
lbRules.Serv.ProbeRetries = int(params.Attr.ServiceArguments.ProbeRetries)
lbRules.Serv.Name = params.Attr.ServiceArguments.Name
lbRules.Serv.Oper = cmn.LBOp(params.Attr.ServiceArguments.Oper)
lbRules.Serv.Path = params.Attr.ServiceArguments.Path

if lbRules.Serv.Proto == "sctp" {
for _, data := range params.Attr.SecondaryIPs {
Expand Down Expand Up @@ -77,14 +78,19 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd
return &ResultResponse{Result: "Success"}
}

func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerUrlpathUrlpathExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var lbServ cmn.LbServiceArg
var lbRules cmn.LbRuleMod
lbServ.ServIP = params.IPAddress
lbServ.ServPort = uint16(params.Port)
lbServ.Proto = params.Proto
if params.Urlpath == "any" {
lbServ.Path = ""
} else {
lbServ.Path = params.Urlpath
}
if params.Block != nil {
lbServ.BlockNum = uint16(*params.Block)
}
Expand All @@ -102,6 +108,32 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerExternal
return &ResultResponse{Result: "Success"}
}

func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder {
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)

var lbServ cmn.LbServiceArg
var lbRules cmn.LbRuleMod
lbServ.ServIP = params.IPAddress
lbServ.ServPort = uint16(params.Port)
lbServ.Proto = params.Proto
lbServ.Path = ""
if params.Block != nil {
lbServ.BlockNum = uint16(*params.Block)
}
if params.Bgp != nil {
lbServ.Bgp = *params.Bgp
}

lbRules.Serv = lbServ
tk.LogIt(tk.LogDebug, "[API] lbRules (w/o Path): %v\n", lbRules)
_, err := ApiHooks.NetLbRuleDel(&lbRules)
if err != nil {
tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err)
return &ResultResponse{Result: err.Error()}
}
return &ResultResponse{Result: "Success"}
}

func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) middleware.Responder {
// Get LB rules
tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL)
Expand Down Expand Up @@ -133,6 +165,7 @@ func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) mid
tmpSvc.Probeport = lb.Serv.ProbePort
tmpSvc.Name = lb.Serv.Name
tmpSvc.Snat = lb.Serv.Snat
tmpSvc.Path = lb.Serv.Path

tmpLB.ServiceArguments = &tmpSvc

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading