-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: route name should be unique, but now it can be duplicate #2479
Comments
I feel that it is a bug that affects the user experience, it would be better to solve before2.0, how about your options @membphis @nic-chen @moonming @juzhiyuan |
you can take the |
test result:
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '{"name":"test1","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
HTTP/1.1 201 Created
Server: openresty
Date: Tue, 20 Oct 2020 12:01:43 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
{"node":{"key":"\/apisix\/routes\/1000","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test1","id":"1000","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"102"},"action":"set"}
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '{"name":"test2","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
HTTP/1.1 200 OK
Server: openresty
Date: Tue, 20 Oct 2020 12:11:10 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
{"node":{"key":"\/apisix\/routes\/user1","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","id":"user1","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"},"action":"set"}
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
{"node":{"value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1},"hash_on":"vars","pass_host":"pass"},"id":"user1"},"modifiedIndex":105,"key":"\/apisix\/routes\/user1","createdIndex":103},"count":"1","action":"get","header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"}} Actually two duplicate id route create successfully, and the second one‘s data coverd the former |
you used the `PUT` method, so it will update the exist one.
you can try the `POST` method.
Thanks,
Ming Wen
Twitter: _WenMing
liuxiran <notifications@github.com> 于2020年10月20日周二 下午8:28写道:
… you can take the name as id, for example:
http://127.0.0.1:9080/apisix/admin/routes/test1
test result:
1. create a route id: user1,name:test1
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '{"name":"test1","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
HTTP/1.1 201 Created
Server: openresty
Date: Tue, 20 Oct 2020 12:01:43 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
{"node":{"key":"\/apisix\/routes\/1000","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test1","id":"1000","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"102"},"action":"set"}
1. create route id: user1, name test2
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '{"name":"test2","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
HTTP/1.1 200 OK
Server: openresty
Date: Tue, 20 Oct 2020 12:11:10 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
{"node":{"key":"\/apisix\/routes\/user1","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","id":"user1","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"},"action":"set"}
[**** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes/user1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
{"node":{"value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"test2","upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1},"hash_on":"vars","pass_host":"pass"},"id":"user1"},"modifiedIndex":105,"key":"\/apisix\/routes\/user1","createdIndex":103},"count":"1","action":"get","header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"105"}}
*Actually two duplicate id route create successfully, and the second one‘s
data coverd the former*
so there should be a unique key whether it's id or name
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2479 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGJZBK7RQZG5CGMQAF4SNA3SLV657ANCNFSM4SYDVW5Q>
.
|
I also tried [****** compose]$ curl http://127.0.0.1:9080/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -i -d '{"name":"just-test","uri":"/index.html","hosts":["foo.com","*.bar.com"],"remote_addrs":["127.0.0.0/8"],"methods":["PUT","GET"],"upstream":{"type":"roundrobin","nodes":{"39.97.63.215:80":1}}}'
HTTP/1.1 201 Created
Server: openresty
Date: Tue, 20 Oct 2020 12:24:14 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
{"header":{"raft_term":"5","cluster_id":"14841639068965178418","member_id":"10276657743932975437","revision":"107"},"node":{"key":"\/apisix\/routes\/00000000000000000106","value":{"priority":0,"methods":["PUT","GET"],"uri":"\/index.html","remote_addrs":["127.0.0.0\/8"],"hosts":["foo.com","*.bar.com"],"name":"just-test","upstream":{"pass_host":"pass","hash_on":"vars","nodes":{"39.97.63.215:80":1},"type":"roundrobin"}}},"action":"create"}
the Key point is that the response data did not contain |
@membphis please take a look |
Hi @liuxiran , actually there is a field
@moonming @membphis @juzhiyuan @liuxiran , I guess the real problem is that we can NOT specify a custom (unique) |
Thanks for your explanation, for this point, it would be better to return the same data format under different circumstances. |
I tried to create routes with the same name by from the above screenshots, we can see that the current Admin-API( run apisix with master branch) still allow to create the route with same name, so any updates on this issue? @membphis @spacewander thanks a lot |
Why not use the name as id? |
Better not add a unique restriction on the name field, which will introduce a break change. Since the name field is widely used, such break change is unacceptable. |
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions. |
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time. |
Issue description
refer to #1655
route name should be unique, actually I can create two routes with the same name.
Environment
apisix version
): latest masterMinimal test code / Steps to reproduce the issue
What's the expected result?
In practical application, you will use name to distinguish route, so duplicate names would make users confused.
The text was updated successfully, but these errors were encountered: