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/04 03:01:30 UTC

[GitHub] [apisix] tokers opened a new issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

tokers opened a new issue #5417:
URL: https://github.com/apache/apisix/issues/5417


   ### Issue description
   
   Currently, Apache APISIX will generate an id while initializing if the user doesn't specify one, and it relies on the [lua-resty-jit-uuid](https://github.com/thibaultcha/lua-resty-jit-uuid) library but without an explicit seed.
   
   https://github.com/apache/apisix/blob/4dafab5afa3293b3d72007517246e01da385f8ef/apisix/core/id.lua#L76-L78
   
   While the jit-uuid library creates the seed by the process id and the time in ngx_lua context.
   
   https://github.com/thibaultcha/lua-resty-jit-uuid/blob/82538049040ae85ff880b79886f21d8593140c7d/lib/resty/jit-uuid.lua#L53-L54
   
   However, in a containerized environment, the process id (the master process) might be the same, i.e. the No. 1 process, also, if users try to deploy Apache APISIX clusters on Kubernetes through the `Deployment` resource, the time might be the same since `ngx.time` doesn't have enough precisions (only at milliseconds level). so the generated apisix id might be duplicated, and if the id is critical, this may cause some fatal problems in the business scenarios.
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - 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`):
   
   
   ### Steps to reproduce
   
   N/A
   
   ### Actual result
   
   N/A
   
   ### Error log
   
   N/A
   
   ### Expected result
   
   _No response_


-- 
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] membphis commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   how about this way? 
   
   https://github.com/kubernetes/ingress-nginx/blob/30809c066cd027079cbb32dccc8a101d6fbffdcb/rootfs/etc/nginx/lua/lua_ingress.lua#L44
   
   


-- 
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] tokers commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   > Maybe we can suffix some rand bytes from [thibaultcha/lua-resty-jit-uuid#19 (comment)](https://github.com/thibaultcha/lua-resty-jit-uuid/issues/19#issuecomment-521076462)
   
   Good idea.


-- 
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 commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   Maybe we can suffix some rand bytes from https://github.com/thibaultcha/lua-resty-jit-uuid/issues/19#issuecomment-521076462


-- 
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] aseaday commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   Or add randomsed in apisix/patch.lua


-- 
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] membphis commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   After a careful look at the two implementations, the core is the same.
   
   Let's do it.


-- 
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 commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   @leslie-tsang 
   Would you like to have a try? Thanks!


-- 
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] aseaday commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   Considering a more stable production purpose use, how about we did our best in the k8s environment or something else?
   [Project Hipsor](http://www.irisa.fr/caps/projects/hipsor/)
   


-- 
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] aseaday commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   > how about this way?
   > 
   > https://github.com/kubernetes/ingress-nginx/blob/30809c066cd027079cbb32dccc8a101d6fbffdcb/rootfs/etc/nginx/lua/lua_ingress.lua#L44
   
   It seems like the same as Kong one?


-- 
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] aseaday commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   > After a careful look at the two implementations, the core is the same.
   > 
   > Let's do it.
   
   I want to fix this bug as an first step to contribute to apisix. As an newbie, I had one question:
   1. Need we to patch the math.randomseed or just fix the id problem?


-- 
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] leslie-tsang commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

Posted by GitBox <gi...@apache.org>.
leslie-tsang commented on issue #5417:
URL: https://github.com/apache/apisix/issues/5417#issuecomment-966753779


   > @leslie-tsang Would you like to have a try? Thanks!
   
   Sure.


-- 
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] tokers commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   Vote for Kong, it's on a higher level.


-- 
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] membphis commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   Which one is the best, then use which one.


-- 
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] aseaday commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   > I prefer patch `math.randomseed` way
   
   If we patch the math.randomsee globally as the [kong](https://github.com/Kong/kong/blob/fb7a68d497c1104779d650014ba6521bf129f726/kong/globalpatches.lua?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L241-L342) way, we need to add a module as the global patch. Is it a good choice to put the module in the core?


-- 
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 #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   vote the kong way too


-- 
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] membphis commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   > Or add randomsed in apisix/patch.lua
   
   I prefer this way. what is your opinion? @spacewander 


-- 
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] leslie-tsang commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

Posted by GitBox <gi...@apache.org>.
leslie-tsang commented on issue #5417:
URL: https://github.com/apache/apisix/issues/5417#issuecomment-968476491


   After reading the [lua-resty-jit-uuid's issue](https://github.com/thibaultcha/lua-resty-jit-uuid/issues/19#issuecomment-521076462), there are three solution for this issue:
   1. use `resty.random` to generate `UUID`, it depend on OpenSSL `RAND_bytes `
   2. use `tostring(table or str)` to get a random seed, Ref to [lua-nginx-module issue #1457](https://github.com/openresty/lua-nginx-module/issues/1457) and [apisix PR #5414](https://github.com/apache/apisix/pull/5414/files#diff-95a2018f002f15f5fb0714075b5ef27a1db113c186bfe20ae705f6023080b38fR214)
   3. patch `_G.math.randomseed` like [kong](https://github.com/Kong/kong/blob/fb7a68d497c1104779d650014ba6521bf129f726/kong/globalpatches.lua?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L241-L342) does
   
   @spacewander @tokers What do you guys think ?


-- 
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 commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   I vote for the kong way.


-- 
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] membphis commented on issue #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   I prefer patch `math.randomseed` way


-- 
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 #5417: bug: auto-generated apisix id is likely to be duplicated in containerized environments

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


   


-- 
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