Skip to content

Commit

Permalink
Merge pull request #814 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
PR: loxilb-io/kube-loxilb#184 Clear inactive endpoints on LB endpoint update
  • Loading branch information
UltraInstinct14 authored Sep 27, 2024
2 parents a3cdc82 + a1232a6 commit a462122
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ type ruleLBEp struct {
inActiveEP bool
noService bool
chkVal bool
epCreated bool
stat ruleStat
foldEndPoints []ruleLBEp
foldRuleKey string
Expand Down Expand Up @@ -877,7 +878,8 @@ func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleLBEp, doAddOp bool, liv
} else {
hopts.probeDuration = r.hChk.prbTimeo
}
for _, nep := range endpoints {
for idx := range endpoints {
nep := &endpoints[idx]
if r.tuples.l4Prot.val == 6 {
pType = HostProbeConnectTCP
pPort = nep.xPort
Expand Down Expand Up @@ -912,11 +914,25 @@ func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleLBEp, doAddOp bool, liv
epKey := makeEPKey(nep.xIP.String(), pType, pPort)

if doAddOp {
if !nep.inActiveEP {
R.AddEPHost(false, nep.xIP.String(), epKey, hopts)
if !nep.inActiveEP && !nep.epCreated {
_, err := R.AddEPHost(false, nep.xIP.String(), epKey, hopts)
if err == nil {
nep.epCreated = true
} else {
tk.LogIt(tk.LogError, "add ep-host error %v : %s\n", epKey, err)
}
} else if nep.inActiveEP {
nep.epCreated = false
}
} else {
R.DeleteEPHost(false, epKey, nep.xIP.String(), hopts.probeType, hopts.probePort)
if nep.epCreated {
_, err := R.DeleteEPHost(false, epKey, nep.xIP.String(), hopts.probeType, hopts.probePort)
if err == nil {
nep.epCreated = false
} else {
tk.LogIt(tk.LogError, "delete ep-host error %v : %s\n", epKey, err)
}
}
}
}
}
Expand Down Expand Up @@ -1506,7 +1522,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, se
if lBActs.mode == cmn.LBModeDSR && k.EpPort != serv.ServPort {
return RuleUnknownServiceErr, errors.New("malformed-service dsr-port error")
}
ep := ruleLBEp{pNetAddr, xNetAddr, k.EpPort, k.Weight, 0, false, false, false, ruleStat{0, 0}, nil, ""}
ep := ruleLBEp{pNetAddr, xNetAddr, k.EpPort, k.Weight, 0, false, false, false, false, ruleStat{0, 0}, nil, ""}
lBActs.endPoints = append(lBActs.endPoints, ep)
}

Expand Down

0 comments on commit a462122

Please sign in to comment.