You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by we...@apache.org on 2020/07/27 08:20:25 UTC
[incubator-apisix] branch master updated: change: the timeout of
`healthcheck` should be number type. (#1892)
This is an automated email from the ASF dual-hosted git repository.
wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 4015071 change: the timeout of `healthcheck` should be number type. (#1892)
4015071 is described below
commit 4015071e30e9613099f110a08547b8a1613109d9
Author: YuanSheng Wang <me...@gmail.com>
AuthorDate: Mon Jul 27 16:19:01 2020 +0800
change: the timeout of `healthcheck` should be number type. (#1892)
---
apisix/schema_def.lua | 2 +-
doc/health-check.md | 3 +++
doc/zh-cn/health-check.md | 3 +++
t/admin/health-check.t | 42 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index d580be6..8133953 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -75,7 +75,7 @@ local health_checker = {
enum = {"http", "https", "tcp"},
default = "http"
},
- timeout = {type = "integer", default = 1},
+ timeout = {type = "number", default = 1},
concurrency = {type = "integer", default = 10},
host = host_def,
http_path = {type = "string", default = "/"},
diff --git a/doc/health-check.md b/doc/health-check.md
index 1b78831..81e35a5 100644
--- a/doc/health-check.md
+++ b/doc/health-check.md
@@ -45,6 +45,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
"retries": 2,
"checks": {
"active": {
+ "timeout": 5,
"http_path": "/status",
"host": "foo.com",
"healthy": {
@@ -78,6 +79,8 @@ contains: `active` or `passive`.
* `active`: To enable active health checks, you need to specify the configuration items under `checks.active` in the Upstream object configuration.
+ * `active.timeout`: Socket timeout for active checks (in seconds), support decimals. For example `1.01` means `1010` milliseconds, `2` means `2000` milliseconds.
+
* `active.http_path`: The HTTP GET request path used to detect if the upstream is healthy.
* `active.host`: The HTTP request host used to detect if the upstream is healthy.
diff --git a/doc/zh-cn/health-check.md b/doc/zh-cn/health-check.md
index 6be4691..c77ae6a 100644
--- a/doc/zh-cn/health-check.md
+++ b/doc/zh-cn/health-check.md
@@ -46,6 +46,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
"retries": 2,
"checks": {
"active": {
+ "timeout": 5,
"http_path": "/status",
"host": "foo.com",
"healthy": {
@@ -78,6 +79,8 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
* `active`: 要启动探活健康检查,需要在upstream配置中的 `checks.active` 添加如下配置项。
+ * `active.timeout`: 主动健康检查 socket 超时时间(秒为单位),支持小数点。比如 `1.01` 代表 `1010` 毫秒,`2` 代表 `2000` 毫秒。
+
* `active.http_path`: 用于发现upstream节点健康可用的HTTP GET请求路径。
* `active.host`: 用于发现upstream节点健康可用的HTTP请求主机名。
diff --git a/t/admin/health-check.t b/t/admin/health-check.t
index 8680768..698d69d 100644
--- a/t/admin/health-check.t
+++ b/t/admin/health-check.t
@@ -476,3 +476,45 @@ GET /t
{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: object matches none of the requireds: [\"active\"] or [\"active\",\"passive\"]"}
--- no_error_log
[error]
+
+
+
+=== TEST 13: number type timeout
+--- config
+ location /t {
+ content_by_lua_block {
+ local t = require("lib.test_admin").test
+
+ req_data.upstream.checks = json.decode([[{
+ "active": {
+ "http_path": "/status",
+ "host": "foo.com",
+ "timeout": 1.01,
+ "healthy": {
+ "interval": 2,
+ "successes": 1
+ },
+ "unhealthy": {
+ "interval": 1,
+ "http_failures": 2
+ }
+ }
+ }]])
+ exp_data.node.value.upstream.checks = req_data.upstream.checks
+
+ local code, body = t('/apisix/admin/routes/1',
+ ngx.HTTP_PUT,
+ req_data,
+ exp_data
+ )
+
+ ngx.status = code
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]