RalapZ opened a new issue #5276:
URL: https://github.com/apache/apisix/issues/5276


   ### Issue description
   
   demand:
        x-ak-request-id:10008  forward to two 
nodes(10.49.0.248:22;10.49.1.114:22)
        x-ak-request-id:10009  forward to two 
nodes(10.49.0.248:2379;10.49.1.114:2379)
   
   configuration:
       "plugins": {
       "traffic-split": {
         "disable": false,
         "rules": [
           {
             "match": [
               {
                 "vars": [
                   [
                     "http_x_ak_request_id",
                     "==",
                     "10008"
                   ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {
                 "upstream": {
                   "hash_on": "vars",
                   "name": "upstream_B",
                   "nodes": [
                     {
                       "host": "10.49.0.248",
                       "port": 22,
                       "weight": 10
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 22,
                       "weight": 10
                     }
                   ],
                   "pass_host": "pass",
                   "scheme": "http",
                   "type": "roundrobin"
                 },
                 "weight": 1
               }
             ]
           },
           {
             "match": [
               {
                 "vars": [
                   [
                     "http_x_ak_request_id",
                     "==",
                     "10009"
                   ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {
                 "upstream": {
                   "hash_on": "vars",
                   "name": "upstream_B",
                   "nodes": [
                     {
                       "host": "10.49.0.248",
                       "port": 2379,
                       "weight": 10
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 2379,
                       "weight": 10
                     }
                   ],
                   "pass_host": "pass",
                   "scheme": "http",
                   "type": "roundrobin"
                 },
                 "weight": 1
               }
             ]
           }
         ]
       }
     },
   
   result:
         "x-ak-request-id:   10008 " has been forward to two 
nodes(10.49.0.248:2379;10.49.1.114:2379)
   
   logs:
   
   {"datetime":"19/Oct/2021:08:04:00 +0800","remote_addr": 
"10.49.0.248","upstream_addr": "10.49.0.248:2379","http_host": 
"myzone.ak.xyz","request_method": "GET","http_referer": "-","req_id": 
"10009","company_id": "-","zid": "-","status": "404","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "19","upstream_response_time": "0.000","request_time": 
"0.001"}
   {"datetime":"19/Oct/2021:08:04:20 +0800","remote_addr": 
"10.49.0.248","upstream_addr": "10.49.1.114:2379","http_host": 
"myzone.ak.xyz","request_method": "GET","http_referer": "-","req_id": 
"10008","company_id": "-","zid": "-","status": "404","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "19","upstream_response_time": "0.000","request_time": 
"0.001"}
   
       
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):2.8
   - OS (cmd: `uname -a`): Linux apisix-preprd-10-49-0-248.qcd.ak.lan 
3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 
x86_64 GNU/Linux 
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):nginx 
version: openresty/1.19.3.1
   - etcd version, if have (cmd: run `curl 
http://127.0.0.1:9090/v1/server_info` to get the info from server-info 
API):{"boot_time":1628073527,"hostname":"apisix-preprd-10-49-0-248.qcd.ak.lan","up_time":6528500,"last_report_time":1634602002,"version":"2.8","etcd_version":"3.4.0","id":"2780f743-e456-44d5-ba43-6ac3577be82b"}
   - apisix-dashboard version, if have:  2.6
   - the plugin runner version, if the issue is about a plugin runner (cmd: 
depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks 
--version`):/usr/local/bin/luarocks 3.4.0
   
   
   ### Steps to reproduce
   
   configuration
   {
     "uris": [
       "/*"
     ],
     "name": "test",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "hosts": [
       "myzone.ak.xyz"
     ],
     "plugins": {
       "traffic-split": {
         "disable": false,
         "rules": [
           {
             "match": [
               {
                 "vars": [
                   [
                     "http_x_ak_request_id",
                     "==",
                     "10008"
                   ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {
                 "upstream": {
                   "hash_on": "vars",
                   "name": "upstream_B",
                   "nodes": [
                     {
                       "host": "10.49.0.248",
                       "port": 22,
                       "weight": 10
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 22,
                       "weight": 10
                     }
                   ],
                   "pass_host": "pass",
                   "scheme": "http",
                   "type": "roundrobin"
                 },
                 "weight": 1
               }
             ]
           },
           {
             "match": [
               {
                 "vars": [
                   [
                     "http_x_ak_request_id",
                     "==",
                     "10009"
                   ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {
                 "upstream": {
                   "hash_on": "vars",
                   "name": "upstream_B",
                   "nodes": [
                     {
                       "host": "10.49.0.248",
                       "port": 2379,
                       "weight": 10
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 2379,
                       "weight": 10
                     }
                   ],
                   "pass_host": "pass",
                   "scheme": "http",
                   "type": "roundrobin"
                 },
                 "weight": 1
               }
             ]
           }
         ]
       }
     },
     "upstream": {
       "nodes": [
         {
           "host": "10.49.8.11",
           "port": 655,
           "weight": 10
         }
       ],
       "timeout": {
         "connect": 6,
         "read": 6,
         "send": 6
       },
       "type": "roundrobin",
       "scheme": "http",
       "pass_host": "pass"
     },
     "status": 1
   }
   
   
   
   
   
   
   request methods:
   curl myzone.ak.xyz -H "x-ak-request-id:10008"
   curl myzone.ak.xyz -H "x-ak-request-id:10009"
   
   ### Actual result
   
   {"datetime":"19/Oct/2021:08:11:15 +0800","remote_addr": 
"10.49.0.248","upstream_addr": "10.49.0.248:2379","http_host": 
"myzone.ak.xyz","request_method": "GET","http_referer": "-","req_id": 
"10008","company_id": "-","zid": "-","status": "404","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "19","upstream_response_time": "0.000","request_time": 
"0.001"}
   {"datetime":"19/Oct/2021:08:11:33 +0800","remote_addr": 
"10.49.0.248","http_host": "myzone.ak.xyz","upstream_addr": 
"10.49.0.248:22","request_method": "GET","http_referer": "-","req_id": 
"10008","company_id": "-","zid": "-","status": "009","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "0","upstream_response_time": "0.008","request_time": 
"0.009"}
   
   ### Error log
   
   {"datetime":"19/Oct/2021:08:11:15 +0800","remote_addr": 
"10.49.0.248","upstream_addr": "10.49.0.248:2379","http_host": 
"myzone.ak.xyz","request_method": "GET","http_referer": "-","req_id": 
"10008","company_id": "-","zid": "-","status": "404","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "19","upstream_response_time": "0.000","request_time": 
"0.001"}
   
   ### Expected result
   
   {"datetime":"19/Oct/2021:08:11:33 +0800","remote_addr": 
"10.49.0.248","http_host": "myzone.ak.xyz","upstream_addr": 
"10.49.0.248:22","request_method": "GET","http_referer": "-","req_id": 
"10008","company_id": "-","zid": "-","status": "009","server_name": 
"_","request_uri": "/","http_user_agent": "curl/7.29.0","http_x_forwarded_for": 
"-","body_bytes_sent": "0","upstream_response_time": "0.008","request_time": 
"0.009"}


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to