apisix icon indicating copy to clipboard operation
apisix copied to clipboard

request help: If the fusing interval of apisix depends on the setttings of upstream.checks.active.healthy.interval

Open OnlyPiglet opened this issue 6 years ago • 7 comments

Issue description

If the fusing interval of apisix depends on the setttings of upstream.checks.active.healthy.interval after I set the retries 0 forcelly , the checker won't report after a failed 502 request? is this right?

Thanks for helping.

OnlyPiglet avatar Nov 03 '20 11:11 OnlyPiglet

I am confused. The retries field in the upstream is not part of the checks. It only affects the proxy request, doesn't impact the health check.

spacewander avatar Nov 04 '20 01:11 spacewander

Could you give more detail of the configuration about your doubt?

idbeta avatar Nov 04 '20 05:11 idbeta

@idbeta @spacewander this is some part of the function pick_server in the balancer.lua

1    ctx.balancer_try_count = (ctx.balancer_try_count or 0) + 1
2   if checker and ctx.balancer_try_count > 1 then
3        local state, code = get_last_failure()
4        local host = up_conf.checks and up_conf.checks.active and up_conf.checks.active.host
5        local port = up_conf.checks and up_conf.checks.active and up_conf.checks.active.port
6       if state == "failed" then
7            if code == 504 then
8                checker:report_timeout(ctx.balancer_ip, port or ctx.balancer_port, host)
9            else
10                checker:report_tcp_failure(ctx.balancer_ip, port or ctx.balancer_port, host)
11           end
12        else
13            checker:report_http_status(ctx.balancer_ip, port or ctx.balancer_port, host, code)
14       end
15    end

16    if ctx.balancer_try_count == 1 then
17       local retries = up_conf.retries
18        if not retries or retries < 0 then
19            retries = #up_conf.nodes - 1
20        end

21        if retries > 0 then
22            set_more_tries(retries)
23        end
24    end

I mean if I set_more_tries as zero forecelly at the line 19, then the request won't enter the branch if checker and ctx.balancer_try_count > 1 then so the bad request won't be report at noce. right? it's just beacuse I changed the balancer.lua

OnlyPiglet avatar Nov 04 '20 05:11 OnlyPiglet

so the bad request won't be report

The bad request will be reported elsewhere: https://github.com/apache/apisix/blob/61cd91440bb8826d616e7a056428fe42ea64ebd0/apisix/init.lua#L649

spacewander avatar Nov 04 '20 06:11 spacewander

@spacewander thanks a lot I see,I use active checker,so it didn't work.

OnlyPiglet avatar Nov 04 '20 08:11 OnlyPiglet

If thing doesn't work for you, please provide a minimal reproduce example, including the configuration, how you test it and the possible error log.

spacewander avatar Nov 04 '20 08:11 spacewander

Consider solved.

spacewander avatar Nov 18 '20 06:11 spacewander