- Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Closed
thibaultcha wants to merge 4 commits into openresty:master from thibaultcha:feat/lua-load-resty-core
Closed
Changes from all commits
Commits
Show all changes
4 commits Select commit Hold shift + click to select a range
e052887
feat: implemented the lua_load_resty_core directive which loads resty…
thibaultcha 08f3959
tests: fixed default lua path to load resty.core from many test cases.
thibaultcha 36ab412
tests: fixed a few failing test cases due to loading resty.core.
thibaultcha 3d3ce00
[removeme] travis: switched to the contributor's branch of lua-resty-…
thibaultcha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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 justrequire("resty.core")
it works as expected.Note that the error does not recur when I reload Nginx.
Uh oh!
There was an error while loading. Please reload this page.
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
andLUA_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
andlua_package_cpath
directives. @thibaultcha Thelua_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
andlua-resty-lrucache
folders to something else. I then editedt/161-load-resty-core.t
addedONLY
to the first test and also addedlua_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 renamedlua-resty-core
andlua-resty-lrucache
folders to. Then running test it succeeds. So that tells me it respectslua_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 Nginx1.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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 theLUA_PATH
environment variable and thelua_package_path
directive. In fact, I just pushed a new test asserting this behavior: 4102b82Make 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
?