This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 1ab12ac chore: make t/node/upstream-retries.t stable (#4599)
1ab12ac is described below
commit 1ab12ac2b0173f511e2427e3896df0154fdd34fd
Author: 罗泽轩 <[email protected]>
AuthorDate: Thu Jul 15 11:48:44 2021 +0800
chore: make t/node/upstream-retries.t stable (#4599)
Signed-off-by: spacewander <[email protected]>
---
apisix/balancer.lua | 4 +++-
apisix/schema_def.lua | 2 +-
docs/en/latest/admin-api.md | 2 +-
docs/zh/latest/admin-api.md | 2 +-
t/node/upstream-retries.t | 8 ++++----
5 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index e6af3a3..fbcae25 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -299,7 +299,9 @@ function _M.run(route, ctx, plugin_funcs)
else
if ctx.proxy_retry_deadline and ctx.proxy_retry_deadline < ngx_now()
then
- core.log.error("proxy retry timeout, retry count: ",
ctx.balancer_try_count or 0)
+ -- retry count is (try count - 1)
+ core.log.error("proxy retry timeout, retry count: ",
(ctx.balancer_try_count or 1) - 1,
+ ", deadline: ", ctx.proxy_retry_deadline, " now: ",
ngx_now())
return core.response.exit(502)
end
-- retry
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index 80f05fc..b6b158a 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -354,7 +354,7 @@ local upstream_schema = {
minimum = 0,
},
retry_timeout = {
- type = "integer",
+ type = "number",
minimum = 0,
},
timeout = timeout_def,
diff --git a/docs/en/latest/admin-api.md b/docs/en/latest/admin-api.md
index 6815876..8cfeea2 100644
--- a/docs/en/latest/admin-api.md
+++ b/docs/en/latest/admin-api.md
@@ -546,7 +546,7 @@ In addition to the basic complex equalization algorithm
selection, APISIX's Upst
|key |optional|This option is only valid if the `type` is `chash`.
Find the corresponding node `id` according to `hash_on` and `key`. When
`hash_on` is set as `vars`, `key` is the required parameter, for now, it
support nginx built-in variables like `uri, server_name, server_addr,
request_uri, remote_port, remote_addr, query_string, host, hostname, arg_***`,
`arg_***` is arguments in the request line, [Nginx variables
list](http://nginx.org/en/docs/varindex.html). When `hash_ [...]
|checks |optional|Configure the parameters of the health check. For
details, refer to [health-check](health-check.md).|
|retries |optional|Pass the request to the next upstream using the
underlying Nginx retry mechanism, the retry mechanism is enabled by default and
set the number of retries according to the number of available backend nodes.
If `retries` option is explicitly set, it will override the default value. `0`
means disable retry mechanism.|
-|retry_timeout |optional|Limits the amount of time that retries can be
continued, and do not continue retries if the previous request and retry
requests have taken too long. `0` means disable retry timeout mechanism.|
+|retry_timeout |optional|Configure a number to limit the amount of seconds
that retries can be continued, and do not continue retries if the previous
request and retry requests have taken too long. `0` means disable retry timeout
mechanism.|
|timeout |optional| Set the timeout for connecting, sending and
receiving messages. |
|name |optional|Identifies upstream names|
|desc |optional|upstream usage scenarios, and more.|
diff --git a/docs/zh/latest/admin-api.md b/docs/zh/latest/admin-api.md
index 97a79a4..3b359cc 100644
--- a/docs/zh/latest/admin-api.md
+++ b/docs/zh/latest/admin-api.md
@@ -551,7 +551,7 @@ APISIX 的 Upstream 除了基本的负载均衡算法选择外,还支持对上
| key | 条件必需 | 匹配类型 | 该选项只有类型是
`chash` 才有效。根据 `key` 来查找对应的 node `id`,相同的 `key` 在同一个对象中,永远返回相同 id,目前支持的 Nginx
内置变量有 `uri, server_name, server_addr, request_uri, remote_port, remote_addr,
query_string, host, hostname, arg_***`,其中 `arg_***` 是来自 URL 的请求参数,[Nginx
变量列表](http://nginx.org/en/docs/varindex.html) |
|
| checks | 可选 | health_checker |
配置健康检查的参数,详细可参考[health-check](health-check.md)
| |
| retries | 可选 | 整型 | 使用底层的
Nginx 重试机制将请求传递给下一个上游,默认启用重试且次数为后端可用的 node 数量。如果指定了具体重试次数,它将覆盖默认值。`0`
代表不启用重试机制。
|
|
-| retry_timeout | 可选 | 整型 |
限制是否继续重试的时间,若之前的请求和重试请求花费太多时间就不再继续重试。`0` 代表不启用重试超时机制。
| |
+| retry_timeout | 可选 | number |
限制是否继续重试的时间,若之前的请求和重试请求花费太多时间就不再继续重试。`0` 代表不启用重试超时机制。
| |
| timeout | 可选 | 超时时间对象 |
设置连接、发送消息、接收消息的超时时间
| |
| hash_on | 可选 | 辅助 | `hash_on`
支持的类型有 `vars`(Nginx 内置变量),`header`(自定义 header),`cookie`,`consumer`,默认值为 `vars`
|
| name | 可选 | 辅助 |
标识上游服务名称、使用场景等。
| |
diff --git a/t/node/upstream-retries.t b/t/node/upstream-retries.t
index 89ff86c..e0cba34 100644
--- a/t/node/upstream-retries.t
+++ b/t/node/upstream-retries.t
@@ -285,7 +285,7 @@ proxy request to 127.0.0.1:1/
"127.0.0.1:1982": 100
},
"retries": 10,
- "retry_timeout": 2,
+ "retry_timeout": 0.15,
"type": "roundrobin"
},
"uri": "/mysleep"
@@ -299,7 +299,7 @@ proxy request to 127.0.0.1:1/
local http = require "resty.http"
local httpc = http.new()
local uri = "http://127.0.0.1:" .. ngx.var.server_port
- .. "/mysleep?abort=true&seconds=1"
+ .. "/mysleep?abort=true&seconds=0.1"
local res, err = httpc:request_uri(uri)
if not res then
ngx.say(err)
@@ -312,5 +312,5 @@ proxy request to 127.0.0.1:1/
--- request
GET /t
--- error_code: 502
---- error_log eval
-qr/proxy retry timeout, retry count: 2/
+--- error_log
+proxy retry timeout, retry count: 1