kobolog / gorb

IPVS on steroids – REST API, heartbeats, service discovery and more
GNU Lesser General Public License v3.0
809 stars 83 forks source link

Doesn't update weight with tcp pulse #47

Closed username1366 closed 6 years ago

username1366 commented 6 years ago
level=warning msg="backend [http/192.168.1.226] status: Up"
level=info msg="updating backend [http/192.168.1.226] with weight: 0"

Service configuration:

curl -v -XPUT http://127.0.0.1:4672/service/ads-http -d @- << EOF
{
    "host": "10.128.1.222",
    "port": 80,
    "protocol": "tcp",
    "method": "rr",
    "persistent": false,
    "flags": "sh-fallback"
}
EOF

Backend configuration:

curl -v -XPUT http://127.0.0.1:4672/service/http/backend1 -d @- << EOF
{
    "host": "192.168.1.226",
    "port": 80,
    "method": "nat",
    "pulse": {
        "type": "tcp",
        "interval": "20s"
    },
    "weight": 1
}

ipvsadm -S -n:

-A -t 10.128.1.222:80 -s rr -b flag-1
-a -t 10.128.1.222:80 -r 192.168.1.226:80 -m -w 0
-a -t 10.128.1.222:80 -r 192.168.1.228:80 -m -w 0
-a -t 10.128.1.222:80 -r 192.168.1.229:80 -m -w 0
-a -t 10.128.1.222:80 -r 192.168.1.230:80 -m -w 0
-a -t 10.128.1.222:80 -r 192.168.1.231:80 -m -w 0
kobolog commented 6 years ago

I believe this is due to https://github.com/kobolog/gorb/blob/master/core/runtime.go#L64 where it calculates the relative health of a backend. Since your initial weight is 1, any degradation or even one missed ping will make it less than 1 which will be truncated to 0 on int-conversion. Try setting the initial weight to like a 100?

kobolog commented 6 years ago

Hopefully it helped, closing for now.