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 2022/08/17 09:29:02 UTC

[apisix] branch release/2.13 updated (597955993 -> 29541f5e2)

This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a change to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git


    from 597955993 backport: commits to release/2.13 (#7319)
     new 33bd7416d fix: distinguish different upstreams even they have the same addr (#7213)
     new bf605a21d ci: make sure the correct version of click is installed (#7589)
     new 1892d997e fix(upstream): http connection was put into https connection pool (#7466)
     new ec62dd265 fix:  auth plugin repeats the rewrite phase (#7531)
     new 3dfefe82b test(openwhisk): ensure the request sent to a wrong host (#7507)
     new 871aface6 fix: adjust the execution priority of request-id to fix opentelemetry has no request id (#7281)
     new 60ed87be9 fix(limit-count): conf with group and disable can't be configured (#7384)
     new d24b4c9bd fix: upgrade lua-resty-etcd to 1.8.2 (#7480)
     new bae4a9b5e chore: upgrade lua-resty-etcd to 1.8.3 (#7565)
     new aa17261a3 fix: remove the restriction of etcd prefix (#7675)
     new 7268fe7aa fix(http-logger): avoid empty Authorization header by default (#7444)
     new 29541f5e2 fix(k8s): cleanup variable before re list and watch (#7506)

The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .github/workflows/fuzzing-ci.yaml                |   2 +
 apisix/balancer.lua                              |   1 +
 apisix/cli/schema.lua                            |   1 -
 apisix/discovery/kubernetes/informer_factory.lua |   3 +
 apisix/plugin.lua                                |  19 ++++-
 apisix/plugins/http-logger.lua                   |   2 +-
 apisix/plugins/limit-count.lua                   |   6 +-
 apisix/plugins/request-id.lua                    |   2 +-
 apisix/upstream.lua                              |   7 +-
 conf/config-default.yaml                         |   2 +-
 docs/en/latest/plugins/http-logger.md            |  23 +++--
 docs/zh/latest/plugins/http-logger.md            |   2 +-
 rockspec/apisix-master-0.rockspec                |   2 +-
 t/admin/plugins.t                                |   2 +-
 t/cli/test_validate_config.sh                    |  13 ---
 t/debug/debug-mode.t                             |   2 +-
 t/node/consumer-plugin2.t                        |  65 ++++++++++++++
 t/node/upstream-keepalive-pool.t                 | 103 +++++++++++++++++++++++
 t/node/upstream.t                                |  70 +++++++++++++++
 t/plugin/http-logger2.t                          |  56 ++++++++++++
 t/plugin/limit-count2.t                          |  37 ++++++++
 t/plugin/openwhisk.t                             |   2 +-
 22 files changed, 381 insertions(+), 41 deletions(-)


[apisix] 03/12: fix(upstream): http connection was put into https connection pool (#7466)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 1892d997eff7ccbebe8e00ba930fa3db27997540
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Fri Jul 15 14:06:28 2022 +0800

    fix(upstream): http connection was put into https connection pool (#7466)
    
    This bug is introduced in https://github.com/apache/apisix/commit/3dddf41382e8916ce92d7e29c1e8e6d86b821304
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/balancer.lua              |   1 +
 t/node/upstream-keepalive-pool.t | 103 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)

diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index 5eb9d2777..d7935a661 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -289,6 +289,7 @@ do
             local size = keepalive_pool.size
             local requests = keepalive_pool.requests
 
+            core.table.clear(pool_opt)
             pool_opt.pool_size = size
 
             local scheme = up_conf.scheme
diff --git a/t/node/upstream-keepalive-pool.t b/t/node/upstream-keepalive-pool.t
index 084522b4e..26f9306d0 100644
--- a/t/node/upstream-keepalive-pool.t
+++ b/t/node/upstream-keepalive-pool.t
@@ -635,3 +635,106 @@ qr/lua balancer: keepalive create pool, .*/
 qr/^lua balancer: keepalive create pool, crc32: \S+, size: 8
 lua balancer: keepalive create pool, crc32: \S+, size: 4
 $/
+
+
+
+=== TEST 14: upstreams with SNI, then without SNI
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin")
+            local test = require("lib.test_admin").test
+            local json = require("toolkit.json")
+
+            local code, body = test('/apisix/admin/upstreams/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "scheme": "https",
+                    "type": "roundrobin",
+                    "nodes": {
+                        "127.0.0.1:1983": 1
+                    },
+                    "pass_host": "rewrite",
+                    "upstream_host": "a.com",
+                    "keepalive_pool": {
+                        "size": 4
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.print(body)
+                return
+            end
+
+            local data = {
+                scheme = "http",
+                type = "roundrobin",
+                nodes = {
+                    ["127.0.0.1:1980"] = 1,
+                },
+                pass_host = "rewrite",
+                upstream_host = "b.com",
+                keepalive_pool = {
+                    size = 8
+                }
+            }
+            local code, body = test('/apisix/admin/upstreams/2',
+                ngx.HTTP_PUT,
+                json.encode(data)
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.print(body)
+                return
+            end
+
+            for i = 1, 2 do
+                local code, body = test('/apisix/admin/routes/' .. i,
+                    ngx.HTTP_PUT,
+                    [[{
+                        "uri":"/hello/]] .. i .. [[",
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "uri": "/hello"
+                            }
+                        },
+                        "upstream_id": ]] .. i .. [[
+                    }]])
+                if code >= 300 then
+                    ngx.status = code
+                    ngx.print(body)
+                    return
+                end
+            end
+        }
+    }
+--- response_body
+
+
+
+=== TEST 15: hit
+--- config
+    location /t {
+        content_by_lua_block {
+            local http = require "resty.http"
+            local uri = "http://127.0.0.1:" .. ngx.var.server_port
+            for i = 0, 1 do
+                local idx = i % 2 + 1
+                local httpc = http.new()
+                local res, err = httpc:request_uri(uri .. "/hello/" .. idx)
+                local res, err = httpc:request_uri(uri)
+                if not res then
+                    ngx.say(err)
+                    return
+                end
+                ngx.print(res.body)
+            end
+        }
+    }
+--- grep_error_log eval
+qr/lua balancer: keepalive create pool, .*/
+--- grep_error_log_out eval
+qr/^lua balancer: keepalive create pool, crc32: \S+, size: 4
+lua balancer: keepalive create pool, crc32: \S+, size: 8
+$/


[apisix] 07/12: fix(limit-count): conf with group and disable can't be configured (#7384)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 60ed87be97fffe874498a217c71d80f543f2a055
Author: soulbird <zh...@outlook.com>
AuthorDate: Thu Jul 7 11:37:31 2022 +0800

    fix(limit-count): conf with group and disable can't be configured (#7384)
---
 apisix/plugins/limit-count.lua |  6 +++++-
 t/plugin/limit-count2.t        | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index 746e474b9..e191b6223 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -129,6 +129,7 @@ local schema = {
     }
 }
 
+local schema_copy = core.table.deepcopy(schema)
 
 local _M = {
     version = 0.4,
@@ -151,7 +152,10 @@ function _M.check_schema(conf)
 
     if conf.group then
         local fields = {}
-        for k in pairs(schema.properties) do
+        -- When the goup field is configured,
+        -- we will use schema_copy to get the whitelist of properties,
+        -- so that we can avoid getting injected properties.
+        for k in pairs(schema_copy.properties) do
             tab_insert(fields, k)
         end
         local extra = policy_to_additional_properties[conf.policy]
diff --git a/t/plugin/limit-count2.t b/t/plugin/limit-count2.t
index 621edad8a..e3025be5d 100644
--- a/t/plugin/limit-count2.t
+++ b/t/plugin/limit-count2.t
@@ -764,3 +764,40 @@ limit key: afafafhao2:remote_addr
 limit key: afafafhao2:remote_addr
 --- response_body
 [200,200,503,503]
+
+
+
+=== TEST 22: group with disable
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/services/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "group": "abcd",
+                            "disable": false
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed


[apisix] 05/12: test(openwhisk): ensure the request sent to a wrong host (#7507)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 3dfefe82bad977e28d5f718308fa239b17a71fcf
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Thu Jul 21 09:00:04 2022 +0800

    test(openwhisk): ensure the request sent to a wrong host (#7507)
    
    Avoid test failures:
    Failed test 't/plugin/openwhisk.t TEST 12: hit route (with wrong api_host) -
    pattern "failed to process openwhisk action, err:" should match a line
    in error.log
    happened in CentOS 7 test.
    
    Look like 127.0.0.0 is connectable in some environment.
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 t/plugin/openwhisk.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/plugin/openwhisk.t b/t/plugin/openwhisk.t
index 4d89bbe57..0d7e73a96 100644
--- a/t/plugin/openwhisk.t
+++ b/t/plugin/openwhisk.t
@@ -244,7 +244,7 @@ qr/"error":"The requested resource does not exist."/
                  [[{
                         "plugins": {
                             "openwhisk": {
-                                "api_host": "http://127.0.0.0:3233",
+                                "api_host": "http://127.0.0.1:1979",
                                 "service_token": "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP",
                                 "namespace": "guest",
                                 "action": "non-existent"


[apisix] 10/12: fix: remove the restriction of etcd prefix (#7675)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit aa17261a37c21f5eb934e92071501823d957afa8
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon Aug 15 17:25:41 2022 +0800

    fix: remove the restriction of etcd prefix (#7675)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/cli/schema.lua         |  1 -
 t/cli/test_validate_config.sh | 13 -------------
 2 files changed, 14 deletions(-)

diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua
index e44f0be63..5ed6fe5d8 100644
--- a/apisix/cli/schema.lua
+++ b/apisix/cli/schema.lua
@@ -215,7 +215,6 @@ local config_schema = {
                 },
                 prefix = {
                     type = "string",
-                    pattern = [[^/[^/]+$]]
                 },
                 host = {
                     type = "array",
diff --git a/t/cli/test_validate_config.sh b/t/cli/test_validate_config.sh
index 3310f472b..cb7a911de 100755
--- a/t/cli/test_validate_config.sh
+++ b/t/cli/test_validate_config.sh
@@ -190,17 +190,4 @@ if ! echo "$out" | grep 'property "host" validation failed'; then
     exit 1
 fi
 
-echo '
-etcd:
-    prefix: "/apisix/"
-    host:
-        - https://127.0.0.1
-' > conf/config.yaml
-
-out=$(make init 2>&1 || true)
-if ! echo "$out" | grep 'property "prefix" validation failed'; then
-    echo "failed: should check etcd schema during init"
-    exit 1
-fi
-
 echo "passed: check etcd schema during init"


[apisix] 02/12: ci: make sure the correct version of click is installed (#7589)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit bf605a21d558318dac0f84214f6fa445d9ca92b2
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Aug 2 15:07:53 2022 +0800

    ci: make sure the correct version of click is installed (#7589)
    
    Address broken fuzzing CI like
    https://github.com/apache/apisix/runs/7625185369?check_suite_focus=true
    https://github.com/apache/apisix/runs/7625351307?check_suite_focus=true
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 .github/workflows/fuzzing-ci.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.github/workflows/fuzzing-ci.yaml b/.github/workflows/fuzzing-ci.yaml
index 4e46c7a70..798026eb3 100644
--- a/.github/workflows/fuzzing-ci.yaml
+++ b/.github/workflows/fuzzing-ci.yaml
@@ -60,6 +60,8 @@ jobs:
 
     - name: install boofuzz
       run: |
+        # Avoid "ERROR: flask has requirement click>=8.0, but you'll have click 7.0 which is incompatible"
+        sudo apt remove python3-click
         pip install -r $PWD/t/fuzzing/requirements.txt
 
     - name: run simpleroute test


[apisix] 09/12: chore: upgrade lua-resty-etcd to 1.8.3 (#7565)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit bae4a9b5e811a8d01a8deed2f52d4da2023a0dcc
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Tue Aug 2 13:34:26 2022 +0800

    chore: upgrade lua-resty-etcd to 1.8.3 (#7565)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 rockspec/apisix-master-0.rockspec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec
index 2b93de3f7..297d0bb21 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -34,7 +34,7 @@ dependencies = {
     "lua-resty-ctxdump = 0.1-0",
     "lua-resty-dns-client = 6.0.2",
     "lua-resty-template = 2.0",
-    "lua-resty-etcd = 1.8.2",
+    "lua-resty-etcd = 1.8.3",
     "api7-lua-resty-http = 0.2.0",
     "lua-resty-balancer = 0.04",
     "lua-resty-ngxvar = 0.5.2",


[apisix] 11/12: fix(http-logger): avoid empty Authorization header by default (#7444)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 7268fe7aa689aa08a5113f73d627db42a63d1b0f
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Wed Jul 13 13:49:54 2022 +0800

    fix(http-logger): avoid empty Authorization header by default (#7444)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/plugins/http-logger.lua        |  2 +-
 docs/en/latest/plugins/http-logger.md | 23 +++++++-------
 docs/zh/latest/plugins/http-logger.md |  2 +-
 t/plugin/http-logger2.t               | 56 +++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 14 deletions(-)

diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua
index 3d3ebdfb4..93cd8c9be 100644
--- a/apisix/plugins/http-logger.lua
+++ b/apisix/plugins/http-logger.lua
@@ -33,7 +33,7 @@ local schema = {
     type = "object",
     properties = {
         uri = core.schema.uri_def,
-        auth_header = {type = "string", default = ""},
+        auth_header = {type = "string"},
         timeout = {type = "integer", minimum = 1, default = 3},
         include_req_body = {type = "boolean", default = false},
         include_resp_body = {type = "boolean", default = false},
diff --git a/docs/en/latest/plugins/http-logger.md b/docs/en/latest/plugins/http-logger.md
index 0cfffefc5..673ba001b 100644
--- a/docs/en/latest/plugins/http-logger.md
+++ b/docs/en/latest/plugins/http-logger.md
@@ -29,18 +29,17 @@ This will provide the ability to send Log data requests as JSON objects to Monit
 
 ## Attributes
 
-| Name             | Type    | Requirement | Default       | Valid   | Description                                                                              |
-| ---------------- | ------- | ----------- | ------------- | ------- | ---------------------------------------------------------------------------------------- |
-| uri              | string  | required    |               |         | The URI of the `HTTP/HTTPS` server.                                                      |
-| auth_header      | string  | optional    | ""            |         | Any authorization headers.                                                               |
-| timeout          | integer | optional    | 3             | [1,...] | Time to keep the connection alive after sending a request.                               |
-| name             | string  | optional    | "http logger" |         | A unique identifier to identity the logger.                                              |
-|  include_req_body | boolean | optional    | false         | [false, true] | Whether to include the request body. false: indicates that the requested body is not included; true: indicates that the requested body is included. Note: if the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitation. |
-| include_resp_body| boolean | optional    | false         | [false, true] | Whether to include the response body. The response body is included if and only if it is `true`. |
-| include_resp_body_expr  | array  | optional    |          |         | When `include_resp_body` is true, control the behavior based on the result of the [lua-resty-expr](https://github.com/api7/lua-resty-expr) expression. If present, only log the response body when the result is true. |
-| concat_method    | string  | optional    | "json"        | ["json", "new_line"] | Enum type: `json` and `new_line`. **json**: use `json.encode` for all pending logs. **new_line**: use `json.encode` for each pending log and concat them with "\n" line. |
-| ssl_verify       | boolean | optional    | false          | [false, true] | Whether to verify certificate. |
-
+| Name                   | Type    | Required | Default       | Valid values         | Description                                                                                                                                                                                                              |
+| ---------------------- | ------- | -------- | ------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| uri                    | string  | True     |               |                      | URI of the HTTP/HTTPS server.                                                                                                                                                                                            |
+| auth_header            | string  | False    |               |                      | Authorization headers if required.                                                                                                                                                                                       |
+| timeout                | integer | False    | 3             | [1,...]              | Time to keep the connection alive for after sending a request.                                                                                                                                                           |
+| name                   | string  | False    | "http logger" |                      | Unique identifier to identify the logger.                                                                                                                                                                                |
+| include_req_body       | boolean | False    | false         | [false, true]        | When set to `true` includes the request body in the log. If the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitations.                                                         |
+| include_resp_body      | boolean | False    | false         | [false, true]        | When set to `true` includes the response body in the log.                                                                                                                                                                |
+| include_resp_body_expr | array   | False    |               |                      | When the `include_resp_body` attribute is set to `true`, use this to filter based on [lua-resty-expr](https://github.com/api7/lua-resty-expr). If present, only logs the response if the expression evaluates to `true`. |
+| concat_method          | string  | False    | "json"        | ["json", "new_line"] | Sets how to concatenate logs. When set to `json`, uses `json.encode` for all pending logs and when set to `new_line`, also uses `json.encode` but uses the newline (`\n`) to concatenate lines.                          |
+| ssl_verify             | boolean | False    | false         | [false, true]        | When set to `true` verifies the SSL certificate.                                                                                                                                                                         |
 The plugin supports the use of batch processors to aggregate and process entries(logs/data) in a batch. This avoids frequent data submissions by the plugin, which by default the batch processor submits data every `5` seconds or when the data in the queue reaches `1000`. For information or custom batch processor parameter settings, see [Batch-Processor](../batch-processor.md#configuration) configuration section.
 
 ## How To Enable
diff --git a/docs/zh/latest/plugins/http-logger.md b/docs/zh/latest/plugins/http-logger.md
index ddb270b20..e0d384761 100644
--- a/docs/zh/latest/plugins/http-logger.md
+++ b/docs/zh/latest/plugins/http-logger.md
@@ -32,7 +32,7 @@ title: http-logger
 | 名称             | 类型    | 必选项 | 默认值        | 有效值  | 描述                                             |
 | ---------------- | ------- | ------ | ------------- | ------- | ------------------------------------------------ |
 | uri              | string  | 必须   |               |         | `HTTP/HTTPS` 服务器的 URI。                   |
-| auth_header      | string  | 可选   | ""            |         | 授权头部。                                    |
+| auth_header      | string  | 可选   |               |         | 授权头部。                                    |
 | timeout          | integer | 可选   | 3             | [1,...] | 发送请求后保持连接活动的时间。                   |
 | name             | string  | 可选   | "http logger" |         | 标识 logger 的唯一标识符。                     |
 | include_req_body | boolean | 可选   | false         | [false, true] | 是否包括请求 body。false: 表示不包含请求的 body ; true: 表示包含请求的 body 。 |
diff --git a/t/plugin/http-logger2.t b/t/plugin/http-logger2.t
index 688bc8bc3..f99c11483 100644
--- a/t/plugin/http-logger2.t
+++ b/t/plugin/http-logger2.t
@@ -42,6 +42,13 @@ add_block_preprocessor(sub {
             }
         }
 
+        location /http-logger/Authorization {
+            content_by_lua_block {
+                ngx.log(ngx.WARN, "received Authorization header: [", ngx.var.http_authorization, "]")
+                ngx.say("OK")
+            }
+        }
+
         location /http-logger/center {
             content_by_lua_block {
                 local function str_split(str, reps)
@@ -253,3 +260,52 @@ test-http-logger-response
 request.body:test-http-logger-request
 response.body:test-http-logger-response
 --- wait: 1.5
+
+
+
+=== TEST 8: test default Authorization header sent to the log server
+--- 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,
+                 [[{
+                        "methods": ["POST"],
+                        "plugins": {
+                            "http-logger": {
+                                "uri": "http://127.0.0.1:12001/http-logger/Authorization",
+                                "batch_max_size": 1,
+                                "max_retry_count": 1,
+                                "retry_delay": 2,
+                                "buffer_duration": 2,
+                                "inactive_timeout": 2
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:12001": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/http-logger/test"
+                }]])
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 9: hit
+--- request
+POST /http-logger/test
+test-http-logger-request
+--- error_log
+received Authorization header: [nil]
+--- wait: 1.5


[apisix] 08/12: fix: upgrade lua-resty-etcd to 1.8.2 (#7480)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit d24b4c9bd153a6fc8e6aa1c87de60525bbffa989
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon Jul 18 16:51:34 2022 +0800

    fix: upgrade lua-resty-etcd to 1.8.2 (#7480)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 rockspec/apisix-master-0.rockspec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec
index 91786bbe8..2b93de3f7 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -34,7 +34,7 @@ dependencies = {
     "lua-resty-ctxdump = 0.1-0",
     "lua-resty-dns-client = 6.0.2",
     "lua-resty-template = 2.0",
-    "lua-resty-etcd = 1.6.0",
+    "lua-resty-etcd = 1.8.2",
     "api7-lua-resty-http = 0.2.0",
     "lua-resty-balancer = 0.04",
     "lua-resty-ngxvar = 0.5.2",


[apisix] 01/12: fix: distinguish different upstreams even they have the same addr (#7213)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 33bd7416d76d8c1516af6335f0df7d0166a75878
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon Jun 13 16:52:29 2022 +0800

    fix: distinguish different upstreams even they have the same addr (#7213)
    
    Thanks for the report of @redynasc
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/upstream.lua |  7 ++++--
 t/node/upstream.t   | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/apisix/upstream.lua b/apisix/upstream.lua
index 75c589e9c..e153a1f1c 100644
--- a/apisix/upstream.lua
+++ b/apisix/upstream.lua
@@ -285,8 +285,11 @@ function _M.set_by_route(route, api_ctx)
         end
     end
 
-    set_directly(api_ctx, up_conf.type .. "#upstream_" .. tostring(up_conf),
-                 tostring(up_conf), up_conf)
+    local id = up_conf.parent.value.id
+    local conf_version = up_conf.parent.modifiedIndex
+    -- include the upstream object as part of the version, because the upstream will be changed
+    -- by service discovery or dns resolver.
+    set_directly(api_ctx, id, conf_version .. "#" .. tostring(up_conf), up_conf)
 
     local nodes_count = up_conf.nodes and #up_conf.nodes or 0
     if nodes_count == 0 then
diff --git a/t/node/upstream.t b/t/node/upstream.t
index 9a248bb10..f5501d019 100644
--- a/t/node/upstream.t
+++ b/t/node/upstream.t
@@ -510,3 +510,73 @@ GET /uri
 qr/host: localhost/
 --- error_log
 proxy request to 127.0.0.1:1980
+
+
+
+=== TEST 21: distinguish different upstreams even they have the same addr
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/upstreams/1',
+                 ngx.HTTP_PUT,
+                 {
+                    nodes = {["localhost:1980"] = 1},
+                    type = "roundrobin"
+                 }
+                )
+            assert(code < 300)
+
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "upstream_id": "1",
+                        "uri": "/server_port"
+                }]]
+                )
+            assert(code < 300)
+
+            local http = require "resty.http"
+            local uri = "http://127.0.0.1:" .. ngx.var.server_port
+                        .. "/server_port"
+
+            local ports_count = {}
+            for i = 1, 24 do
+                local httpc = http.new()
+                local res, err = httpc:request_uri(uri)
+                if not res then
+                    ngx.say(err)
+                    return
+                end
+                ports_count[res.body] = (ports_count[res.body] or 0) + 1
+
+                local code, body = t('/apisix/admin/upstreams/1',
+                    ngx.HTTP_PUT,
+                    {
+                        nodes = {["localhost:" .. (1980 + i % 3)] = 1},
+                        type = "roundrobin"
+                    }
+                    )
+                assert(code < 300)
+            end
+
+            local ports_arr = {}
+            for port, count in pairs(ports_count) do
+                table.insert(ports_arr, {port = port, count = count})
+            end
+
+            local function cmd(a, b)
+                return a.port > b.port
+            end
+            table.sort(ports_arr, cmd)
+
+            ngx.say(require("toolkit.json").encode(ports_arr))
+        }
+    }
+--- request
+GET /t
+--- timeout: 5
+--- response_body
+[{"count":8,"port":"1982"},{"count":8,"port":"1981"},{"count":8,"port":"1980"}]
+--- no_error_log
+[error]


[apisix] 04/12: fix: auth plugin repeats the rewrite phase (#7531)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit ec62dd265181a36c3059017db7c32084146d7f26
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Wed Jul 27 17:05:43 2022 +0800

    fix:  auth plugin repeats the rewrite phase (#7531)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/plugin.lua         | 19 +++++++++++---
 t/node/consumer-plugin2.t | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 4 deletions(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index f6ea42743..0c30b419d 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -736,11 +736,20 @@ function _M.run_plugin(phase, plugins, api_ctx)
         and phase ~= "delayed_body_filter"
     then
         for i = 1, #plugins, 2 do
-            if phase == "rewrite_in_consumer" and plugins[i + 1]._from_consumer
-                    and plugins[i].type ~= "auth"then
-                phase = "rewrite"
+            local phase_func
+            if phase == "rewrite_in_consumer" then
+                if plugins[i].type == "auth" then
+                    plugins[i + 1]._skip_rewrite_in_consumer = true
+                end
+                phase_func = plugins[i]["rewrite"]
+            else
+                phase_func = plugins[i][phase]
             end
-            local phase_func = plugins[i][phase]
+
+            if phase == "rewrite_in_consumer" and plugins[i + 1]._skip_rewrite_in_consumer then
+                goto CONTINUE
+            end
+
             if phase_func then
                 plugin_run = true
                 local code, body = phase_func(plugins[i + 1], api_ctx)
@@ -760,6 +769,8 @@ function _M.run_plugin(phase, plugins, api_ctx)
                     end
                 end
             end
+
+            ::CONTINUE::
         end
         return api_ctx, plugin_run
     end
diff --git a/t/node/consumer-plugin2.t b/t/node/consumer-plugin2.t
index 249441a6c..c05762f40 100644
--- a/t/node/consumer-plugin2.t
+++ b/t/node/consumer-plugin2.t
@@ -238,3 +238,68 @@ x-real-ip: 127.0.0.1
     }
 --- response_body
 {"key-auth":true,"proxy-rewrite":true}
+
+
+
+=== TEST 7: configure non-auth plugins in the consumer and run it's rewrite phase
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/consumers/jack',
+                 ngx.HTTP_PUT,
+                [[{
+                    "username": "jack",
+                    "plugins": {
+                        "key-auth": {
+                            "key": "auth-jack"
+                        },
+                        "ip-restriction": {
+                            "blacklist": [
+                                "127.0.0.0/24"
+                            ]
+                        }
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "plugins": {
+                            "key-auth": {}
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/hello"
+                }]]
+            )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 8: hit routes and ip-restriction work well
+--- request
+GET /hello
+--- more_headers
+apikey: auth-jack
+--- error_code: 403
+--- response_body
+{"message":"Your IP address is not allowed"}


[apisix] 06/12: fix: adjust the execution priority of request-id to fix opentelemetry has no request id (#7281)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 871aface63a5b268fe6f1a28530e0eba590c9a36
Author: Jager <im...@zhang.ge>
AuthorDate: Wed Jun 22 18:04:04 2022 +0800

    fix: adjust the execution priority of request-id to fix opentelemetry has no request id (#7281)
    
    Co-authored-by: Jagerzhang <ja...@tencent.com>
---
 apisix/plugins/request-id.lua | 2 +-
 conf/config-default.yaml      | 2 +-
 t/admin/plugins.t             | 2 +-
 t/debug/debug-mode.t          | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/apisix/plugins/request-id.lua b/apisix/plugins/request-id.lua
index 183374e8f..062ef4513 100644
--- a/apisix/plugins/request-id.lua
+++ b/apisix/plugins/request-id.lua
@@ -63,7 +63,7 @@ local attr_schema = {
 
 local _M = {
     version = 0.1,
-    priority = 11010,
+    priority = 12015,
     name = plugin_name,
     schema = schema
 }
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index d42ff2151..f9be1c0b5 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -325,11 +325,11 @@ plugins:                          # plugin list (sorted by priority)
   - real-ip                        # priority: 23000
   - client-control                 # priority: 22000
   - proxy-control                  # priority: 21990
+  - request-id                     # priority: 12015
   - zipkin                         # priority: 12011
   #- skywalking                    # priority: 12010
   #- opentelemetry                 # priority: 12009
   - ext-plugin-pre-req             # priority: 12000
-  - request-id                     # priority: 11010
   - fault-injection                # priority: 11000
   - mocking                        # priority: 10900
   - serverless-pre-function        # priority: 10000
diff --git a/t/admin/plugins.t b/t/admin/plugins.t
index 2cd06c809..fc6531378 100644
--- a/t/admin/plugins.t
+++ b/t/admin/plugins.t
@@ -64,9 +64,9 @@ __DATA__
 real-ip
 client-control
 proxy-control
+request-id
 zipkin
 ext-plugin-pre-req
-request-id
 fault-injection
 mocking
 serverless-pre-function
diff --git a/t/debug/debug-mode.t b/t/debug/debug-mode.t
index d2f629d8e..0fe20a8bb 100644
--- a/t/debug/debug-mode.t
+++ b/t/debug/debug-mode.t
@@ -43,9 +43,9 @@ done
 --- error_log
 loaded plugin and sort by priority: 23000 name: real-ip
 loaded plugin and sort by priority: 22000 name: client-control
+loaded plugin and sort by priority: 12015 name: request-id
 loaded plugin and sort by priority: 12011 name: zipkin
 loaded plugin and sort by priority: 12000 name: ext-plugin-pre-req
-loaded plugin and sort by priority: 11010 name: request-id
 loaded plugin and sort by priority: 11000 name: fault-injection
 loaded plugin and sort by priority: 10000 name: serverless-pre-function
 loaded plugin and sort by priority: 4000 name: cors


[apisix] 12/12: fix(k8s): cleanup variable before re list and watch (#7506)

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch release/2.13
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 29541f5e234cbd1aa0ae93ed86cbb5692cd985b2
Author: zhixiongdu <ro...@libssl.com>
AuthorDate: Fri Jul 22 14:15:01 2022 +0800

    fix(k8s): cleanup variable before re list and watch (#7506)
---
 apisix/discovery/kubernetes/informer_factory.lua | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/apisix/discovery/kubernetes/informer_factory.lua b/apisix/discovery/kubernetes/informer_factory.lua
index a03f27a5a..3dca06403 100644
--- a/apisix/discovery/kubernetes/informer_factory.lua
+++ b/apisix/discovery/kubernetes/informer_factory.lua
@@ -263,6 +263,9 @@ local function list_watch(informer, apiserver)
     local reason, message
     local httpc = http.new()
 
+    informer.continue = ""
+    informer.version = ""
+
     informer.fetch_state = "connecting"
     core.log.info("begin to connect ", apiserver.host, ":", apiserver.port)