Skip to content

bug: the traffic-split plugin is invalid to bind upstream via upstream_id #3740

Description

@Firstsawyou

Issue description

When both the routing and traffic-split plugins use upstream_id to bind upstream, the request distribution is not accurate.

1、add route and bind plugin

The upstream_id is 1, the response data is 1980, and the upstream_id is 2 the response data is 1981.

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "create_time":1614743731,
    "update_time":1614745342,
    "uris":[
        "/*"
    ],
    "name":"luarocks_cn",
    "methods":[
        "GET",
        "HEAD",
        "POST",
        "PUT",
        "DELETE",
        "OPTIONS",
        "PATCH"
    ],   
    "vars":[

    ],
    "plugins":{
        "proxy-rewrite":{
            "disable":false,
            "scheme":"http"
        },
        "traffic-split":{
            "disable":false,
            "rules":[
                {
                    "match":[
                        {
                            "vars":[
                                [
                                    "uri",
                                    "==",
                                    "/hello"
                                ]
                            ]
                        }
                    ],
                    "weighted_upstreams":[
                        {
                            "upstream_id":"2"
                        }
                    ]
                }
            ]
        }
    },
    "upstream_id":"1",
    "status":1
}
'

2、Test plugin

The vars rule passes:

$ curl http://127.0.0.1:9080/hello
1981

The vars rule failed:

$ curl http://127.0.0.1:9080/hello12
1980

The vars rule passes:

$ curl http://127.0.0.1:9080/hello
1981

The vars rule failed (an exception occurred):

$ curl http://127.0.0.1:9080/hello12
1981

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions