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/11/10 01:58:01 UTC

[apisix] branch release/2.15 updated (4fb18b0d5 -> ae71e11e3)

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

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


    from 4fb18b0d5 docs: fix indent
     new 4ca7183bd chore: upgrade lua-resty-etcd to 1.8.3 (#7565)
     new 5d991fd1f fix(balancer): quote ipv6 address (#7594)
     new 59e0a4a34 fix: the phases after proxy should run when 500 happens before proxy (#7703)
     new af98e895b ci: change base JDK images to eclipse-temurin as openjdk is being deprecated (#7768)
     new 6e2abc39a change: drop support of OpenResty 1.17 (#7625)
     new f16bcd60b ci: update Ubuntu to 20.04 as 18.04 was deprecated (#7766)
     new a2a91da8a ci: make sure the correct version of click is installed (#7589)
     new 962e477ac ci: upgrade go version
     new 55082f6de fix(limit-count): different route with same conf should not share counter (#7750)
     new 4bb4acfef fix(zipkin): send trace IDs with a reject sampling decision (#7833)
     new cef54ee87 fix(zipkin): send trace IDs with a reject sampling decision (#8099)
     new ba67d351d fix(gRPC): set :authority header to the upstream host (#7939)
     new 32bae9594 fix:  auth plugin repeats the rewrite phase (#7531)
     new 70457ba28 fix: use modifiedIndex as lru key when merge plugins from route and consumer (#7965)
     new e262a9000 fix: meta.filter in plugin doesn't work in response-rewrite plugin (#8162)
     new c020f0eb0 fix: APISIX extended variables cannot be used in `_meta.filter` (#8256)
     new 8be3a9816 test: fix incompatible test failure
     new ae71e11e3 fix: add change lost when handling merge conflict

The 18 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/build.yml                        |   4 +-
 .github/workflows/chaos.yml                        |   2 +-
 .github/workflows/cli-master.yml                   |   2 +-
 .github/workflows/cli.yml                          |   2 +-
 .github/workflows/fuzzing-ci.yaml                  |   2 +
 .github/workflows/kubernetes-ci.yml                |   4 +-
 .github/workflows/performance.yml                  |   2 +-
 .github/workflows/tars-ci.yml                      |   4 +-
 apisix/balancer.lua                                |  11 +-
 apisix/cli/ngx_tpl.lua                             |  10 +-
 apisix/cli/ops.lua                                 |   8 +-
 apisix/conf_server.lua                             |   2 +-
 apisix/consumer.lua                                |   1 +
 apisix/init.lua                                    |  14 +-
 apisix/plugin.lua                                  |  60 ++++-
 apisix/plugins/limit-count.lua                     |   2 +-
 apisix/plugins/zipkin.lua                          |  61 ++---
 apisix/plugins/zipkin/codec.lua                    |  10 +-
 apisix/plugins/zipkin/reporter.lua                 |   3 +
 apisix/upstream.lua                                |   7 -
 bin/apisix                                         |   6 +-
 ...17_runner.sh => linux_openresty_1_19_runner.sh} |   2 +-
 ci/pod/nacos/service/Dockerfile                    |   2 +-
 docs/en/latest/admin-api.md                        |   2 +-
 docs/zh/latest/admin-api.md                        |   2 +-
 rockspec/apisix-master-0.rockspec                  |   2 +-
 t/APISIX.pm                                        |  20 +-
 t/admin/upstream4.t                                |  60 ++---
 t/deployment/conf_server.t                         |  15 +-
 t/deployment/conf_server2.t                        |  11 +-
 t/error_page/error_page.t                          |  55 +++++
 ...ls-openresty-1-19.t => client-mtls-openresty.t} |   6 +-
 t/node/consumer-plugin2.t                          | 197 +++++++++++++++
 t/node/grpc-proxy.t                                |  96 ++++++++
 t/node/merge-route.t                               |   4 +-
 t/node/plugin-configs.t                            | 102 ++++++++
 t/node/upstream-ipv6.t                             | 184 ++++++++++++++
 t/node/upstream.t                                  |   6 -
 .../{sanity-openresty-1-19.t => sanity2.t}         |  11 +-
 t/plugin/limit-count3.t                            |  61 +++++
 t/plugin/plugin.t                                  | 265 ++++++++++++++++++++-
 t/plugin/traffic-split2.t                          |   2 -
 t/plugin/zipkin2.t                                 |   7 +
 t/stream-node/sanity.t                             |   2 -
 utils/linux-install-openresty.sh                   |   2 +-
 45 files changed, 1138 insertions(+), 195 deletions(-)
 rename ci/{linux_openresty_1_17_runner.sh => linux_openresty_1_19_runner.sh} (96%)
 rename t/node/{client-mtls-openresty-1-19.t => client-mtls-openresty.t} (96%)
 rename t/plugin/ext-plugin/{sanity-openresty-1-19.t => sanity2.t} (86%)


[apisix] 03/18: fix: the phases after proxy should run when 500 happens before proxy (#7703)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 59e0a4a34c13de9094047d1a0ab2e53e893aed02
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Wed Aug 17 10:48:35 2022 +0800

    fix: the phases after proxy should run when 500 happens before proxy (#7703)
---
 apisix/init.lua           |  8 +++----
 t/APISIX.pm               |  1 +
 t/error_page/error_page.t | 55 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index 25d9d5aa2..8bb64760d 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -421,6 +421,10 @@ function _M.http_access_phase()
     api_ctx.route_id = route.value.id
     api_ctx.route_name = route.value.name
 
+    local ref = ctxdump.stash_ngx_ctx()
+    core.log.info("stash ngx ctx: ", ref)
+    ngx_var.ctx_ref = ref
+
     -- run global rule
     plugin.run_global_rules(api_ctx, router.global_rules, nil)
 
@@ -554,10 +558,6 @@ function _M.http_access_phase()
     -- run the before_proxy method in access phase first to avoid always reinit request
     common_phase("before_proxy")
 
-    local ref = ctxdump.stash_ngx_ctx()
-    core.log.info("stash ngx ctx: ", ref)
-    ngx_var.ctx_ref = ref
-
     local up_scheme = api_ctx.upstream_scheme
     if up_scheme == "grpcs" or up_scheme == "grpc" then
         return ngx.exec("@grpc_pass")
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 0143aa9d8..62f1904f1 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -604,6 +604,7 @@ _EOC_
             more_clear_headers Date;
         }
 
+        # this configuration is needed as error_page is configured in http block
         location \@50x.html {
             set \$from_error_page 'true';
             content_by_lua_block {
diff --git a/t/error_page/error_page.t b/t/error_page/error_page.t
index 70cc34c68..981dc36a1 100644
--- a/t/error_page/error_page.t
+++ b/t/error_page/error_page.t
@@ -198,3 +198,58 @@ qr/(stash|fetch) ngx ctx/
 --- grep_error_log_out
 stash ngx ctx
 fetch ngx ctx
+
+
+
+=== TEST 11: check if the phases after proxy are run when 500 happens before proxy
+--- 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,
+                 [[{
+                    "plugins": {
+                        "serverless-post-function": {
+                            "functions" : ["return function() if ngx.var.http_x_test_status ~= nil then;ngx.exit(tonumber(ngx.var.http_x_test_status));end;end"]
+                        },
+                        "serverless-pre-function": {
+                            "phase": "log",
+                            "functions" : ["return function() ngx.log(ngx.WARN, 'run log phase in error_page') end"]
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uri": "/*"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 12: hit
+--- request
+GET /hello
+--- more_headers
+X-Test-Status: 500
+--- error_code: 500
+--- response_body_like
+.*apisix.apache.org.*
+--- error_log
+run log phase in error_page


[apisix] 09/18: fix(limit-count): different route with same conf should not share counter (#7750)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 55082f6de4ee1a06db3ff9cfa8b8decd4af1ba43
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Wed Aug 24 11:11:47 2022 +0800

    fix(limit-count): different route with same conf should not share counter (#7750)
    
    fix #7746
---
 apisix/plugins/limit-count.lua |  2 +-
 t/plugin/limit-count3.t        | 61 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index e191b6223..56ff34cb2 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -251,7 +251,7 @@ function _M.access(conf, ctx)
         -- Here we use plugin-level conf version to prevent the counter from being resetting
         -- because of the change elsewhere.
         -- A route which reuses a previous route's ID will inherits its counter.
-        key = ctx.conf_type .. apisix_plugin.conf_version(conf) .. ':' .. key
+        key = ctx.conf_type .. ctx.conf_id .. ':' .. apisix_plugin.conf_version(conf) .. ':' .. key
     else
         key = conf.group .. ':' .. key
     end
diff --git a/t/plugin/limit-count3.t b/t/plugin/limit-count3.t
index 4298a20bd..0c5490616 100644
--- a/t/plugin/limit-count3.t
+++ b/t/plugin/limit-count3.t
@@ -224,3 +224,64 @@ passed
     }
 --- response_body
 [200,200]
+
+
+
+=== TEST 7: set another route with the same conf
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/2',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello1",
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 61
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 8: avoid sharing the same counter
+--- config
+    location /t {
+        content_by_lua_block {
+            local json = require "t.toolkit.json"
+            local http = require "resty.http"
+            local uri = "http://127.0.0.1:" .. ngx.var.server_port
+                        .. "/hello1"
+            local ress = {}
+            for i = 1, 2 do
+                local httpc = http.new()
+                local res, err = httpc:request_uri(uri)
+                if not res then
+                    ngx.say(err)
+                    return
+                end
+                table.insert(ress, res.status)
+            end
+            ngx.say(json.encode(ress))
+        }
+    }
+--- response_body
+[200,200]


[apisix] 17/18: test: fix incompatible test failure

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 8be3a9816fb3d3e21cbce9cfa134e9e821003e47
Author: spacewander <sp...@gmail.com>
AuthorDate: Wed Nov 9 15:14:56 2022 +0800

    test: fix incompatible test failure
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 t/node/merge-route.t | 4 +++-
 t/plugin/plugin.t    | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/t/node/merge-route.t b/t/node/merge-route.t
index b6f1d467e..f5223de99 100644
--- a/t/node/merge-route.t
+++ b/t/node/merge-route.t
@@ -180,7 +180,9 @@ qr/1980/
                             "time_window": 60,
                             "rejected_code": 503,
                             "key": "remote_addr",
-                            "disable": true
+                            "_meta": {
+                                "disable": true
+                            }
                         }
                     },
                     "uri": "/server_port",
diff --git a/t/plugin/plugin.t b/t/plugin/plugin.t
index 7ad45bc0d..7886e324a 100644
--- a/t/plugin/plugin.t
+++ b/t/plugin/plugin.t
@@ -762,7 +762,8 @@ GET /hello
                     upstream = {
                         nodes = {
                             ["127.0.0.1:1980"] = 1
-                        }
+                        },
+                        type = "roundrobin"
                     },
                     uri = "/hello"
                 }


[apisix] 12/18: fix(gRPC): set :authority header to the upstream host (#7939)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit ba67d351ddfab9b2c0d090783a70f913cb5afeed
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Tue Sep 20 09:16:00 2022 +0800

    fix(gRPC): set :authority header to the upstream host (#7939)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/cli/ngx_tpl.lua |  8 +++++
 t/APISIX.pm            | 13 +++++++
 t/node/grpc-proxy.t    | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+)

diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua
index b459cd027..dba9917cb 100644
--- a/apisix/cli/ngx_tpl.lua
+++ b/apisix/cli/ngx_tpl.lua
@@ -773,6 +773,14 @@ http {
                 apisix.grpc_access_phase()
             }
 
+            {% if use_apisix_openresty then %}
+            # For servers which obey the standard, when `:authority` is missing,
+            # `host` will be used instead. When used with apisix-base, we can do
+            # better by setting `:authority` directly
+            grpc_set_header   ":authority" $upstream_host;
+            {% else %}
+            grpc_set_header   "Host" $upstream_host;
+            {% end %}
             grpc_set_header   Content-Type application/grpc;
             grpc_socket_keepalive on;
             grpc_pass         $upstream_scheme://apisix_backend;
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 999bcd8a1..bce7c735a 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -177,6 +177,19 @@ my $grpc_location = <<_EOC_;
                 apisix.grpc_access_phase()
             }
 
+_EOC_
+
+if ($version =~ m/\/apisix-nginx-module/) {
+    $grpc_location .= <<_EOC_;
+            grpc_set_header   ":authority" \$upstream_host;
+_EOC_
+} else {
+    $grpc_location .= <<_EOC_;
+            grpc_set_header   "Host" \$upstream_host;
+_EOC_
+}
+
+$grpc_location .= <<_EOC_;
             grpc_set_header   Content-Type application/grpc;
             grpc_socket_keepalive on;
             grpc_pass         \$upstream_scheme://apisix_backend;
diff --git a/t/node/grpc-proxy.t b/t/node/grpc-proxy.t
index c4338e77b..9c173792c 100644
--- a/t/node/grpc-proxy.t
+++ b/t/node/grpc-proxy.t
@@ -183,3 +183,99 @@ GET /hello
 --- error_code: 502
 --- error_log
 upstream: "grpc://127.0.0.1:80"
+
+
+
+=== TEST 7: set authority header
+--- log_level: debug
+--- http2
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uris:
+        - /helloworld.Greeter/SayHello
+    methods: [
+        POST
+    ]
+    upstream:
+      scheme: grpc
+      nodes:
+        "127.0.0.1:50051": 1
+      type: roundrobin
+#END
+--- exec
+grpcurl -import-path ./t/grpc_server_example/proto -proto helloworld.proto -plaintext -d '{"name":"apisix"}' 127.0.0.1:1984 helloworld.Greeter.SayHello
+--- response_body
+{
+  "message": "Hello apisix"
+}
+--- grep_error_log eval
+qr/grpc header: "(:authority|host): [^"]+"/
+--- grep_error_log_out eval
+qr/grpc header: "(:authority|host): 127.0.0.1:1984"/
+
+
+
+=== TEST 8: set authority header to node header
+--- log_level: debug
+--- http2
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uris:
+        - /helloworld.Greeter/SayHello
+    methods: [
+        POST
+    ]
+    upstream:
+      scheme: grpc
+      pass_host: node
+      nodes:
+        "127.0.0.1:50051": 1
+      type: roundrobin
+#END
+--- exec
+grpcurl -import-path ./t/grpc_server_example/proto -proto helloworld.proto -plaintext -d '{"name":"apisix"}' 127.0.0.1:1984 helloworld.Greeter.SayHello
+--- response_body
+{
+  "message": "Hello apisix"
+}
+--- grep_error_log eval
+qr/grpc header: "(:authority|host): [^"]+"/
+--- grep_error_log_out eval
+qr/grpc header: "(:authority|host): 127.0.0.1:50051"/
+
+
+
+=== TEST 9: set authority header to specific value
+--- log_level: debug
+--- http2
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uris:
+        - /helloworld.Greeter/SayHello
+    methods: [
+        POST
+    ]
+    upstream:
+      scheme: grpc
+      pass_host: rewrite
+      upstream_host: hello.world
+      nodes:
+        "127.0.0.1:50051": 1
+      type: roundrobin
+#END
+--- exec
+grpcurl -import-path ./t/grpc_server_example/proto -proto helloworld.proto -plaintext -d '{"name":"apisix"}' 127.0.0.1:1984 helloworld.Greeter.SayHello
+--- response_body
+{
+  "message": "Hello apisix"
+}
+--- grep_error_log eval
+qr/grpc header: "(:authority|host): [^"]+"/
+--- grep_error_log_out eval
+qr/grpc header: "(:authority|host): hello.world"/


[apisix] 04/18: ci: change base JDK images to eclipse-temurin as openjdk is being deprecated (#7768)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit af98e895b84a37b136386d0db57f07c22d1f74f5
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Tue Aug 23 12:48:37 2022 +0800

    ci: change base JDK images to eclipse-temurin as openjdk is being deprecated (#7768)
---
 ci/pod/nacos/service/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ci/pod/nacos/service/Dockerfile b/ci/pod/nacos/service/Dockerfile
index f76ba1585..d279c7497 100644
--- a/ci/pod/nacos/service/Dockerfile
+++ b/ci/pod/nacos/service/Dockerfile
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-FROM java
+FROM eclipse-temurin:8
 
 ENV SUFFIX_NUM=${SUFFIX_NUM:-1}
 ENV NACOS_ADDR=${NACOS_ADDR:-127.0.0.1:8848}


[apisix] 08/18: ci: upgrade go version

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 962e477acd58b480baa79878ceea07f520ec9cb4
Author: spacewander <sp...@gmail.com>
AuthorDate: Wed Nov 9 11:10:43 2022 +0800

    ci: upgrade go version
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 .github/workflows/chaos.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/chaos.yml b/.github/workflows/chaos.yml
index 20b45f602..95f48132c 100644
--- a/.github/workflows/chaos.yml
+++ b/.github/workflows/chaos.yml
@@ -26,7 +26,7 @@ jobs:
       - name: Setup go
         uses: actions/setup-go@v3
         with:
-          go-version: "1.16"
+          go-version: "1.17"
 
       - uses: actions/cache@v3
         with:


[apisix] 16/18: fix: APISIX extended variables cannot be used in `_meta.filter` (#8256)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit c020f0eb06e0d011eebc7564632286e9574c8834
Author: soulbird <zh...@outlook.com>
AuthorDate: Mon Nov 7 15:02:28 2022 +0800

    fix: APISIX extended variables cannot be used in `_meta.filter` (#8256)
    
    Co-authored-by: soulbird <zh...@gmail.com>
    Fixes https://github.com/apache/apisix/issues/8251
---
 apisix/plugin.lua |  2 +-
 t/plugin/plugin.t | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 511fbc605..7224e3492 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -425,7 +425,7 @@ local function meta_filter(ctx, plugin_name, plugin_conf)
                          " plugin_name: ", plugin_name)
         return true
     end
-    ok, err = ex:eval()
+    ok, err = ex:eval(ctx.var)
     if err then
         core.log.warn("failed to run the 'vars' expression: ", err,
                          " plugin_name: ", plugin_name)
diff --git a/t/plugin/plugin.t b/t/plugin/plugin.t
index 248688050..7ad45bc0d 100644
--- a/t/plugin/plugin.t
+++ b/t/plugin/plugin.t
@@ -735,3 +735,55 @@ passed
 GET /hello
 --- response_headers
 !x-version
+
+
+
+=== TEST 29: use APISIX's built-in variables in  meta.filter
+--- 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,
+                {
+                    plugins = {
+                        ["proxy-rewrite"] = {
+                            _meta = {
+                                filter = {
+                                    {"post_arg_key", "==", "abc"}
+                                }
+                            },
+                            uri = "/echo",
+                            headers = {
+                                ["X-Api-Version"] = "ga"
+                            }
+                        }
+                    },
+                    upstream = {
+                        nodes = {
+                            ["127.0.0.1:1980"] = 1
+                        }
+                    },
+                    uri = "/hello"
+                }
+            )
+            if code >= 300 then
+                ngx.print(body)
+            else
+                ngx.say(body)
+            end
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 30: hit route: proxy-rewrite enable with post_arg_xx in meta.filter
+--- request
+POST /hello
+key=abc
+--- more_headers
+Content-Type: application/x-www-form-urlencoded
+--- response_headers
+x-api-version: ga


[apisix] 07/18: 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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit a2a91da8a8b97850a02c2c5247be9811a48027e0
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 426ebcc37..757bb93b7 100644
--- a/.github/workflows/fuzzing-ci.yaml
+++ b/.github/workflows/fuzzing-ci.yaml
@@ -63,6 +63,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] 10/18: fix(zipkin): send trace IDs with a reject sampling decision (#7833)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 4bb4acfefb45e8278ba7743ab3b82eedcbbb392b
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Fri Sep 2 13:51:49 2022 +0800

    fix(zipkin): send trace IDs with a reject sampling decision (#7833)
---
 apisix/plugins/zipkin.lua | 8 ++++++++
 t/plugin/zipkin2.t        | 7 +++++++
 2 files changed, 15 insertions(+)

diff --git a/apisix/plugins/zipkin.lua b/apisix/plugins/zipkin.lua
index 3fafd29f0..ab284cefe 100644
--- a/apisix/plugins/zipkin.lua
+++ b/apisix/plugins/zipkin.lua
@@ -127,6 +127,8 @@ function _M.rewrite(plugin_conf, ctx)
     local b3 = headers["b3"]
     if b3 then
         -- don't pass b3 header by default
+        -- TODO: add an option like 'single_b3_header' so we can adapt to the upstream
+        -- which doesn't support b3 header without always breaking down the header
         core.request.set_header(ctx, "b3", nil)
 
         local err
@@ -158,6 +160,12 @@ function _M.rewrite(plugin_conf, ctx)
     ctx.opentracing_sample = tracer.sampler:sample(per_req_sample_ratio or conf.sample_ratio)
     if not ctx.opentracing_sample then
         core.request.set_header(ctx, "x-b3-sampled", "0")
+        -- pass the trace ids even the sample is rejected
+        -- see https://github.com/openzipkin/b3-propagation#why-send-
+        -- trace-ids-with-a-reject-sampling-decision
+        core.request.set_header(ctx, "x-b3-traceid", trace_id)
+        core.request.set_header(ctx, "x-b3-parentspanid", parent_span_id)
+        core.request.set_header(ctx, "x-b3-spanid", request_span_id)
         return
     end
 
diff --git a/t/plugin/zipkin2.t b/t/plugin/zipkin2.t
index 3175075d3..8423f6f67 100644
--- a/t/plugin/zipkin2.t
+++ b/t/plugin/zipkin2.t
@@ -98,6 +98,7 @@ passed
 b3: 80f198ee56343ba864fe8b2a57d3eff7-e457b5a2e4d86bd1-1-05e3ac9a4f6e3b90
 --- response_headers
 x-b3-sampled: 1
+x-b3-traceid: 80f198ee56343ba864fe8b2a57d3eff7
 --- raw_response_headers_unlike
 b3:
 --- error_log
@@ -124,6 +125,9 @@ invalid b3 header
 b3: 80f198ee56343ba864fe8b2a57d3eff7-e457b5a2e4d86bd1-0-05e3ac9a4f6e3b90
 --- response_headers
 x-b3-sampled: 0
+x-b3-traceid: 80f198ee56343ba864fe8b2a57d3eff7
+x-b3-parentspanid: 05e3ac9a4f6e3b90
+x-b3-spanid: e457b5a2e4d86bd1
 
 
 
@@ -132,6 +136,9 @@ x-b3-sampled: 0
 b3: 0
 --- response_headers
 x-b3-sampled: 0
+x-b3-traceid:
+x-b3-parentspanid:
+x-b3-spanid:
 
 
 


[apisix] 11/18: fix(zipkin): send trace IDs with a reject sampling decision (#8099)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit cef54ee87da07f9d45c8b1d5e65e32a4acc8b493
Author: Gallardot <tt...@163.com>
AuthorDate: Mon Oct 31 14:16:24 2022 +0800

    fix(zipkin): send trace IDs with a reject sampling decision (#8099)
---
 apisix/plugins/zipkin.lua          | 65 ++++++++++++++++++--------------------
 apisix/plugins/zipkin/codec.lua    | 10 +++---
 apisix/plugins/zipkin/reporter.lua |  3 ++
 t/plugin/zipkin2.t                 | 10 +++---
 4 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/apisix/plugins/zipkin.lua b/apisix/plugins/zipkin.lua
index ab284cefe..0c0c4748d 100644
--- a/apisix/plugins/zipkin.lua
+++ b/apisix/plugins/zipkin.lua
@@ -100,6 +100,21 @@ local function parse_b3(b3)
     return nil, pieces[1], pieces[2], pieces[3], pieces[4]
 end
 
+local function inject_header(ctx)
+    local opentracing = ctx.opentracing
+    local tracer = opentracing.tracer
+    local outgoing_headers = {}
+
+    local span = opentracing.request_span
+    if ctx.opentracing_sample then
+        span = opentracing.proxy_span
+    end
+    tracer:inject(span, "http_headers", outgoing_headers)
+
+    for k, v in pairs(outgoing_headers) do
+        core.request.set_header(ctx, k, v)
+    end
+end
 
 function _M.rewrite(plugin_conf, ctx)
     local conf = core.table.clone(plugin_conf)
@@ -151,24 +166,6 @@ function _M.rewrite(plugin_conf, ctx)
         request_span_id = headers["x-b3-spanid"]
     end
 
-    if sampled == "1" or sampled == "true" then
-        per_req_sample_ratio = 1
-    elseif sampled == "0" or sampled == "false" then
-        per_req_sample_ratio = 0
-    end
-
-    ctx.opentracing_sample = tracer.sampler:sample(per_req_sample_ratio or conf.sample_ratio)
-    if not ctx.opentracing_sample then
-        core.request.set_header(ctx, "x-b3-sampled", "0")
-        -- pass the trace ids even the sample is rejected
-        -- see https://github.com/openzipkin/b3-propagation#why-send-
-        -- trace-ids-with-a-reject-sampling-decision
-        core.request.set_header(ctx, "x-b3-traceid", trace_id)
-        core.request.set_header(ctx, "x-b3-parentspanid", parent_span_id)
-        core.request.set_header(ctx, "x-b3-spanid", request_span_id)
-        return
-    end
-
     local zipkin_ctx = core.tablepool.fetch("zipkin_ctx", 0, 3)
     zipkin_ctx.trace_id = trace_id
     zipkin_ctx.parent_span_id = parent_span_id
@@ -198,11 +195,24 @@ function _M.rewrite(plugin_conf, ctx)
         request_span = request_span,
     }
 
+    -- Process sampled
+    if sampled == "1" or sampled == "true" then
+        per_req_sample_ratio = 1
+    elseif sampled == "0" or sampled == "false" then
+        per_req_sample_ratio = 0
+    end
+
+    ctx.opentracing_sample = tracer.sampler:sample(per_req_sample_ratio or conf.sample_ratio)
+    if not ctx.opentracing_sample then
+        request_span:set_baggage_item("x-b3-sampled","0")
+        return
+    end
+    request_span:set_baggage_item("x-b3-sampled","1")
+
     local request_span = ctx.opentracing.request_span
     if conf.span_version == ZIPKIN_SPAN_VER_1 then
         ctx.opentracing.rewrite_span = request_span:start_child_span("apisix.rewrite",
                                                                      start_timestamp)
-
         ctx.REWRITE_END_TIME = tracer:time()
         ctx.opentracing.rewrite_span:finish(ctx.REWRITE_END_TIME)
     else
@@ -212,10 +222,6 @@ function _M.rewrite(plugin_conf, ctx)
 end
 
 function _M.access(conf, ctx)
-    if not ctx.opentracing_sample then
-        return
-    end
-
     local opentracing = ctx.opentracing
     local tracer = opentracing.tracer
 
@@ -231,11 +237,7 @@ function _M.access(conf, ctx)
     end
 
     -- send headers to upstream
-    local outgoing_headers = {}
-    tracer:inject(opentracing.proxy_span, "http_headers", outgoing_headers)
-    for k, v in pairs(outgoing_headers) do
-        core.request.set_header(ctx, k, v)
-    end
+    inject_header(ctx)
 end
 
 
@@ -261,10 +263,6 @@ end
 
 
 function _M.log(conf, ctx)
-    if not ctx.opentracing_sample then
-        return
-    end
-
     local opentracing = ctx.opentracing
 
     local log_end_time = opentracing.tracer:time()
@@ -276,8 +274,7 @@ function _M.log(conf, ctx)
         if opentracing.proxy_span then
             opentracing.proxy_span:finish(log_end_time)
         end
-
-    else
+    elseif opentracing.response_span then
         opentracing.response_span:finish(log_end_time)
     end
 
diff --git a/apisix/plugins/zipkin/codec.lua b/apisix/plugins/zipkin/codec.lua
index eade5e004..917c49233 100644
--- a/apisix/plugins/zipkin/codec.lua
+++ b/apisix/plugins/zipkin/codec.lua
@@ -97,11 +97,13 @@ local function new_injector()
         headers["x-b3-parentspanid"] = span_context.parent_id
                                     and to_hex(span_context.parent_id) or nil
         headers["x-b3-spanid"] = to_hex(span_context.span_id)
-        -- when we call this function, we already start to sample
-        headers["x-b3-sampled"] = "1"
+        headers["x-b3-sampled"] = span_context:get_baggage_item("x-b3-sampled")
         for key, value in span_context:each_baggage_item() do
-            -- XXX: https://github.com/opentracing/specification/issues/117
-            headers["uberctx-"..key] = ngx.escape_uri(value)
+            -- skip x-b3-sampled baggage
+            if key ~= "x-b3-sampled" then
+                -- XXX: https://github.com/opentracing/specification/issues/117
+                headers["uberctx-"..key] = ngx.escape_uri(value)
+            end
         end
     end
 end
diff --git a/apisix/plugins/zipkin/reporter.lua b/apisix/plugins/zipkin/reporter.lua
index e6c051aa3..2edf1c1b7 100644
--- a/apisix/plugins/zipkin/reporter.lua
+++ b/apisix/plugins/zipkin/reporter.lua
@@ -56,6 +56,9 @@ end
 
 
 function _M.report(self, span)
+    if span:get_baggage_item("x-b3-sampled") == "0" then
+        return
+    end
     local span_context = span:context()
 
     local zipkin_tags = {}
diff --git a/t/plugin/zipkin2.t b/t/plugin/zipkin2.t
index 8423f6f67..d99defa5a 100644
--- a/t/plugin/zipkin2.t
+++ b/t/plugin/zipkin2.t
@@ -126,8 +126,8 @@ b3: 80f198ee56343ba864fe8b2a57d3eff7-e457b5a2e4d86bd1-0-05e3ac9a4f6e3b90
 --- response_headers
 x-b3-sampled: 0
 x-b3-traceid: 80f198ee56343ba864fe8b2a57d3eff7
-x-b3-parentspanid: 05e3ac9a4f6e3b90
-x-b3-spanid: e457b5a2e4d86bd1
+x-b3-parentspanid: e457b5a2e4d86bd1
+--- raw_response_headers_like: x-b3-spanid: .*
 
 
 
@@ -136,9 +136,9 @@ x-b3-spanid: e457b5a2e4d86bd1
 b3: 0
 --- response_headers
 x-b3-sampled: 0
-x-b3-traceid:
-x-b3-parentspanid:
-x-b3-spanid:
+--- raw_response_headers_like
+x-b3-traceid: .*
+x-b3-spanid: .*
 
 
 


[apisix] 18/18: fix: add change lost when handling merge conflict

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit ae71e11e35b2147778522e10b92ecfa976d15b99
Author: spacewander <sp...@gmail.com>
AuthorDate: Wed Nov 9 16:46:26 2022 +0800

    fix: add change lost when handling merge conflict
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/plugin.lua | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 7224e3492..7408786cb 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -460,7 +460,8 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
         if not check_disable(plugin_conf) then
             if plugin_obj.run_policy == "prefer_route" and route_plugin_conf ~= nil then
                 local plugin_conf_in_route = route_plugin_conf[name]
-                if plugin_conf_in_route and not plugin_conf_in_route.disable then
+                local disable_in_route = check_disable(plugin_conf_in_route)
+                if plugin_conf_in_route and not disable_in_route then
                     goto continue
                 end
             end


[apisix] 13/18: 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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

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

    fix:  auth plugin repeats the rewrite phase (#7531)
---
 apisix/plugin.lua         | 14 ++++++----
 t/node/consumer-plugin2.t | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index e87dbc750..a624a5696 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -881,13 +881,17 @@ 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" and plugins[i + 1]._skip_rewrite_in_consumer then
+            if phase == "rewrite_in_consumer" and plugins[i + 1]._skip_rewrite_in_consumer then
                 goto CONTINUE
             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] 02/18: fix(balancer): quote ipv6 address (#7594)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 5d991fd1fa2bc544898ee9dd2a616068191b03f0
Author: jinhua luo <ho...@163.com>
AuthorDate: Thu Aug 4 19:37:40 2022 +0800

    fix(balancer): quote ipv6 address (#7594)
    
    Fixes #7563
---
 apisix/balancer.lua         |   7 ++
 docs/en/latest/admin-api.md |   2 +-
 docs/zh/latest/admin-api.md |   2 +-
 t/node/upstream-ipv6.t      | 184 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 193 insertions(+), 2 deletions(-)

diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index e0cecdf06..d96b7a2a0 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -26,6 +26,7 @@ local set_more_tries   = balancer.set_more_tries
 local get_last_failure = balancer.get_last_failure
 local set_timeouts     = balancer.set_timeouts
 local ngx_now          = ngx.now
+local str_byte         = string.byte
 
 
 local module_name = "balancer"
@@ -195,6 +196,12 @@ local function pick_server(route, ctx)
     core.log.info("ctx: ", core.json.delay_encode(ctx, true))
     local up_conf = ctx.upstream_conf
 
+    for _, node in ipairs(up_conf.nodes) do
+        if core.utils.parse_ipv6(node.host) and str_byte(node.host, 1) ~= str_byte("[") then
+            node.host = '[' .. node.host .. ']'
+        end
+    end
+
     local nodes_count = #up_conf.nodes
     if nodes_count == 1 then
         local node = up_conf.nodes[1]
diff --git a/docs/en/latest/admin-api.md b/docs/en/latest/admin-api.md
index deaf1c4c7..cb551cd15 100644
--- a/docs/en/latest/admin-api.md
+++ b/docs/en/latest/admin-api.md
@@ -524,7 +524,7 @@ In addition to the equalization algorithm selections, Upstream also supports pas
 | Name                        | Optional                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                    [...]
 | --------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ [...]
 | type                        | required                                    | Load balancing algorithm to be used.                                                                                                                                                                                                                                                                                                                                                                                           [...]
-| nodes                       | required, can't be used with `service_name` | IP addresses (with optional ports) of the Upstream nodes represented as a hash table or an array. In the hash table, the key is the IP address and the value is the weight of the node for the load balancing algorithm. In the array, each item is a hash table with keys `host`, `weight`, and the optional `port` and `priority`. Empty nodes are treated as placeholders and clients trying to access this Upstream will r [...]
+| nodes                       | required, can't be used with `service_name` | IP addresses (with optional ports) of the Upstream nodes represented as a hash table or an array. In the hash table, the key is the IP address and the value is the weight of the node for the load balancing algorithm. For hash table case, if the key is IPv6 address with port, then the IPv6 address must be quoted with square brackets. In the array, each item is a hash table with keys `host`, `weight`, and the opt [...]
 | service_name                | required, can't be used with `nodes`        | Service name used for [service discovery](discovery.md).                                                                                                                                                                                                                                                                                                                                                                       [...]
 | discovery_type              | required, if `service_name` is used         | The type of service [discovery](discovery.md).                                                                                                                                                                                                                                                                                                                                                                                 [...]
 | hash_on                     | optional                                    | Only valid if the `type` is `chash`. Supports Nginx variables (`vars`), custom headers (`header`), `cookie` and `consumer`. Defaults to `vars`.                                                                                                                                                                                                                                                                                [...]
diff --git a/docs/zh/latest/admin-api.md b/docs/zh/latest/admin-api.md
index e5dc14202..0eea807f2 100644
--- a/docs/zh/latest/admin-api.md
+++ b/docs/zh/latest/admin-api.md
@@ -532,7 +532,7 @@ APISIX 的 Upstream 除了基本的负载均衡算法选择外,还支持对上
 | 名字           | 可选项                             | 类型           | 说明                                                                                                                                                                                                                                                                                                                                                        | 示例                                             |
 | -------------- | ---------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
 | type           | 必需                               | 枚举           | 负载均衡算法                                                                                                                                                                                                                                                                                                                                                            |                                      |     |
-| nodes          | 必需,不能和 `service_name` 一起用 | Node           | 哈希表或数组。当它是哈希表时,内部元素的 key 是上游机器地址列表,格式为`地址 +(可选的)端口`,其中地址部分可以是 IP 也可以是域名,比如 `192.168.1.100:80`、`foo.com:80`等。value 则是节点的权重。当它是数组时,数组中每个元素都是一个哈希表,其中包含 `host`、`weight` 以及可选的 `port`、`priority`。`nodes` 可以为空,这通常用作占位符。客户端命中这样的上游会返回 502。                                        | `192.168.1.100:80`                               |
+| nodes          | 必需,不能和 `service_name` 一起用 | Node           | 哈希表或数组。当它是哈希表时,内部元素的 key 是上游机器地址列表,格式为`地址 +(可选的)端口`,其中地址部分可以是 IP 也可以是域名,比如 `192.168.1.100:80`、`foo.com:80`等。对于哈希表的情况,如果 key 是 IPv6 地址加端口,则必须用中括号将 IPv6 地址括起来。value 则是节点的权重。当它是数组时,数组中每个元素都是一个哈希表,其中包含 `host`、`weight` 以及可选的 `port`、`priority`。`nodes` 可以为空,这通常用作占位符。客户端命中这样的上游会返回 502。                                        | `192.168.1.100:80`, `[::1]:80`                               |
 | service_name   | 必需,不能和 `nodes` 一起用        | string         | 服务发现时使用的服务名,见[集成服务发现注册中心](./discovery.md)                                                                                                                                                                                                                                                                                            | `a-bootiful-client`                              |
 | discovery_type | 必需,如果设置了 `service_name`    | string         | 服务发现类型,见 [集成服务发现注册中心](./discovery.md)                                                                                                                                                                                                                                                                                                      | `eureka`                                         |
 | 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) |                                                  |
diff --git a/t/node/upstream-ipv6.t b/t/node/upstream-ipv6.t
index 51d2e8b84..8aa39f6cf 100644
--- a/t/node/upstream-ipv6.t
+++ b/t/node/upstream-ipv6.t
@@ -108,3 +108,187 @@ GET /hello
 hello world
 --- no_error_log
 [error]
+
+
+
+=== TEST 5: set upstream(id: 1)
+--- 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": [
+                        {
+                            "weight": 100,
+                            "priority": 0,
+                            "host": "::1",
+                            "port": 1980
+                        }
+                    ],
+                    "type": "roundrobin",
+                    "desc": "new upstream"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 6: hit routes
+--- request
+GET /hello
+--- response_body
+hello world
+--- no_error_log
+[error]
+
+
+
+=== TEST 7: set upstream, one array item to specify node
+--- 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": [
+                        {
+                            "weight": 100,
+                            "priority": 0,
+                            "host": "[::1]",
+                            "port": 1980
+                        }
+                    ],
+                    "type": "roundrobin",
+                    "desc": "new upstream"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 8: hit routes
+--- request
+GET /hello
+--- response_body
+hello world
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: set upstream, one hash key to specify node, in wrong format
+--- 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": {
+                        "::1:1980": 1
+                    },
+                    "type": "roundrobin",
+                    "desc": "new upstream"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 10: hit routes
+--- request
+GET /hello
+--- error_code: 502
+--- error_log
+connect() to [::0.1.25.128]:80 failed
+
+
+
+=== TEST 11: set upstream, two array items to specify nodes
+--- 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": [
+                        {
+                            "weight": 100,
+                            "priority": 0,
+                            "host": "::1",
+                            "port": 1980
+                        },
+                        {
+                            "weight": 100,
+                            "priority": 0,
+                            "host": "::1",
+                            "port": 1980
+                        }
+                    ],
+                    "type": "roundrobin",
+                    "desc": "new upstream"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 12: hit routes
+--- request
+GET /hello
+--- response_body
+hello world
+--- no_error_log
+[error]


[apisix] 05/18: change: drop support of OpenResty 1.17 (#7625)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 6e2abc39a120e9b526700f43b2b73fad1b9634a9
Author: 罗泽轩 <sp...@gmail.com>
AuthorDate: Mon Aug 8 19:31:57 2022 +0800

    change: drop support of OpenResty 1.17 (#7625)
    
    Discussed in https://lists.apache.org/thread/hvnop89clr0lx4v59gdvos41zcfnqpwq
    Signed-off-by: spacewander <sp...@gmail.com>
---
 .github/workflows/build.yml                        |  2 +-
 .github/workflows/kubernetes-ci.yml                |  2 +-
 .github/workflows/tars-ci.yml                      |  2 +-
 apisix/balancer.lua                                |  4 +-
 apisix/cli/ngx_tpl.lua                             |  2 -
 apisix/cli/ops.lua                                 |  8 +--
 apisix/conf_server.lua                             |  2 +-
 apisix/init.lua                                    |  6 +--
 apisix/upstream.lua                                |  7 ---
 bin/apisix                                         |  6 +--
 ...17_runner.sh => linux_openresty_1_19_runner.sh} |  2 +-
 t/APISIX.pm                                        |  6 ---
 t/admin/upstream4.t                                | 60 ++++++----------------
 t/deployment/conf_server.t                         | 11 +---
 t/deployment/conf_server2.t                        | 11 +---
 ...ls-openresty-1-19.t => client-mtls-openresty.t} |  6 +--
 t/node/upstream.t                                  |  6 ---
 .../{sanity-openresty-1-19.t => sanity2.t}         | 11 +---
 t/plugin/traffic-split2.t                          |  2 -
 t/stream-node/sanity.t                             |  2 -
 utils/linux-install-openresty.sh                   |  2 +-
 21 files changed, 32 insertions(+), 128 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 21d185cbe..287067390 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,7 +28,7 @@ jobs:
           - ubuntu-18.04
         os_name:
           - linux_openresty
-          - linux_openresty_1_17
+          - linux_openresty_1_19
         test_dir:
           - t/plugin
           - t/admin t/cli t/config-center-yaml t/control t/core t/debug t/deployment t/discovery t/error_page t/misc
diff --git a/.github/workflows/kubernetes-ci.yml b/.github/workflows/kubernetes-ci.yml
index 66615cf80..41f3d46e4 100644
--- a/.github/workflows/kubernetes-ci.yml
+++ b/.github/workflows/kubernetes-ci.yml
@@ -28,7 +28,7 @@ jobs:
           - ubuntu-18.04
         os_name:
           - linux_openresty
-          - linux_openresty_1_17
+          - linux_openresty_1_19
 
     runs-on: ${{ matrix.platform }}
     timeout-minutes: 15
diff --git a/.github/workflows/tars-ci.yml b/.github/workflows/tars-ci.yml
index e85044671..8a5f90f8b 100644
--- a/.github/workflows/tars-ci.yml
+++ b/.github/workflows/tars-ci.yml
@@ -28,7 +28,7 @@ jobs:
           - ubuntu-18.04
         os_name:
           - linux_openresty
-          - linux_openresty_1_17
+          - linux_openresty_1_19
 
     runs-on: ${{ matrix.platform }}
     timeout-minutes: 15
diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index d96b7a2a0..462d04f07 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -366,7 +366,7 @@ function _M.run(route, ctx, plugin_funcs)
 
         local header_changed
         local pass_host = ctx.pass_host
-        if pass_host == "node" and balancer.recreate_request then
+        if pass_host == "node" then
             local host = server.upstream_host
             if host ~= ctx.var.upstream_host then
                 -- retried node has a different host
@@ -377,7 +377,7 @@ function _M.run(route, ctx, plugin_funcs)
 
         local _, run = plugin_funcs("before_proxy")
         -- always recreate request as the request may be changed by plugins
-        if (run or header_changed) and balancer.recreate_request then
+        if run or header_changed then
             balancer.recreate_request()
         end
     end
diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua
index 130033be7..b459cd027 100644
--- a/apisix/cli/ngx_tpl.lua
+++ b/apisix/cli/ngx_tpl.lua
@@ -473,11 +473,9 @@ http {
         apisix.http_init_worker()
     }
 
-    {% if not use_openresty_1_17 then %}
     exit_worker_by_lua_block {
         apisix.http_exit_worker()
     }
-    {% end %}
 
     {% if enable_control then %}
     server {
diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua
index d2275bed5..ca091d9c6 100644
--- a/apisix/cli/ops.lua
+++ b/apisix/cli/ops.lua
@@ -235,16 +235,11 @@ Please modify "admin_key" in conf/config.yaml .
         util.die("can not find openresty\n")
     end
 
-    local need_ver = "1.17.8"
+    local need_ver = "1.19.3"
     if not version_greater_equal(or_ver, need_ver) then
         util.die("openresty version must >=", need_ver, " current ", or_ver, "\n")
     end
 
-    local use_openresty_1_17 = false
-    if not version_greater_equal(or_ver, "1.19.3") then
-        use_openresty_1_17 = true
-    end
-
     local or_info = util.execute_cmd("openresty -V 2>&1")
     if or_info and not or_info:find("http_stub_status_module", 1, true) then
         util.die("'http_stub_status_module' module is missing in ",
@@ -551,7 +546,6 @@ Please modify "admin_key" in conf/config.yaml .
 
     -- Using template.render
     local sys_conf = {
-        use_openresty_1_17 = use_openresty_1_17,
         lua_path = env.pkg_path_org,
         lua_cpath = env.pkg_cpath_org,
         os_name = util.trim(util.execute_cmd("uname")),
diff --git a/apisix/conf_server.lua b/apisix/conf_server.lua
index 2d6780bff..e0ea91e77 100644
--- a/apisix/conf_server.lua
+++ b/apisix/conf_server.lua
@@ -237,7 +237,7 @@ local function pick_node(ctx)
     ctx.balancer_port = res.port
 
     ngx_var.upstream_host = res.domain or res.host
-    if balancer.recreate_request and ngx.get_phase() == "balancer" then
+    if ngx.get_phase() == "balancer" then
         balancer.recreate_request()
     end
 
diff --git a/apisix/init.lua b/apisix/init.lua
index 8bb64760d..3e2b11055 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -41,7 +41,6 @@ local apisix_ssl      = require("apisix.ssl")
 local upstream_util   = require("apisix.utils.upstream")
 local xrpc            = require("apisix.stream.xrpc")
 local ctxdump         = require("resty.ctxdump")
-local ngx_balancer    = require("ngx.balancer")
 local debug           = require("apisix.debug")
 local pubsub_kafka    = require("apisix.pubsub.kafka")
 local ngx             = ngx
@@ -219,10 +218,7 @@ local function set_upstream_host(api_ctx, picked_server)
         return
     end
 
-    local nodes_count = up_conf.nodes and #up_conf.nodes or 0
-    if nodes_count == 1 or ngx_balancer.recreate_request then
-        api_ctx.var.upstream_host = picked_server.upstream_host
-    end
+    api_ctx.var.upstream_host = picked_server.upstream_host
 end
 
 
diff --git a/apisix/upstream.lua b/apisix/upstream.lua
index 0162ad813..465098975 100644
--- a/apisix/upstream.lua
+++ b/apisix/upstream.lua
@@ -19,7 +19,6 @@ local core = require("apisix.core")
 local discovery = require("apisix.discovery.init").discovery
 local upstream_util = require("apisix.utils.upstream")
 local apisix_ssl = require("apisix.ssl")
-local balancer = require("ngx.balancer")
 local error = error
 local tostring = tostring
 local ipairs = ipairs
@@ -458,12 +457,6 @@ local function check_upstream_conf(in_dp, conf)
     end
 
     if is_http then
-        if conf.pass_host == "node" and conf.nodes and
-            not balancer.recreate_request and core.table.nkeys(conf.nodes) ~= 1
-        then
-            return false, "only support single node for `node` mode currently"
-        end
-
         if conf.pass_host == "rewrite" and
             (conf.upstream_host == nil or conf.upstream_host == "")
         then
diff --git a/bin/apisix b/bin/apisix
index 4583fd1b5..780764ae9 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -42,10 +42,6 @@ if [[ -e $OR_EXEC && "$OR_VER" -ge 119 ]]; then
     # use the luajit of openresty
     echo "$LUAJIT_BIN $APISIX_LUA $*"
     exec $LUAJIT_BIN $APISIX_LUA $*
-elif [[ "$LUA_VERSION" =~ "Lua 5.1" ]]; then
-    # OpenResty version is < 1.19, use Lua 5.1 by default
-    echo "lua $APISIX_LUA $*"
-    exec lua $APISIX_LUA $*
 else
-    echo "ERROR: Please check the version of OpenResty and Lua, OpenResty 1.19+ + LuaJIT or OpenResty before 1.19 + Lua 5.1 is required for Apache APISIX."
+    echo "ERROR: Please check the version of OpenResty and Lua, OpenResty 1.19+ + LuaJIT is required for Apache APISIX."
 fi
diff --git a/ci/linux_openresty_1_17_runner.sh b/ci/linux_openresty_1_19_runner.sh
similarity index 96%
rename from ci/linux_openresty_1_17_runner.sh
rename to ci/linux_openresty_1_19_runner.sh
index b0cbde775..ed1751308 100755
--- a/ci/linux_openresty_1_17_runner.sh
+++ b/ci/linux_openresty_1_19_runner.sh
@@ -17,5 +17,5 @@
 #
 
 
-export OPENRESTY_VERSION=1.17.8.2
+export OPENRESTY_VERSION=1.19.3.2
 . ./ci/linux_openresty_common_runner.sh
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 62f1904f1..999bcd8a1 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -561,17 +561,11 @@ _EOC_
         require("apisix").http_init_worker()
         $extra_init_worker_by_lua
     }
-_EOC_
 
-    if ($version !~ m/\/1.17.8/) {
-    $http_config .= <<_EOC_;
     exit_worker_by_lua_block {
         require("apisix").http_exit_worker()
     }
-_EOC_
-    }
 
-    $http_config .= <<_EOC_;
     log_format main escape=default '\$remote_addr - \$remote_user [\$time_local] \$http_host "\$request" \$status \$body_bytes_sent \$request_time "\$http_referer" "\$http_user_agent" \$upstream_addr \$upstream_status \$upstream_response_time "\$upstream_scheme://\$upstream_host\$upstream_uri"';
 
     # fake server, only for test
diff --git a/t/admin/upstream4.t b/t/admin/upstream4.t
index 1f55fc92e..7c909e26a 100644
--- a/t/admin/upstream4.t
+++ b/t/admin/upstream4.t
@@ -201,33 +201,7 @@ passed
 
 
 
-=== TEST 7: invalid route: multi nodes with `node` mode to pass host
---- 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": {
-                        "httpbin.org:8080": 1,
-                        "test.com:8080": 1
-                    },
-                    "type": "roundrobin",
-                    "pass_host": "node"
-                }]]
-                )
-
-            ngx.status = code
-            ngx.print(body)
-        }
-    }
---- skip_nginx: 5: > 1.19.0
---- error_code: 400
-
-
-
-=== TEST 8: invalid route: empty `upstream_host` when `pass_host` is `rewrite`
+=== TEST 7: invalid route: empty `upstream_host` when `pass_host` is `rewrite`
 --- config
     location /t {
         content_by_lua_block {
@@ -253,7 +227,7 @@ passed
 
 
 
-=== TEST 9: set upstream(with labels)
+=== TEST 8: set upstream(with labels)
 --- config
     location /t {
         content_by_lua_block {
@@ -299,7 +273,7 @@ passed
 
 
 
-=== TEST 10: get upstream(with labels)
+=== TEST 9: get upstream(with labels)
 --- config
     location /t {
         content_by_lua_block {
@@ -335,7 +309,7 @@ passed
 
 
 
-=== TEST 11: patch upstream(only labels)
+=== TEST 10: patch upstream(only labels)
 --- config
     location /t {
         content_by_lua_block {
@@ -375,7 +349,7 @@ passed
 
 
 
-=== TEST 12: invalid format of label value: set upstream
+=== TEST 11: invalid format of label value: set upstream
 --- config
     location /t {
         content_by_lua_block {
@@ -403,7 +377,7 @@ passed
 
 
 
-=== TEST 13: patch upstream(whole, create_time)
+=== TEST 12: patch upstream(whole, create_time)
 --- config
     location /t {
         content_by_lua_block {
@@ -453,7 +427,7 @@ passed
 
 
 
-=== TEST 14: patch upstream(whole, update_time)
+=== TEST 13: patch upstream(whole, update_time)
 --- config
     location /t {
         content_by_lua_block {
@@ -503,7 +477,7 @@ passed
 
 
 
-=== TEST 15: create upstream with create_time and update_time
+=== TEST 14: create upstream with create_time and update_time
 --- config
     location /t {
         content_by_lua_block {
@@ -543,7 +517,7 @@ passed
 
 
 
-=== TEST 16: delete test upstream
+=== TEST 15: delete test upstream
 --- config
     location /t {
         content_by_lua_block {
@@ -563,7 +537,7 @@ passed
 
 
 
-=== TEST 17: patch upstream with sub_path, the data is number
+=== TEST 16: patch upstream with sub_path, the data is number
 --- config
     location /t {
         content_by_lua_block {
@@ -606,7 +580,7 @@ passed
 
 
 
-=== TEST 18: set upstream(id: 1)
+=== TEST 17: set upstream(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -630,7 +604,7 @@ passed
 
 
 
-=== TEST 19: set service(id: 1)
+=== TEST 18: set service(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -653,7 +627,7 @@ passed
 
 
 
-=== TEST 20: set route(id: 1)
+=== TEST 19: set route(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -677,7 +651,7 @@ passed
 
 
 
-=== TEST 21: delete upstream(id: 1)
+=== TEST 20: delete upstream(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -696,7 +670,7 @@ passed
 
 
 
-=== TEST 22: delete route(id: 1)
+=== TEST 21: delete route(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -715,7 +689,7 @@ passed
 
 
 
-=== TEST 23: delete service(id: 1)
+=== TEST 22: delete service(id: 1)
 --- config
     location /t {
         content_by_lua_block {
@@ -734,7 +708,7 @@ passed
 
 
 
-=== TEST 24: delete upstream(id: 1)
+=== TEST 23: delete upstream(id: 1)
 --- config
     location /t {
         content_by_lua_block {
diff --git a/t/deployment/conf_server.t b/t/deployment/conf_server.t
index 4943c78e4..ee5234664 100644
--- a/t/deployment/conf_server.t
+++ b/t/deployment/conf_server.t
@@ -14,16 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-use t::APISIX;
-
-my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx';
-my $version = eval { `$nginx_binary -V 2>&1` };
-
-if ($version =~ m/\/1.17.8/) {
-    plan(skip_all => "require OpenResty 1.19+");
-} else {
-    plan('no_plan');
-}
+use t::APISIX 'no_plan';
 
 add_block_preprocessor(sub {
     my ($block) = @_;
diff --git a/t/deployment/conf_server2.t b/t/deployment/conf_server2.t
index d0dda360e..c9eb0ac9c 100644
--- a/t/deployment/conf_server2.t
+++ b/t/deployment/conf_server2.t
@@ -14,16 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-use t::APISIX;
-
-my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx';
-my $version = eval { `$nginx_binary -V 2>&1` };
-
-if ($version =~ m/\/1.17.8/) {
-    plan(skip_all => "require OpenResty 1.19+");
-} else {
-    plan('no_plan');
-}
+use t::APISIX 'no_plan';
 
 add_block_preprocessor(sub {
     my ($block) = @_;
diff --git a/t/node/client-mtls-openresty-1-19.t b/t/node/client-mtls-openresty.t
similarity index 96%
rename from t/node/client-mtls-openresty-1-19.t
rename to t/node/client-mtls-openresty.t
index a7bf517c1..7b388932d 100644
--- a/t/node/client-mtls-openresty-1-19.t
+++ b/t/node/client-mtls-openresty.t
@@ -20,11 +20,7 @@ my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx';
 my $version = eval { `$nginx_binary -V 2>&1` };
 
 if ($version !~ m/\/apisix-nginx-module/) {
-    if ($version =~ m/\/1.17.8/) {
-        plan(skip_all => "require OpenResty 1.19+");
-    } else {
-        plan('no_plan');
-    }
+    plan('no_plan');
 } else {
     plan(skip_all => "for vanilla OpenResty only");
 }
diff --git a/t/node/upstream.t b/t/node/upstream.t
index 70da36145..f8623eb96 100644
--- a/t/node/upstream.t
+++ b/t/node/upstream.t
@@ -436,7 +436,6 @@ GET /t
     }
 --- request
 GET /t
---- skip_nginx: 5: < 1.19.0
 --- response_body
 passed
 --- no_error_log
@@ -447,7 +446,6 @@ passed
 === TEST 18: hit route
 --- request
 GET /uri
---- skip_nginx: 5: < 1.19.0
 --- response_body eval
 qr/host: 127.0.0.1/
 --- error_log
@@ -494,7 +492,6 @@ proxy request to 127.0.0.1:1980
     }
 --- request
 GET /t
---- skip_nginx: 5: < 1.19.0
 --- response_body
 passed
 --- no_error_log
@@ -505,7 +502,6 @@ passed
 === TEST 20: hit route
 --- request
 GET /uri
---- skip_nginx: 5: < 1.19.0
 --- response_body eval
 qr/host: localhost/
 --- error_log
@@ -607,7 +603,6 @@ qr/host: localhost:1980/
             ngx.say(body)
         }
     }
---- skip_nginx: 5: < 1.19.0
 --- request
 GET /t
 --- response_body
@@ -619,7 +614,6 @@ passed
 
 === TEST 24: hit route
 --- log_level: debug
---- skip_nginx: 5: < 1.19.0
 --- request
 GET /uri
 --- error_log
diff --git a/t/plugin/ext-plugin/sanity-openresty-1-19.t b/t/plugin/ext-plugin/sanity2.t
similarity index 86%
rename from t/plugin/ext-plugin/sanity-openresty-1-19.t
rename to t/plugin/ext-plugin/sanity2.t
index c33d86e00..206e7b090 100644
--- a/t/plugin/ext-plugin/sanity-openresty-1-19.t
+++ b/t/plugin/ext-plugin/sanity2.t
@@ -14,16 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-use t::APISIX;
-
-my $nginx_binary = $ENV{'TEST_NGINX_BINARY'} || 'nginx';
-my $version = eval { `$nginx_binary -V 2>&1` };
-
-if ($version =~ m/\/1.17.8/) {
-    plan(skip_all => "require OpenResty 1.19+");
-} else {
-    plan('no_plan');
-}
+use t::APISIX 'no_plan';
 
 repeat_each(1);
 no_long_string();
diff --git a/t/plugin/traffic-split2.t b/t/plugin/traffic-split2.t
index 41bee399d..c41886283 100644
--- a/t/plugin/traffic-split2.t
+++ b/t/plugin/traffic-split2.t
@@ -744,7 +744,6 @@ qr/1980, 1981, 1982, 1980, 1981, 1982, 1980, 1981, 1982/
             ngx.say(body)
         }
     }
---- skip_nginx: 5: < 1.19.0
 --- response_body
 passed
 
@@ -753,7 +752,6 @@ passed
 === TEST 19: hit route
 --- request
 GET /uri?id=1
---- skip_nginx: 5: < 1.19.0
 --- response_body eval
 qr/host: 127.0.0.1/
 --- error_log
diff --git a/t/stream-node/sanity.t b/t/stream-node/sanity.t
index f42b89ca9..06e809dfd 100644
--- a/t/stream-node/sanity.t
+++ b/t/stream-node/sanity.t
@@ -373,7 +373,6 @@ GET /t
 passed
 --- no_error_log
 [error]
---- skip_nginx: 5: < 1.19.0
 
 
 
@@ -384,7 +383,6 @@ mmm
 hello world
 --- no_error_log
 [error]
---- skip_nginx: 5: < 1.19.0
 
 
 
diff --git a/utils/linux-install-openresty.sh b/utils/linux-install-openresty.sh
index 7498da3ab..c97454e3e 100755
--- a/utils/linux-install-openresty.sh
+++ b/utils/linux-install-openresty.sh
@@ -48,4 +48,4 @@ else
     openresty="openresty-debug=$OPENRESTY_VERSION*"
 fi
 
-sudo apt-get install "$openresty" lua5.1 liblua5.1-0-dev openresty-openssl111-debug-dev libldap2-dev
+sudo apt-get install "$openresty" openresty-openssl111-debug-dev libldap2-dev


[apisix] 14/18: fix: use modifiedIndex as lru key when merge plugins from route and consumer (#7965)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 70457ba28e8f736f938eccc9e8adde10d13e194c
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Thu Sep 22 15:15:56 2022 +0800

    fix: use modifiedIndex as lru key when merge plugins from route and consumer (#7965)
    
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/consumer.lua       |   1 +
 apisix/plugin.lua         |   3 +-
 t/node/consumer-plugin2.t | 132 ++++++++++++++++++++++++++++++++++++++++++++++
 t/node/plugin-configs.t   | 102 +++++++++++++++++++++++++++++++++++
 4 files changed, 237 insertions(+), 1 deletion(-)

diff --git a/apisix/consumer.lua b/apisix/consumer.lua
index 9a4dc3c42..5e25b7521 100644
--- a/apisix/consumer.lua
+++ b/apisix/consumer.lua
@@ -56,6 +56,7 @@ local function plugin_consumer()
                 -- is 'username' field in admin
                 new_consumer.consumer_name = new_consumer.id
                 new_consumer.auth_conf = config
+                new_consumer.modifiedIndex = consumer.modifiedIndex
                 core.log.info("consumer:", core.json.delay_encode(new_consumer))
                 core.table.insert(plugins[name].nodes, new_consumer)
             end
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index a624a5696..2e6758efb 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -628,7 +628,8 @@ function _M.merge_consumer_route(route_conf, consumer_conf, api_ctx)
     core.log.info("route conf: ", core.json.delay_encode(route_conf))
     core.log.info("consumer conf: ", core.json.delay_encode(consumer_conf))
 
-    local flag = tostring(route_conf) .. tostring(consumer_conf)
+    local flag = route_conf.value.id .. "#" .. route_conf.modifiedIndex
+                 .. "#" .. consumer_conf.id .. "#" .. consumer_conf.modifiedIndex
     local new_conf = merged_route(flag, nil,
                         merge_consumer_route, route_conf, consumer_conf)
 
diff --git a/t/node/consumer-plugin2.t b/t/node/consumer-plugin2.t
index c05762f40..64c3869bc 100644
--- a/t/node/consumer-plugin2.t
+++ b/t/node/consumer-plugin2.t
@@ -303,3 +303,135 @@ apikey: auth-jack
 --- error_code: 403
 --- response_body
 {"message":"Your IP address is not allowed"}
+
+
+
+=== TEST 9: use the latest consumer modifiedIndex as lrucache key
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/consumers',
+                ngx.HTTP_PUT,
+                [[{
+                    "username": "foo",
+                    "plugins": {
+                        "basic-auth": {
+                            "username": "foo",
+                            "password": "bar"
+                        }
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "ip-restriction": {
+                            "whitelist": ["1.1.1.1"]
+                        },
+                        "basic-auth": {}
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugin_config_id": "1",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uris": ["/hello"]
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+            ngx.sleep(0.5)
+
+            local http = require "resty.http"
+            local httpc = http.new()
+            local uri = "http://127.0.0.1:" .. ngx.var.server_port
+                        .. "/hello"
+            local headers = {
+                ["Authorization"] = "Basic Zm9vOmJhcg=="
+            }
+            local res, err = httpc:request_uri(uri, {headers = headers})
+            ngx.print(res.body)
+
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "ip-restriction": {
+                            "whitelist": ["1.1.1.1", "127.0.0.1"]
+                        },
+                        "basic-auth": {}
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+            ngx.sleep(0.5)
+
+            local res, err = httpc:request_uri(uri, {headers = headers})
+            if not res then
+                ngx.say(err)
+                return
+            end
+            ngx.print(res.body)
+
+            local code, body = t('/apisix/admin/consumers',
+                ngx.HTTP_PUT,
+                [[{
+                    "username": "foo",
+                    "plugins": {
+                        "basic-auth": {
+                            "username": "foo",
+                            "password": "bala"
+                        }
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+            ngx.sleep(0.5)
+
+            local headers = {
+                ["Authorization"] = "Basic Zm9vOmJhbGE="
+            }
+            local res, err = httpc:request_uri(uri, {headers = headers})
+            if not res then
+                ngx.say(err)
+                return
+            end
+            ngx.print(res.body)
+        }
+    }
+--- response_body
+{"message":"Your IP address is not allowed"}
+hello world
+hello world
diff --git a/t/node/plugin-configs.t b/t/node/plugin-configs.t
index 770392276..837bb6a52 100644
--- a/t/node/plugin-configs.t
+++ b/t/node/plugin-configs.t
@@ -249,3 +249,105 @@ property "block_rules" validation failed
 --- response_body
 hello
 hello world
+
+
+
+=== TEST 5: use the latest plugin_consigs after merge the plugins from consumer and route
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/consumers',
+                ngx.HTTP_PUT,
+                [[{
+                    "username": "foo",
+                    "plugins": {
+                        "basic-auth": {
+                            "username": "foo",
+                            "password": "bar"
+                        }
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "ip-restriction": {
+                            "whitelist": ["1.1.1.1"]
+                        },
+                        "basic-auth": {}
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugin_config_id": "1",
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uris": ["/hello"]
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+            ngx.sleep(0.5)
+
+            local http = require "resty.http"
+            local httpc = http.new()
+            local uri = "http://127.0.0.1:" .. ngx.var.server_port
+                        .. "/hello"
+            local headers = {
+                ["Authorization"] = "Basic Zm9vOmJhcg=="
+            }
+            local res, err = httpc:request_uri(uri, {headers = headers})
+            ngx.print(res.body)
+
+            local code, body = t('/apisix/admin/plugin_configs/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "ip-restriction": {
+                            "whitelist": ["1.1.1.1", "127.0.0.1"]
+                        },
+                        "basic-auth": {}
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+            ngx.sleep(0.5)
+
+            local res, err = httpc:request_uri(uri, {headers = headers})
+            if not res then
+                ngx.say(err)
+                return
+            end
+            ngx.print(res.body)
+        }
+    }
+--- response_body
+{"message":"Your IP address is not allowed"}
+hello world


[apisix] 06/18: ci: update Ubuntu to 20.04 as 18.04 was deprecated (#7766)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit f16bcd60b8130525e056ad2eb983bc4c8b9f8900
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Tue Aug 23 09:47:32 2022 +0800

    ci: update Ubuntu to 20.04 as 18.04 was deprecated (#7766)
---
 .github/workflows/build.yml         | 2 +-
 .github/workflows/cli-master.yml    | 2 +-
 .github/workflows/cli.yml           | 2 +-
 .github/workflows/kubernetes-ci.yml | 2 +-
 .github/workflows/performance.yml   | 2 +-
 .github/workflows/tars-ci.yml       | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 287067390..e4bcb4323 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,7 +25,7 @@ jobs:
       fail-fast: false
       matrix:
         platform:
-          - ubuntu-18.04
+          - ubuntu-20.04
         os_name:
           - linux_openresty
           - linux_openresty_1_19
diff --git a/.github/workflows/cli-master.yml b/.github/workflows/cli-master.yml
index 58a34d8b1..fc6b76c26 100644
--- a/.github/workflows/cli-master.yml
+++ b/.github/workflows/cli-master.yml
@@ -26,7 +26,7 @@ jobs:
       matrix:
         job_name:
           - linux_apisix_master_luarocks
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     timeout-minutes: 15
     env:
       OPENRESTY_VERSION: default
diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml
index 342da39b2..3582d7618 100644
--- a/.github/workflows/cli.yml
+++ b/.github/workflows/cli.yml
@@ -25,7 +25,7 @@ jobs:
       fail-fast: false
       matrix:
         platform:
-          - ubuntu-18.04
+          - ubuntu-20.04
         job_name:
           - linux_apisix_current_luarocks
           - linux_apisix_current_luarocks_in_customed_nginx
diff --git a/.github/workflows/kubernetes-ci.yml b/.github/workflows/kubernetes-ci.yml
index 41f3d46e4..9800e681f 100644
--- a/.github/workflows/kubernetes-ci.yml
+++ b/.github/workflows/kubernetes-ci.yml
@@ -25,7 +25,7 @@ jobs:
       fail-fast: false
       matrix:
         platform:
-          - ubuntu-18.04
+          - ubuntu-20.04
         os_name:
           - linux_openresty
           - linux_openresty_1_19
diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml
index 0f022df60..786c43362 100644
--- a/.github/workflows/performance.yml
+++ b/.github/workflows/performance.yml
@@ -13,7 +13,7 @@ permissions:
 jobs:
   performance:
     if: github.event_name == 'pull_request' && github.event.label.name == 'performance'
-    runs-on: ubuntu-18.04
+    runs-on: ubuntu-20.04
     timeout-minutes: 45
 
     steps:
diff --git a/.github/workflows/tars-ci.yml b/.github/workflows/tars-ci.yml
index 8a5f90f8b..79b695862 100644
--- a/.github/workflows/tars-ci.yml
+++ b/.github/workflows/tars-ci.yml
@@ -25,7 +25,7 @@ jobs:
       fail-fast: false
       matrix:
         platform:
-          - ubuntu-18.04
+          - ubuntu-20.04
         os_name:
           - linux_openresty
           - linux_openresty_1_19


[apisix] 15/18: fix: meta.filter in plugin doesn't work in response-rewrite plugin (#8162)

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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit e262a90004aa238c9dd8710469dedd377037e540
Author: soulbird <zh...@outlook.com>
AuthorDate: Fri Oct 28 14:24:18 2022 +0800

    fix: meta.filter in plugin doesn't work in response-rewrite plugin (#8162)
    
    Co-authored-by: soulbird <zh...@gmail.com>
    Signed-off-by: spacewander <sp...@gmail.com>
---
 apisix/plugin.lua |  38 ++++++++--
 t/plugin/plugin.t | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 244 insertions(+), 6 deletions(-)

diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index 2e6758efb..511fbc605 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -76,6 +76,21 @@ local function custom_sort_plugin(l, r)
     return l._meta.priority > r._meta.priority
 end
 
+local function check_disable(plugin_conf)
+    if not plugin_conf then
+        return nil
+    end
+
+    if not plugin_conf._meta then
+       return nil
+    end
+
+    if type(plugin_conf._meta) ~= "table" then
+        return nil
+    end
+
+    return plugin_conf._meta.disable
+end
 
 local PLUGIN_TYPE_HTTP = 1
 local PLUGIN_TYPE_STREAM = 2
@@ -391,6 +406,13 @@ local function meta_filter(ctx, plugin_name, plugin_conf)
         return true
     end
 
+    local match_cache_key =
+        ctx.conf_type .. "#" .. ctx.conf_id .. "#"
+            .. ctx.conf_version .. "#" .. plugin_name .. "#meta_filter_matched"
+    if ctx[match_cache_key] ~= nil then
+        return ctx[match_cache_key]
+    end
+
     local ex, ok, err
     if ctx then
         ex, err = expr_lrucache(plugin_name .. ctx.conf_type .. ctx.conf_id,
@@ -409,6 +431,8 @@ local function meta_filter(ctx, plugin_name, plugin_conf)
                          " plugin_name: ", plugin_name)
         return true
     end
+
+    ctx[match_cache_key] = ok
     return ok
 end
 
@@ -433,8 +457,7 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             goto continue
         end
 
-        local matched = meta_filter(ctx, name, plugin_conf)
-        if not plugin_conf.disable and matched then
+        if not check_disable(plugin_conf) then
             if plugin_obj.run_policy == "prefer_route" and route_plugin_conf ~= nil then
                 local plugin_conf_in_route = route_plugin_conf[name]
                 if plugin_conf_in_route and not plugin_conf_in_route.disable then
@@ -897,8 +920,12 @@ function _M.run_plugin(phase, plugins, api_ctx)
             end
 
             if phase_func then
-                plugin_run = true
                 local conf = plugins[i + 1]
+                if not meta_filter(api_ctx, plugins[i]["name"], conf)then
+                    goto CONTINUE
+                end
+
+                plugin_run = true
                 local code, body = phase_func(conf, api_ctx)
                 if code or body then
                     if is_http then
@@ -931,9 +958,10 @@ function _M.run_plugin(phase, plugins, api_ctx)
 
     for i = 1, #plugins, 2 do
         local phase_func = plugins[i][phase]
-        if phase_func then
+        local conf = plugins[i + 1]
+        if phase_func and meta_filter(api_ctx, plugins[i]["name"], conf) then
             plugin_run = true
-            phase_func(plugins[i + 1], api_ctx)
+            phase_func(conf, api_ctx)
         end
     end
 
diff --git a/t/plugin/plugin.t b/t/plugin/plugin.t
index 755294868..248688050 100644
--- a/t/plugin/plugin.t
+++ b/t/plugin/plugin.t
@@ -520,8 +520,218 @@ passed
 
 
 
-=== TEST 18: hit route: run proxy-rewrite plugin
+=== TEST 18: hit route: run global proxy-rewrite plugin
 --- request
 GET /hello1?version=v4
 --- response_headers
 x-api-version: v4
+
+
+
+=== TEST 19: different global_rules with the same plugin will not use the same meta.filter cache
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/global_rules/3',
+                ngx.HTTP_PUT,
+                {
+                    plugins = {
+                        ["proxy-rewrite"] = {
+                            _meta = {
+                                filter = {
+                                    {"arg_version", "==", "v5"}
+                                }
+                            },
+                            uri = "/echo",
+                            headers = {
+                                ["X-Api-Version"] = "v5"
+                            }
+                        }
+                    }
+                }
+            )
+            if code >= 300 then
+                ngx.print(body)
+            else
+                ngx.say(body)
+            end
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 20: hit global_rules which has the same plugin with different meta.filter
+--- pipelined_requests eval
+["GET /hello1?version=v4", "GET /hello1?version=v5"]
+--- response_headers eval
+["x-api-version: v4", "x-api-version: v5"]
+
+
+
+=== TEST 21: use _meta.filter in response-rewrite plugin
+--- 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,
+                 [[{
+                        "plugins": {
+                            "response-rewrite": {
+                                "_meta": {
+                                    "filter": [
+                                        ["upstream_status", "~=", 200]
+                                    ]
+                                },
+                                "headers": {
+                                    "test-header": "error"
+                                }
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/*"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 22: upstream_status = 502, enable response-rewrite plugin
+--- request
+GET /specific_status
+--- more_headers
+x-test-upstream-status: 502
+--- response_headers
+test-header: error
+--- error_code: 502
+
+
+
+=== TEST 23: upstream_status = 200, disable response-rewrite plugin
+--- request
+GET /hello
+--- response_headers
+!test-header
+
+
+
+=== TEST 24: use _meta.filter in response-rewrite plugin
+--- 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,
+                 [[{
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "headers": {
+                                    "foo-age": "$arg_age"
+                                }
+                            },
+                            "response-rewrite": {
+                                "_meta": {
+                                    "filter": [
+                                        ["http_foo_age", "==", "18"]
+                                    ]
+                                },
+                               "status_code": 403
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/*"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 25: proxy-rewrite plugin will set $http_foo_age, response-rewrite plugin return 403
+--- request
+GET /hello?age=18
+--- error_code: 403
+
+
+
+=== TEST 26: response-rewrite plugin disable, return 200
+--- request
+GET /hello
+
+
+
+=== TEST 27: use response var in meta.filter
+--- 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,
+                 [[{
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "_meta": {
+                                    "filter": [
+                                        ["upstream_status", "==", "200"]
+                                    ]
+                                },
+                                "uri": "/echo",
+                                "headers": {
+                                    "x-version": "v1"
+                                }
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/*"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 28: hit route: disable proxy-rewrite plugin
+--- request
+GET /hello
+--- response_headers
+!x-version


[apisix] 01/18: 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.15
in repository https://gitbox.apache.org/repos/asf/apisix.git

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

    chore: upgrade lua-resty-etcd to 1.8.3 (#7565)
---
 rockspec/apisix-master-0.rockspec | 2 +-
 t/deployment/conf_server.t        | 4 ----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec
index bb0b39e29..e012abd72 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",
diff --git a/t/deployment/conf_server.t b/t/deployment/conf_server.t
index 7b06cf09d..4943c78e4 100644
--- a/t/deployment/conf_server.t
+++ b/t/deployment/conf_server.t
@@ -124,8 +124,6 @@ deployment:
             - http://[::1]:2379
 --- error_log
 dns resolve localhost, result:
---- no_error_log
-[error]
 --- response_body
 foo
 
@@ -236,8 +234,6 @@ OK
 --- error_log
 x.com is resolved to: 127.0.0.3
 x.com is resolved to: 127.0.0.2
---- no_error_log
-[error]