You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2021/06/18 06:54:38 UTC

[apisix] branch master updated: docs: clarify why we require active health check (#4436)

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 1cf9075  docs: clarify why we require active health check (#4436)
1cf9075 is described below

commit 1cf90757506ccbfb97afb9e12f54a71e83152c68
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Fri Jun 18 14:54:26 2021 +0800

    docs: clarify why we require active health check (#4436)
---
 docs/en/latest/health-check.md |  1 +
 docs/zh/latest/health-check.md |  3 ++-
 t/node/healthcheck-passive.t   | 49 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/docs/en/latest/health-check.md b/docs/en/latest/health-check.md
index 7c13848..ab9bbff 100644
--- a/docs/en/latest/health-check.md
+++ b/docs/en/latest/health-check.md
@@ -33,6 +33,7 @@ There won't be any health check if an upstream is configured but isn't in used.
 * If there is no healthy node can be chosen, we will continue to access the upstream.
 * We won't start the health check when the upstream only has one node, as we will access
 it whether this unique node is healthy or not.
+* Active health check is required so that the unhealthy node can recover.
 
 The following is an example of health check:
 
diff --git a/docs/zh/latest/health-check.md b/docs/zh/latest/health-check.md
index 9eb535c..a75f995 100644
--- a/docs/zh/latest/health-check.md
+++ b/docs/zh/latest/health-check.md
@@ -32,6 +32,7 @@ APISIX 的健康检查使用[lua-resty-healthcheck](https://github.com/Kong/lua-
 * 如果没有健康的节点,那么请求会继续发送给上游。
 * 如果 upstream 中只有一个节点,就不会有健康检查。
 因为该唯一节点无论是否健康,请求都会发送给上游,
+* 主动健康检查是必须的,这样不健康的节点才会恢复。
 
 下面是一个检查检查的例子:
 
@@ -87,7 +88,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
 
 监控检查的配置内容在`checks`中,`checks`包含两个类型:`active` 和 `passive`,详情如下
 
-* `active`: 要启动探活健康检查,需要在 upstream 配置中的 `checks.active` 添加如下配置项。
+* `active`: 要启动主动健康检查,需要在 upstream 配置中的 `checks.active` 添加如下配置项。
 
   * `active.timeout`: 主动健康检查 socket 超时时间(秒为单位),支持小数点。比如 `1.01` 代表 `1010` 毫秒,`2` 代表 `2000` 毫秒。
 
diff --git a/t/node/healthcheck-passive.t b/t/node/healthcheck-passive.t
index c554224..dd34c17 100644
--- a/t/node/healthcheck-passive.t
+++ b/t/node/healthcheck-passive.t
@@ -27,7 +27,7 @@ run_tests();
 
 __DATA__
 
-=== TEST 1: set route(only passive)
+=== TEST 1: set route(passive)
 --- config
     location /t {
         content_by_lua_block {
@@ -118,3 +118,50 @@ GET /t
 {"200":5,"502":1}
 --- error_log
 (upstream#/apisix/routes/1) unhealthy HTTP increment (1/1)
+
+
+
+=== TEST 3: set route(only passive)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/server_port",
+                    "upstream": {
+                        "type": "roundrobin",
+                        "nodes": {
+                            "127.0.0.1:1980": 0,
+                            "127.0.0.1:1": 1
+                        },
+                        "retries": 0,
+                        "checks": {
+                            "passive": {
+                                "healthy": {
+                                    "http_statuses": [200, 201],
+                                    "successes": 3
+                                },
+                                "unhealthy": {
+                                    "http_statuses": [502],
+                                    "http_failures": 1,
+                                    "tcp_failures": 1
+                                }
+                            }
+                        }
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.print(body)
+        }
+    }
+--- request
+GET /t
+--- error_code: 400
+--- response_body
+{"error_msg":"invalid configuration: property \"upstream\" validation failed: property \"checks\" validation failed: object matches none of the requireds: [\"active\"] or [\"active\",\"passive\"]"}