mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Merge pull request #426 in YUNIONIO/onecloud from ~ZHOUYOUSONG/onecloud:bugfix/yousong-minors-2.3 to release/2.3.0
* commit '255f5e242ab2f6eb58010d1fb42c7d2940312890': lbagent: make sonar happy
This commit is contained in:
@@ -41,24 +41,6 @@ func NewHaproxyHelper(opts *Options) (*HaproxyHelper, error) {
|
||||
return nil, fmt.Errorf("sysctl: %s", err)
|
||||
}
|
||||
}
|
||||
if false {
|
||||
// ipvs modules
|
||||
mods := []string{
|
||||
"ip_vs",
|
||||
"ip_vs_rr",
|
||||
"ip_vs_wrr",
|
||||
"ip_vs_lc",
|
||||
"ip_vs_wlc",
|
||||
"ip_vs_sh",
|
||||
}
|
||||
args := []string{"modprobe", ""}
|
||||
for _, mod := range mods {
|
||||
args[1] = mod
|
||||
if err := helper.runCmd(args); err != nil {
|
||||
return nil, fmt.Errorf("modprobe %s: %s", mod, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return helper, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -43,80 +43,6 @@ func (b *LoadbalancerCorpus) GenKeepalivedConfigs(dir string, opts *GenKeepalive
|
||||
return err
|
||||
}
|
||||
}
|
||||
if false {
|
||||
// write virtual_server
|
||||
for _, lb := range opts.LoadbalancersEnabled {
|
||||
for _, listener := range lb.listeners {
|
||||
if listener.Status != "enabled" {
|
||||
continue
|
||||
}
|
||||
if listener.BackendGroupId == "" {
|
||||
continue
|
||||
}
|
||||
if listener.ListenerType == "udp" {
|
||||
dataReals := []map[string]interface{}{}
|
||||
dataVirtual := map[string]interface{}{
|
||||
"virtual_ip": lb.Address,
|
||||
"virtual_port": listener.ListenerPort,
|
||||
}
|
||||
{
|
||||
// scheduler
|
||||
switch listener.Scheduler {
|
||||
case "rr", "wrr", "lc", "wlc":
|
||||
dataVirtual["scheduler"] = listener.Scheduler
|
||||
case "sch", "tch":
|
||||
log.Warningf("scheduler %s converted to sh", listener.Scheduler)
|
||||
dataVirtual["scheduler"] = "sh"
|
||||
default:
|
||||
log.Warningf("scheduler %s converted to sh", listener.Scheduler)
|
||||
dataVirtual["scheduler"] = "sh"
|
||||
}
|
||||
}
|
||||
udpCheckEnabled := false
|
||||
{
|
||||
if listener.HealthCheck == "on" && listener.HealthCheckType == "udp" && listener.HealthCheckReq != "" {
|
||||
udpCheckEnabled = true
|
||||
}
|
||||
}
|
||||
backendGroup := lb.backendGroups[listener.BackendGroupId]
|
||||
for _, backend := range backendGroup.backends {
|
||||
dataReal := map[string]interface{}{
|
||||
"real_ip": backend.Address,
|
||||
"real_port": backend.Port,
|
||||
"weight": backend.Weight,
|
||||
}
|
||||
if udpCheckEnabled {
|
||||
checkMiscArgs := []string{
|
||||
keepalivedMiscCheckPath,
|
||||
fmt.Sprintf("wait=%d", listener.HealthCheckTimeout),
|
||||
fmt.Sprintf("req=%s", listener.HealthCheckReq),
|
||||
fmt.Sprintf("exp=%s", listener.HealthCheckExp),
|
||||
fmt.Sprintf("host=%s", backend.Address),
|
||||
fmt.Sprintf("port=%d", backend.Port),
|
||||
}
|
||||
dataCheckMiscPath := agentutils.KeepalivedConfQuoteScriptArgs(checkMiscArgs)
|
||||
dataCheck := map[string]interface{}{
|
||||
"misc_path": dataCheckMiscPath,
|
||||
"misc_timeout": listener.HealthCheckTimeout,
|
||||
"interval": listener.HealthCheckInterval,
|
||||
"fall": listener.HealthCheckFall,
|
||||
"usergroup": "nobody",
|
||||
}
|
||||
dataReal["check"] = dataCheck
|
||||
}
|
||||
dataReals = append(dataReals, dataReal)
|
||||
}
|
||||
dataVirtual["real_servers"] = dataReals
|
||||
|
||||
fmt.Fprintf(buf, "\n\n")
|
||||
fmt.Fprintf(buf, "## listener %s(%s) backendGroup %s(%s)\n",
|
||||
listener.Name, listener.Id,
|
||||
backendGroup.Name, backendGroup.Id)
|
||||
keepalivedConfTmpl.ExecuteTemplate(buf, "keepalivedVirtualServerUDP", dataVirtual)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// write keepalived.conf
|
||||
d := buf.Bytes()
|
||||
|
||||
Reference in New Issue
Block a user