From be57f53b80a7475088feee90f306874e2da1d520 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Sat, 28 Sep 2024 23:11:57 +0900 Subject: [PATCH] graceful handling when max endpoint limit is reached --- pkg/loxinet/rules.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/loxinet/rules.go b/pkg/loxinet/rules.go index a2b1862fe..f3aa2e31b 100644 --- a/pkg/loxinet/rules.go +++ b/pkg/loxinet/rules.go @@ -1442,7 +1442,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, se return RuleArgsErr, errors.New("malformed-service-pport error") } - // Currently support a maximum of MAX_NAT_EPS + // Currently support a maximum of MaxLBEndPoints if len(servEndPoints) <= 0 || len(servEndPoints) > MaxLBEndPoints { return RuleEpCountErr, errors.New("endpoints-range error") } @@ -1573,8 +1573,13 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, se return RuleExistsErr, errors.New("lbrule-exist error: cant modify fullproxy rule mode") } - if eRule.act.action.(*ruleLBActs).mode == cmn.LBModeFullProxy { + if eRule.act.action.(*ruleLBActs).mode == cmn.LBModeFullProxy || len(retEps) > MaxLBEndPoints { eRule.DP(DpRemove) + if len(retEps) > MaxLBEndPoints { + tk.LogIt(tk.LogInfo, "lb-rule %s-%v-%s reset all end-points (too many)\n", serv.ServIP, serv.ServPort, serv.Proto) + delEps = eRule.act.action.(*ruleLBActs).endPoints + retEps = lBActs.endPoints + } } // Update the rule