From d5d4299e43601036ea14a91ecc0d22a129dae64e Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sat, 24 Feb 2024 00:08:32 +0900 Subject: [PATCH] gh-546: probetimeo/retry count configuration on LB creation --- api/models/loadbalance_entry.go | 6 ++++++ api/restapi/embedded_spec.go | 30 +++++++++++++++++++++++++++++ api/restapi/handler/loadbalancer.go | 2 ++ api/swagger.yml | 8 ++++++++ common/common.go | 4 ++++ loxinet/rules.go | 28 ++++++++++++++++++++------- 6 files changed, 71 insertions(+), 7 deletions(-) diff --git a/api/models/loadbalance_entry.go b/api/models/loadbalance_entry.go index 778477599..9aae75776 100644 --- a/api/models/loadbalance_entry.go +++ b/api/models/loadbalance_entry.go @@ -336,6 +336,12 @@ type LoadbalanceEntryServiceArguments struct { // port number for the access Port int64 `json:"port,omitempty"` + // value for probe retries + ProbeRetries int32 `json:"probeRetries,omitempty"` + + // value for probe timer (in seconds) + ProbeTimeout uint32 `json:"probeTimeout,omitempty"` + // probe port if probetype is tcp/udp/sctp Probeport uint16 `json:"probeport,omitempty"` diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 1d7053ead..353385a2a 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -4011,6 +4011,16 @@ func init() { "description": "port number for the access", "type": "integer" }, + "probeRetries": { + "description": "value for probe retries", + "type": "integer", + "format": "int32" + }, + "probeTimeout": { + "description": "value for probe timer (in seconds)", + "type": "integer", + "format": "uint32" + }, "probeport": { "description": "probe port if probetype is tcp/udp/sctp", "type": "integer", @@ -8627,6 +8637,16 @@ func init() { "description": "port number for the access", "type": "integer" }, + "probeRetries": { + "description": "value for probe retries", + "type": "integer", + "format": "int32" + }, + "probeTimeout": { + "description": "value for probe timer (in seconds)", + "type": "integer", + "format": "uint32" + }, "probeport": { "description": "probe port if probetype is tcp/udp/sctp", "type": "integer", @@ -8730,6 +8750,16 @@ func init() { "description": "port number for the access", "type": "integer" }, + "probeRetries": { + "description": "value for probe retries", + "type": "integer", + "format": "int32" + }, + "probeTimeout": { + "description": "value for probe timer (in seconds)", + "type": "integer", + "format": "uint32" + }, "probeport": { "description": "probe port if probetype is tcp/udp/sctp", "type": "integer", diff --git a/api/restapi/handler/loadbalancer.go b/api/restapi/handler/loadbalancer.go index e5d6b9725..6ce1ede45 100644 --- a/api/restapi/handler/loadbalancer.go +++ b/api/restapi/handler/loadbalancer.go @@ -42,6 +42,8 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd lbRules.Serv.ProbePort = params.Attr.ServiceArguments.Probeport lbRules.Serv.ProbeReq = params.Attr.ServiceArguments.Probereq lbRules.Serv.ProbeResp = params.Attr.ServiceArguments.Proberesp + lbRules.Serv.ProbeTimeout = params.Attr.ServiceArguments.ProbeTimeout + lbRules.Serv.ProbeRetries = int(params.Attr.ServiceArguments.ProbeRetries) lbRules.Serv.Name = params.Attr.ServiceArguments.Name if lbRules.Serv.Proto == "sctp" { diff --git a/api/swagger.yml b/api/swagger.yml index 74f870ebe..c7b266d38 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2445,6 +2445,14 @@ definitions: type: integer format: int32 description: value for inactivity timeout (in seconds) + probeTimeout: + type: integer + format: uint32 + description: value for probe timer (in seconds) + probeRetries: + type: integer + format: int32 + description: value for probe retries name: type: string description: service name diff --git a/common/common.go b/common/common.go index 53534a2ab..de669f6a7 100644 --- a/common/common.go +++ b/common/common.go @@ -517,6 +517,10 @@ type LbServiceArg struct { ProbeReq string `json:"probereq"` // ProbeResp - Response string for liveness check ProbeResp string `json:"proberesp"` + // ProbeTimeout - Probe Timeout + ProbeTimeout uint32 `json:"probeTimeout"` + // ProbeRetries - Probe Retries + ProbeRetries int `json:"probeRetries"` // Name - Service name Name string `json:"name"` } diff --git a/loxinet/rules.go b/loxinet/rules.go index 7c23e4b26..b4dba198d 100644 --- a/loxinet/rules.go +++ b/loxinet/rules.go @@ -253,11 +253,13 @@ type ruleStat struct { } type ruleProbe struct { - actChk bool - prbType string - prbPort uint16 - prbReq string - prbResp string + actChk bool + prbType string + prbPort uint16 + prbReq string + prbResp string + prbTimeo uint32 + prbRetries int } type ruleEnt struct { @@ -820,8 +822,16 @@ func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleNatEp, doAddOp bool, li var hopts epHostOpts pType := "" pPort := uint16(0) - hopts.inActTryThr = DflLbaInactiveTries - hopts.probeDuration = DflHostProbeTimeout + if r.hChk.prbRetries == 0 { + hopts.inActTryThr = DflLbaInactiveTries + } else { + hopts.inActTryThr = r.hChk.prbRetries + } + if r.hChk.prbTimeo == 0 { + hopts.probeDuration = DflHostProbeTimeout + } else { + hopts.probeDuration = r.hChk.prbTimeo + } for _, nep := range endpoints { if r.tuples.l4Prot.val == 6 { pType = HostProbeConnectTCP @@ -1373,6 +1383,8 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, eRule.hChk.prbPort = serv.ProbePort eRule.hChk.prbReq = serv.ProbeReq eRule.hChk.prbResp = serv.ProbeResp + eRule.hChk.prbRetries = serv.ProbeRetries + eRule.hChk.prbTimeo = serv.ProbeTimeout eRule.act.action.(*ruleNatActs).sel = natActs.sel eRule.act.action.(*ruleNatActs).endPoints = eEps eRule.act.action.(*ruleNatActs).mode = natActs.mode @@ -1408,6 +1420,8 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, r.hChk.prbPort = serv.ProbePort r.hChk.prbReq = serv.ProbeReq r.hChk.prbResp = serv.ProbeResp + r.hChk.prbRetries = serv.ProbeRetries + r.hChk.prbTimeo = serv.ProbeTimeout r.hChk.actChk = serv.Monitor r.act.action = &natActs r.ruleNum, err = R.tables[RtLB].Mark.GetCounter()