-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: implemented the lua_load_resty_core directive. #1501
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
feat: implemented the lua_load_resty_core directive. #1501
Conversation
a1ded3b
to
2babfcb
Compare
2babfcb
to
98f0747
Compare
98f0747
to
10a7534
Compare
….core by default.
10a7534
to
3d3ce00
Compare
Manually merged |
Hi @thibaultcha , The default See this issue: #1509 (comment) |
@chobits Indeed. lua-resty-core is to become a dependency of this module. For now, you can still turn this directive off. In an upcoming release, all CFunction APIs will be removed and lua-resty-core will become mandatory. |
@thibaultcha OK. Let me try lua-resty-core! |
"module from https://github.com/openresty/lua-resty" | ||
"-core; ensure you are using an OpenResty release " | ||
"from https://openresty.org/en/download.html " | ||
"(rc: %i, reason: %s)", rc, lua_tostring(L, -1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean lua-nginx-module can not be used outside of OpenResty bundle anymore? In one of our projects we compile lua-nginx-module manually and also include lua-resty-core and set lua package path correctly. Since this PR Nginx fails when starting with this error. When I turn off lua_load_resty_core
and do just require("resty.core")
it works as expected.
Note that the error does not recur when I reload Nginx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElvinEfendi It still can, just a little bit harder as you found out. If you want to add Lua library search paths to your own nginx build at build time, then just override the values of the macros LUA_DEFAULT_PATH
and LUA_DEFAULT_CPATH
to include your own installation paths of lua-resty-core (and lua-resty-lrucache). The OpenResty distribution's build system does exactly that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it should also work if the user specify the lua_package_path
and lua_package_cpath
directives. @thibaultcha The lua_code_resty_core
directive does not run after these search path nginx directives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agentzh the project I'm talking about is https://github.com/kubernetes/ingress-nginx/, and we are actually considering to use OpenResty as base image instead of Nginx.
--
I replicated CI image in this repository and renamed lua-resty-core
and lua-resty-lrucache
folders to something else. I then edited t/161-load-resty-core.t
added ONLY
to the first test and also added lua_package_path "/lua-resty-corexxx/lib/?.lua;/lua-resty-lrucachexxx/lib/?.lua;;";
using --- http_config
.
/lua-resty-corexxx
and /lua-resty-lrucachexxx
are what I renamed lua-resty-core
and lua-resty-lrucache
folders to. Then running test it succeeds. So that tells me it respects lua_package_path
in this case. Not sure yet why it does not work in https://github.com/kubernetes/ingress-nginx though. The only difference between the Nginx we use in ingress-nginx and 1.15.8 (also the version I used in the above test: https://github.com/ElvinEfendi/lua-nginx-module/pull/1/files#diff-3254677a7917c6c01f55212f86c57fbfR7) that OpenResty uses is that we use Nginx 1.17.0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElvinEfendi Then it's not something on our side? For OpenResty, then it already includes lua-resty-core or lua-resty-lrucache in its default search paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElvinEfendi For us to support you, you need to prepare a minimal and self-contained example. We are not maintaining that ingress-nginx project anyway, not to mention your own setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agentzh all I wanted to clarify was "Does this mean lua-nginx-module can not be used outside of OpenResty bundle anymore?" :) Because the error message implies that. But I got my answer, which is it should be possible.
I co-maintain ingress-nginx project - will look into this further on our side to see what's going on and will also potentially switch to OpenResty as base image for that project if the dependencies we need play well with OpenResty bundle.
Thanks for taking time to look into this though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's a recommendation. Not a requirement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElvinEfendi The lua_load_resty_core
directive respects the LUA_PATH
environment variable and the lua_package_path
directive. In fact, I just pushed a new test asserting this behavior: 4102b82
Make sure that you also clone lua-resty-lrucache which is itself a dependency of lua-resty-core.
Or maybe you set your Lua path in Lua-land (e.g. package.path = "...;" .. package.path
)? In which case, that'd be too late for this directive to honor the change.
Providing a minimally reproducible example with error logs may be useful here, but again as @agentzh said, this isn't really an issue with this module.
This module can still be used independently but the margin for error is high for most users, hence the warnings and other logs (e.g. lua-resty-core, LuaJIT's fork, etc...) asking to prefer the formal OpenResty releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where can I set package.path
?
Start from commit openresty/lua-nginx-module@60736e6 'resty.core' is now mandatorily loaded, and the 'lua_load_resty_core' directive is deprecated. See also openresty/lua-nginx-module#1501 If nginx is built with USE="nginx_modules_http_lua", there must have resty.core (OpenResty or a module with name 'resty') exist, otherwise nginx will fail to start w/ messages like bellow: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib64/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib64/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') in /etc/nginx/nginx.conf:47 Closes: https://bugs.gentoo.org/726728 Signed-off-by: Z. Liu <[email protected]>
Start from commit openresty/lua-nginx-module@60736e6 'resty.core' is now mandatorily loaded, and the 'lua_load_resty_core' directive is deprecated. See also openresty/lua-nginx-module#1501 If nginx is built with USE="nginx_modules_http_lua", there must have resty.core (OpenResty or a module named 'resty') exist, otherwise nginx will fail to start w/ messages like bellow: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib64/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib64/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') in /etc/nginx/nginx.conf:47 Closes: https://bugs.gentoo.org/726728 Signed-off-by: Z. Liu <[email protected]>
Start from commit openresty/lua-nginx-module@60736e6 'resty.core' is now mandatorily loaded, and the 'lua_load_resty_core' directive is deprecated. See also openresty/lua-nginx-module#1501 If nginx is built with USE="nginx_modules_http_lua", there must have resty.core (OpenResty or a module named 'resty') exist, otherwise nginx will fail to start w/ messages like bellow: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib64/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib64/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') in /etc/nginx/nginx.conf:47 Closes: https://bugs.gentoo.org/726728 Signed-off-by: Z. Liu <[email protected]>
Start from commit openresty/lua-nginx-module@60736e6 'resty.core' is now mandatorily loaded, and the 'lua_load_resty_core' directive is deprecated. See also openresty/lua-nginx-module#1501 If nginx is built with USE="nginx_modules_http_lua", there must have resty.core (OpenResty or a module named 'resty') exist, otherwise nginx will fail to start w/ messages like bellow: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib64/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib64/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') in /etc/nginx/nginx.conf:47 Closes: https://bugs.gentoo.org/726728 Signed-off-by: Z. Liu <[email protected]>
Start from commit openresty/lua-nginx-module@60736e6 'resty.core' is now mandatorily loaded, and the 'lua_load_resty_core' directive is deprecated. See also openresty/lua-nginx-module#1501 If nginx is built with USE="nginx_modules_http_lua", there must have resty.core (OpenResty or a module named 'resty') exist, otherwise nginx will fail to start w/ messages like bellow: nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: module 'resty.core' not found: no field package.preload['resty.core'] no file './resty/core.lua' no file '/usr/share/luajit-2.1.0-beta3/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core.lua' no file '/usr/local/share/lua/5.1/resty/core/init.lua' no file '/usr/share/lua/5.1/resty/core.lua' no file '/usr/share/lua/5.1/resty/core/init.lua' no file './resty/core.so' no file '/usr/local/lib/lua/5.1/resty/core.so' no file '/usr/lib64/lua/5.1/resty/core.so' no file '/usr/local/lib/lua/5.1/loadall.so' no file './resty.so' no file '/usr/local/lib/lua/5.1/resty.so' no file '/usr/lib64/lua/5.1/resty.so' no file '/usr/local/lib/lua/5.1/loadall.so') in /etc/nginx/nginx.conf:47 Closes: https://bugs.gentoo.org/726728 Signed-off-by: Z. Liu <[email protected]> Closes: #39823 Signed-off-by: Sam James <[email protected]>
Sister PRs: