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/11/01 01:31:47 UTC

[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

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