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/12/13 06:06:40 UTC

[apisix] branch master updated: feat: support resolve upstream host in stream subsystem (#8500)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ad581958d feat: support resolve upstream host in stream subsystem (#8500)
ad581958d is described below

commit ad581958dddb5f3941a7e53fce9a1e8692c31593
Author: tzssangglass <tz...@gmail.com>
AuthorDate: Tue Dec 13 14:06:33 2022 +0800

    feat: support resolve upstream host in stream subsystem (#8500)
    
    Fixes https://github.com/apache/apisix/issues/7733
---
 rockspec/apisix-master-0.rockspec |  2 +-
 t/cli/test_dns.sh                 | 47 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec
index 5f558b82a..9507002ed 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -32,7 +32,7 @@ description = {
 
 dependencies = {
     "lua-resty-ctxdump = 0.1-0",
-    "lua-resty-dns-client = 6.0.2",
+    "api7-lua-resty-dns-client = 7.0.1",
     "lua-resty-template = 2.0",
     "lua-resty-etcd = 1.10.1",
     "api7-lua-resty-http = 0.2.0",
diff --git a/t/cli/test_dns.sh b/t/cli/test_dns.sh
index 7c656f72f..cb8f8eaee 100755
--- a/t/cli/test_dns.sh
+++ b/t/cli/test_dns.sh
@@ -123,3 +123,50 @@ if grep "fe80::21c:42ff:fe00:18%eth0" conf/nginx.conf > /dev/null; then
 fi
 
 echo "passed: check dns resolver"
+
+# dns resolver in stream subsystem
+rm logs/error.log || true
+
+echo "
+apisix:
+    enable_admin: true
+    stream_proxy:
+        tcp:
+            - addr: 9100
+    dns_resolver:
+        - 127.0.0.1:1053
+nginx_config:
+    error_log_level: info
+" > conf/config.yaml
+
+make run
+sleep 0.5
+
+curl -v -k -i -m 20 -o /dev/null -s -X PUT http://127.0.0.1:9180/apisix/admin/stream_routes/1 \
+    -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
+    -d '{
+        "upstream": {
+            "type": "roundrobin",
+            "nodes": [{
+                "host": "sd.test.local",
+                "port": 1995,
+                "weight": 1
+            }]
+        }
+    }'
+
+curl http://127.0.0.1:9100 || true
+make stop
+sleep 0.1 # wait for logs output
+
+if grep -E 'dns client error: 101 empty record received while prereading client data' logs/error.log; then
+    echo "failed: resolve upstream host in stream subsystem should works fine"
+    exit 1
+fi
+
+if ! grep -E 'dns resolver domain: sd.test.local to 127.0.0.(1|2) while prereading client data' logs/error.log; then
+    echo "failed: resolve upstream host in preread phase should works fine"
+    exit 1
+fi
+
+echo "success: resolve upstream host in stream subsystem works fine"