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

PR - Updated default liveness check policy #316

Merged
merged 4 commits into from
Jun 13, 2023
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
2 changes: 2 additions & 0 deletions loxinet/loxinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type loxiNetH struct {
wg sync.WaitGroup
bgp *GoBgpH
sumDis bool
pProbe bool
has *CIStateH
logger *tk.Logger
ready bool
Expand Down Expand Up @@ -181,6 +182,7 @@ func loxiNetInit() {

mh.self = opts.Opts.ClusterSelf
mh.sumDis = opts.Opts.CSumDisable
mh.pProbe = opts.Opts.PassiveEPProbe
mh.sigCh = make(chan os.Signal, 5)
signal.Notify(mh.sigCh, os.Interrupt, syscall.SIGCHLD)
signal.Notify(mh.sigCh, os.Interrupt, syscall.SIGHUP)
Expand Down
45 changes: 37 additions & 8 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ type epHostOpts struct {
probeDuration uint32
currProbeDuration uint32
probePort uint16
probeActivated bool
}

type epHost struct {
Expand Down Expand Up @@ -770,7 +771,7 @@ func validateXlateEPWeights(servEndPoints []cmn.LbEndPointArg) (int, error) {
return 0, nil
}

func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleNatEp, doAddOp bool) {
func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleNatEp, doAddOp bool, liveCheckEn bool) {
var hopts epHostOpts
hopts.inActTryThr = DflLbaInactiveTries
hopts.probeDuration = DflHostProbeTimeout
Expand All @@ -790,6 +791,10 @@ func (R *RuleH) modNatEpHost(r *ruleEnt, endpoints []ruleNatEp, doAddOp bool) {
hopts.probeType = HostProbePing
}

if mh.pProbe == true || liveCheckEn {
hopts.probeActivated = true
}

epKey := makeEPKey(nep.xIP.String(), hopts.probeType, hopts.probePort)

if doAddOp {
Expand Down Expand Up @@ -977,6 +982,8 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIpArg,
return RuleArgsErr, errors.New("secondaryIP-args len error")
}

activateProbe := false

for _, k := range servSecIPs {
pNetAddr := net.ParseIP(k.SecIP)
if pNetAddr == nil {
Expand All @@ -998,6 +1005,10 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIpArg,
natActs.sel = serv.Sel
natActs.mode = cmn.LBMode(serv.Mode)

if natActs.mode == cmn.LBModeOneArm || serv.Monitor {
activateProbe = true
}

for _, k := range servEndPoints {
pNetAddr := net.ParseIP(k.EpIP)
if pNetAddr == nil {
Expand Down Expand Up @@ -1084,7 +1095,7 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIpArg,
eRule.act.action.(*ruleNatActs).endPoints = eEps
eRule.act.action.(*ruleNatActs).mode = natActs.mode

R.modNatEpHost(eRule, eEps, true)
R.modNatEpHost(eRule, eEps, true, activateProbe)

eRule.sT = time.Now()
eRule.iTo = serv.InactiveTimeout
Expand Down Expand Up @@ -1118,7 +1129,7 @@ func (R *RuleH) AddNatLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIpArg,
r.BGP = serv.Bgp
r.CI = cmn.CIDefault

R.modNatEpHost(r, natActs.endPoints, true)
R.modNatEpHost(r, natActs.endPoints, true, activateProbe)

tk.LogIt(tk.LogDebug, "nat lb-rule added - %d:%s-%s\n", r.ruleNum, r.tuples.String(), r.act.String())

Expand Down Expand Up @@ -1174,7 +1185,11 @@ func (R *RuleH) DeleteNatLbRule(serv cmn.LbServiceArg) (int, error) {
defer R.Tables[RtLB].Mark.PutCounter(rule.ruleNum)

eEps := rule.act.action.(*ruleNatActs).endPoints
R.modNatEpHost(rule, eEps, false)
activatedProbe := false
if rule.act.action.(*ruleNatActs).mode == cmn.LBModeOneArm || rule.ActChk {
activatedProbe = true
}
R.modNatEpHost(rule, eEps, false, activatedProbe)

delete(R.Tables[RtLB].eMap, rt.ruleKey())
if rule.ruleNum < RtMaximumLbs {
Expand Down Expand Up @@ -1408,9 +1423,13 @@ func (R *RuleH) GetEpHosts() ([]cmn.EndPointMod, error) {
// Make end-point
ret.HostName = data.hostName
ret.Name = data.epKey
ret.InActTries = data.opts.inActTryThr
ret.ProbeType = data.opts.probeType
ret.ProbeDuration = data.opts.probeDuration
if !data.opts.probeActivated {
ret.ProbeType = HostProbeNone
} else {
ret.ProbeType = data.opts.probeType
ret.ProbeDuration = data.opts.probeDuration
ret.InActTries = data.opts.inActTryThr
}
ret.ProbeReq = data.opts.probeReq
ret.ProbeResp = data.opts.probeResp
ret.ProbePort = data.opts.probePort
Expand Down Expand Up @@ -1483,6 +1502,10 @@ func makeEPKey(hostName string, probeType string, probePort uint16) string {
func (R *RuleH) AddEPHost(apiCall bool, hostName string, name string, args epHostOpts) (int, error) {
var epKey string

if apiCall && args.probeType != HostProbeNone {
args.probeActivated = true
}

R.epMx.Lock()
defer R.epMx.Unlock()

Expand Down Expand Up @@ -1624,6 +1647,12 @@ func (R *RuleH) epCheckNow(ep *epHost) {
sName = fmt.Sprintf("[%s]:%d", ep.hostName, ep.opts.probePort)
}

if !ep.opts.probeActivated {
ep.inactive = false
ep.inActTries = 0
return
}

if ep.opts.probeType == HostProbeConnectTcp ||
ep.opts.probeType == HostProbeConnectUdp ||
ep.opts.probeType == HostProbeConnectSctp {
Expand Down Expand Up @@ -1739,7 +1768,7 @@ func epTicker(R *RuleH, helper int) {
if idx > 0 {
idx = 0
// We restart the sweep from beginning while taking a short break
// Due to how goLang range, works we would be sweeping eps mostly randomly
// Due to how goLang range works, we would be sweeping eps mostly randomly
R.epMx.Unlock()
break
}
Expand Down
1 change: 1 addition & 0 deletions options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ var Opts struct {
CPUProfile string `long:"cpuprofile" description:"Enable cpu profiling and specify file to use" default:"none" env:"CPUPROF"`
NoPrometheus bool `short:"p" long:"nopro" description:" Do not run prometheus thread"`
CSumDisable bool `long:"disable-csum" description:"Disable checksum update(experimental)"`
PassiveEPProbe bool `long:"passive-probe" description:"Enable passive liveness probes(experimental)"`
}