You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/10/19 00:13:47 UTC

[GitHub] [apisix] RalapZ opened a new issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ edited a comment on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ edited a comment on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946739822


   > we have test cases covering this case:
   > 
   > https://github.com/apache/apisix/blob/50fed630823bb3c562f411d7cb5f5d38218348fb/t/plugin/traffic-split2.t#L593-L710
   > 
   > > {"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"}
   > 
   > What kind of log is this? And according to the logs I found some suspicions:
   > 
   > the matching conditions are
   > 
   > ```
   > [
   > "http_x_ak_request_id",
   > "==",
   > "10008"
   > ]
   > ```
   > 
   > but the header in request is `req_id`? `http_x_ak_request_id` match the `x-ak-request-id` in header, take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   
   >this is log format  
   
   >>access_log_format: '{"datetime":"$time_local","remote_addr": "$remote_addr","http_host": "$http_host","upstream_addr": "$upstream_addr","request_method": "$request_method","http_referer": "$http_referer","req_id": "$http_x_ak_request_id","company_id": "$http_x_ak_company_id","zid": "$http_zid","status": "$status","server_name": "$server_name","request_uri": "$request_uri","http_user_agent": "$http_user_agent","http_x_forwarded_for": "$http_x_forwarded_for","body_bytes_sent": "$body_bytes_sent","upstream_response_time": "$upstream_response_time","request_time": "$request_time"}'
   
   >req_id is key in my logformat;  but value is  "http_x_ak_request_id"


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-947105418


   > can you show the logs in error.log, just like `[lua] balancer.lua:349: run(): proxy request to 127.0.0.1:1980 while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /hello HTTP/1.1", host: "127.0.0.1:1984"`
   
   >>2021/10/20 05:05:45 [error] 18332#18332: *39585706 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 10.48.8.13, server: _, request: "GET / HTTP/1.1", upstream: "http://10.49.0.248:22/", host: "myzone.ak.xyz"
   2021/10/20 05:05:45 [error] 18332#18332: *39585706 readv() failed (104: Connection reset by peer) while reading upstream, client: 10.48.8.13, server: _, request: "GET / HTTP/1.1", upstream: "http://10.49.0.248:22/", host: "myzone.ak.xyz"
   
   
   
   > this error is a new request


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-948324423


   > @chnliyong @nic-chen @tzssangglass 这个应该是一个bug,预计啥时候能修复的?
   
   Need to confirm that this is a bug first, I'm surprised that our test cases cover this case.


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946849587


   can you show the logs in error.log, just like `[lua] balancer.lua:349: run(): proxy request to 127.0.0.1:1980 while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /hello HTTP/1.1", host: "127.0.0.1:1984"`


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946733596


   we have test cases covering this case:https://github.com/apache/apisix/blob/50fed630823bb3c562f411d7cb5f5d38218348fb/t/plugin/traffic-split2.t#L593-L710
   
   
   > {"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"}
   
   What kind of log is this? And according to the logs I found some suspicions:
   
   the matching conditions are
   
   ```
   [
   "http_x_ak_request_id",
   "==",
   "10008"
   ]
   ```
   
   but the header in request is `req_id`? `http_x_ak_request_id` match the `x-ak-request-id` in header, take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946792768


   > > req_id is key in my logformat; but value is "http_x_ak_request_id"
   > 
   > take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   > 
   > ```
   > "vars": [
   >     ["http_x-api-id","==","2"]
   > ]
   > ```
   > 
   > the request header it will match is `x-api-id`
   
   
   
   >{
   ```
   "rules": [
           {
             "match": [
               {
                 "vars": [
                   [ "http_x-ak-request-id","==","10008" ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {
                 "upstream": {
                   "hash_on": "vars",
                   "name": "upstream_a",
                   "nodes": [
                     {
                       "host": "10.49.0.248",
                       "port": 2379,
                       "weight": 11
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 2379,
                       "weight": 11
                     }
                   ],
                   "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": 22,
                       "weight": 11
                     },
                     {
                       "host": "10.49.1.114",
                       "port": 22,
                       "weight": 11
                     }
                   ],
                   "pass_host": "pass",
                   "scheme": "http",
                   "type": "roundrobin"
                 },
                 "weight": 1
               }
             ]
           }
         ]
   ```
   
   log
   >>{"datetime":"19/Oct/2021:22:36:28 +0800","remote_addr": "10.48.8.13","http_host": "myzone.ak.xyz","upstream_addr": "10.49.1.114: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.007","request_time": "0.007"}
   
   
   >follow you guide,but there is the same result


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-954406845


   Here is my reproduction process:
   
   1. route config:
   
   ```
   curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/routes/1' \
   --header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
   --header 'Content-Type: application/json' \
   --data-raw '{
       "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": "127.0.0.1",
                                           "port": 1980,
                                           "weight": 10
                                       },
                                       {
                                           "host": "127.0.0.1",
                                           "port": 1981,
                                           "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": "127.0.0.1",
                                           "port": 1982,
                                           "weight": 10
                                       },
                                       {
                                           "host": "127.0.0.1",
                                           "port": 1983,
                                           "weight": 10
                                       }
                                   ],
                                   "pass_host": "pass",
                                   "scheme": "http",
                                   "type": "roundrobin"
                               },
                               "weight": 1
                           }
                       ]
                   }
               ]
           }
       },
       "upstream": {
           "nodes": [
               {
                   "host": "127.0.0.1",
                   "port": 1984,
                   "weight": 10
               }
           ],
           "timeout": {
               "connect": 6,
               "read": 6,
               "send": 6
           },
           "type": "roundrobin",
           "scheme": "http",
           "pass_host": "pass"
       }
   }'
   ```
   
   2. my fake upstream is an openresty, the `nginx.conf` as below
   
   ```
   master_process on;
   
   worker_processes 2;
   
   error_log logs/error.log warn;
   pid logs/nginx.pid;
   
   worker_rlimit_nofile 20480;
   
   events {
       accept_mutex off;
       worker_connections 10620;
   }
   
   worker_shutdown_timeout 3;
   
   http {
       server {
           listen 1980;
   
           access_log off;
           location / {
               content_by_lua_block {
                   ngx.say("port: 1980, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
               }
           }
       }
   
       server {
           listen 1981;
   
           access_log off;
           location / {
               content_by_lua_block {
                   ngx.say("port: 1981, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
               }
           }
       }
   
       server {
           listen 1982;
   
           access_log off;
           location / {
               content_by_lua_block {
                   ngx.say("port: 1982, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
               }
           }
       }
   
       server {
           listen 1983;
   
           access_log off;
           location / {
               content_by_lua_block {
                   ngx.say("port: 1983, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
               }
           }
       }
   
       server {
           listen 1984;
   
           access_log off;
           location / {
               content_by_lua_block {
                   ngx.say("port: 1984, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
               }
           }
       }
   }
   
   ```
   
   3. test
   
   3.1
   
   ```
   # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1984
   
   $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10007'
   port: 1984, x_ak_request_id: 10007
   ```
   
   3.2
   
   ```
   # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1980 or 1981
   
   $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10008'
   port: 1981, x_ak_request_id: 10008
   ```
   
   3.3
   
   ```
   # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1982 or 1983
   
   $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10009'
   port: 1980, x_ak_request_id: 10009
   ```
   
   you can see that 3.3 is not normal.
   
   I think this is a bug. I will fix this.
   
   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ edited a comment on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ edited a comment on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-947105418


   > can you show the logs in error.log, just like `[lua] balancer.lua:349: run(): proxy request to 127.0.0.1:1980 while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /hello HTTP/1.1", host: "127.0.0.1:1984"`
   
   
   
   >curl myzone.ak.xyz -H "x-ak-request-id:10009"
   
   >log info
   >>2021/10/20 05:05:45 [error] 18332#18332: *39585706 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 10.48.8.13, server: _, request: "GET / HTTP/1.1", upstream: "http://10.49.0.248:22/", host: "myzone.ak.xyz"
   2021/10/20 05:05:45 [error] 18332#18332: *39585706 readv() failed (104: Connection reset by peer) while reading upstream, client: 10.48.8.13, server: _, request: "GET / HTTP/1.1", upstream: "http://10.49.0.248:22/", host: "myzone.ak.xyz"
   
   > this error is a new request


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946747076


   > req_id is key in my logformat; but value is "http_x_ak_request_id"
   
   take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   
   ```
   "vars": [
       ["http_x-api-id","==","2"]
   ]
   ```
   
   the request header it will match is `x-api-id`


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ edited a comment on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ edited a comment on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946739822


   > we have test cases covering this case:
   > 
   > https://github.com/apache/apisix/blob/50fed630823bb3c562f411d7cb5f5d38218348fb/t/plugin/traffic-split2.t#L593-L710
   > 
   > > {"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"}
   > 
   > What kind of log is this? And according to the logs I found some suspicions:
   > 
   > the matching conditions are
   > 
   > ```
   > [
   > "http_x_ak_request_id",
   > "==",
   > "10008"
   > ]
   > ```
   > 
   > but the header in request is `req_id`? `http_x_ak_request_id` match the `x-ak-request-id` in header, take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   
   this is log format  
   
   >>access_log_format: '{"datetime":"$time_local","remote_addr": "$remote_addr","http_host": "$http_host","upstream_addr": "$upstream_addr","request_method": "$request_method","http_referer": "$http_referer","req_id": "$http_x_ak_request_id","company_id": "$http_x_ak_company_id","zid": "$http_zid","status": "$status","server_name": "$server_name","request_uri": "$request_uri","http_user_agent": "$http_user_agent","http_x_forwarded_for": "$http_x_forwarded_for","body_bytes_sent": "$body_bytes_sent","upstream_response_time": "$upstream_response_time","request_time": "$request_time"}'
   req_id is key in my logformat;  but value is  "http_x_ak_request_id"


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ edited a comment on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ edited a comment on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-953652607


   @tzssangglass @spacewander    Is the problem confirmed ?
   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-955850125


   > Here is my reproduction process:
   > 
   > 1. route config:
   > 
   > ```
   > curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/routes/1' \
   > --header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
   > --header 'Content-Type: application/json' \
   > --data-raw '{
   >     "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": "127.0.0.1",
   >                                         "port": 1980,
   >                                         "weight": 10
   >                                     },
   >                                     {
   >                                         "host": "127.0.0.1",
   >                                         "port": 1981,
   >                                         "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": "127.0.0.1",
   >                                         "port": 1982,
   >                                         "weight": 10
   >                                     },
   >                                     {
   >                                         "host": "127.0.0.1",
   >                                         "port": 1983,
   >                                         "weight": 10
   >                                     }
   >                                 ],
   >                                 "pass_host": "pass",
   >                                 "scheme": "http",
   >                                 "type": "roundrobin"
   >                             },
   >                             "weight": 1
   >                         }
   >                     ]
   >                 }
   >             ]
   >         }
   >     },
   >     "upstream": {
   >         "nodes": [
   >             {
   >                 "host": "127.0.0.1",
   >                 "port": 1984,
   >                 "weight": 10
   >             }
   >         ],
   >         "timeout": {
   >             "connect": 6,
   >             "read": 6,
   >             "send": 6
   >         },
   >         "type": "roundrobin",
   >         "scheme": "http",
   >         "pass_host": "pass"
   >     }
   > }'
   > ```
   > 
   > 1. my fake upstream is an openresty, the `nginx.conf` as below
   > 
   > ```
   > master_process on;
   > 
   > worker_processes 2;
   > 
   > error_log logs/error.log warn;
   > pid logs/nginx.pid;
   > 
   > worker_rlimit_nofile 20480;
   > 
   > events {
   >     accept_mutex off;
   >     worker_connections 10620;
   > }
   > 
   > worker_shutdown_timeout 3;
   > 
   > http {
   >     server {
   >         listen 1980;
   > 
   >         access_log off;
   >         location / {
   >             content_by_lua_block {
   >                 ngx.say("port: 1980, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
   >             }
   >         }
   >     }
   > 
   >     server {
   >         listen 1981;
   > 
   >         access_log off;
   >         location / {
   >             content_by_lua_block {
   >                 ngx.say("port: 1981, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
   >             }
   >         }
   >     }
   > 
   >     server {
   >         listen 1982;
   > 
   >         access_log off;
   >         location / {
   >             content_by_lua_block {
   >                 ngx.say("port: 1982, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
   >             }
   >         }
   >     }
   > 
   >     server {
   >         listen 1983;
   > 
   >         access_log off;
   >         location / {
   >             content_by_lua_block {
   >                 ngx.say("port: 1983, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
   >             }
   >         }
   >     }
   > 
   >     server {
   >         listen 1984;
   > 
   >         access_log off;
   >         location / {
   >             content_by_lua_block {
   >                 ngx.say("port: 1984, x_ak_request_id: " .. ngx.req.get_headers()["x_ak_request_id"])
   >             }
   >         }
   >     }
   > }
   > ```
   > 
   > 1. test
   > 
   > 3.1
   > 
   > ```
   > # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1984
   > 
   > $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10007'
   > port: 1984, x_ak_request_id: 10007
   > ```
   > 
   > 3.2
   > 
   > ```
   > # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1980 or 1981
   > 
   > $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10008'
   > port: 1981, x_ak_request_id: 10008
   > ```
   > 
   > 3.3
   > 
   > ```
   > # It should not be caught by the rule in traffic-split, and apisix proxy request to upstream port 1982 or 1983
   > 
   > $ curl 127.0.0.1:9080/hello -H 'Host: myzone.ak.xyz' -H 'x-ak-request-id: 10009'
   > port: 1980, x_ak_request_id: 10009
   > ```
   > 
   > you can see that 3.3 is not normal.
   > 
   > I think this is a bug. I will fix this.
   
   
   
   >ok,thanks ,will this bug be fixed by  the next version ?


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-948440948


   > > @chnliyong @nic-chen @tzssangglass 这个应该是一个bug,预计啥时候能修复的?
   > 
   > Need to confirm that this is a bug first, I'm surprised that our test cases cover this case.
   
   
   
   >ok, Thanks;   APISXI has been  online in my company  


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946739822


   > we have test cases covering this case:
   > 
   > https://github.com/apache/apisix/blob/50fed630823bb3c562f411d7cb5f5d38218348fb/t/plugin/traffic-split2.t#L593-L710
   > 
   > > {"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"}
   > 
   > What kind of log is this? And according to the logs I found some suspicions:
   > 
   > the matching conditions are
   > 
   > ```
   > [
   > "http_x_ak_request_id",
   > "==",
   > "10008"
   > ]
   > ```
   > 
   > but the header in request is `req_id`? `http_x_ak_request_id` match the `x-ak-request-id` in header, take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   
   this is log format  
   ======================
   access_log_format: '{"datetime":"$time_local","remote_addr": "$remote_addr","http_host": "$http_host","upstream_addr": "$upstream_addr","request_method": "$request_method","http_referer": "$http_referer","req_id": "$http_x_ak_request_id","company_id": "$http_x_ak_company_id","zid": "$http_zid","status": "$status","server_name": "$server_name","request_uri": "$request_uri","http_user_agent": "$http_user_agent","http_x_forwarded_for": "$http_x_forwarded_for","body_bytes_sent": "$body_bytes_sent","upstream_response_time": "$upstream_response_time","request_time": "$request_time"}'
   ======================
   
   req_id is key in my logformat;  but value is  "http_x_ak_request_id"


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-953652607


   @tzssangglass @spacewande   Is the problem confirmed ?
   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander closed issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #5276:
URL: https://github.com/apache/apisix/issues/5276


   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander closed issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #5276:
URL: https://github.com/apache/apisix/issues/5276


   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ commented on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ commented on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-948295281


   @chnliyong @nic-chen @tzssangglass   这个应该是一个bug,预计啥时候能修复的?


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] RalapZ edited a comment on issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
RalapZ edited a comment on issue #5276:
URL: https://github.com/apache/apisix/issues/5276#issuecomment-946739822


   > we have test cases covering this case:
   > 
   > https://github.com/apache/apisix/blob/50fed630823bb3c562f411d7cb5f5d38218348fb/t/plugin/traffic-split2.t#L593-L710
   > 
   > > {"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"}
   > 
   > What kind of log is this? And according to the logs I found some suspicions:
   > 
   > the matching conditions are
   > 
   > ```
   > [
   > "http_x_ak_request_id",
   > "==",
   > "10008"
   > ]
   > ```
   > 
   > but the header in request is `req_id`? `http_x_ak_request_id` match the `x-ak-request-id` in header, take a look at:https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/traffic-split.md#matching-rules-correspond-to-upstream
   
   this is log format  
   
   ---
   access_log_format: '{"datetime":"$time_local","remote_addr": "$remote_addr","http_host": "$http_host","upstream_addr": "$upstream_addr","request_method": "$request_method","http_referer": "$http_referer","req_id": "$http_x_ak_request_id","company_id": "$http_x_ak_company_id","zid": "$http_zid","status": "$status","server_name": "$server_name","request_uri": "$request_uri","http_user_agent": "$http_user_agent","http_x_forwarded_for": "$http_x_forwarded_for","body_bytes_sent": "$body_bytes_sent","upstream_response_time": "$upstream_response_time","request_time": "$request_time"}'
   ----
   req_id is key in my logformat;  but value is  "http_x_ak_request_id"


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander closed issue #5276: bug:module:"traffic-split" ,when config multi rules. and multi nodes. There is a problem with the matching rule

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #5276:
URL: https://github.com/apache/apisix/issues/5276


   


-- 
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-unsubscribe@apisix.apache.org

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