-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Lua object class support #7338
Lua object class support #7338
Conversation
COOL! Not sure we need to contains lua source in ceph repo. Specify a external directory may better? |
cool! looking forward to being merged ! |
Does it makes sense to use a submodule instead of an extracted tarball for lua? |
@yuyuyu101 @liewegas I have no issue with Lua being in a submodule (what's the motivation?) The only important thing is that we control that submodule because we may want to customize the VM in the future, but I'm assuming I target a ceph/lua repo? |
yeah. the submodule makes it easier to move between lua versions, keeps
lua and ceph code separate, and avoids munging up any source code stats.
|
sounds good. i'll need to have someone create ceph/lua repo.. looks like I don't have permission. |
Forked! https://github.com/ceph/lua
|
Thanks. I need push access to that repo. It isn't a vanilla Lua distribution, and its build configuration has been modified to assume cmake, so we'll need to hack it a bit to play nice with automake too. |
Hey @batrick thanks for pointing that out! I didn't realize that Lua 5.3 had this function. I wanted to include some useful serialization modules out-of-the-box so people could immediately start using this. It sounds like it might be OK to nuke the struct module for now. Let me know if you have any other questions or issues using cls_lua. |
target_include_directories(cephlua | ||
PUBLIC lua/lua-5.3.2/src/ | ||
) | ||
|
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.
could we move the cmake bits into a lua/CMakeLists.txt please?
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.
Absolutely. I'm in the process of stuffing Lua into a git submodule and I'll add this to the todo list.
@liewegas mind adding me to ceph/lua so I can push there? |
@noahdesu I updated the permissions there |
@noahdesu the cmake looks good, thanks. i'll check it out and make sure it builds for me too |
Rebased to remove merge recent merge conflicts. |
cls_method_context_t hctx = clslua_get_hctx(L); | ||
const char *key = luaL_checkstring(L, 1); | ||
bufferlist *bl = clslua_pushbufferlist(L, NULL); | ||
int ret = cls_cxx_map_get_val(hctx, key, bl); |
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.
I believe ret
needs to be negated on error right? In my tests, it returns a negative value which gives us:
Unknown error -2
in the logs.
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.
Do you mean negated to resolve to the correct errno string via strerror, or negated to change the logic?
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.
To get the correct errno string I believe.
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.
Thanks for catching this Patrick. I pushed a fix for it that seems to work (note that I also rebased to fix a merge conflict in master) 50739d7
There was some discussion of this at one of the recent CDM's. I think one of the main concerns was that we need a mechanism to whitelist classes for users? |
223aa95
to
91c7c43
Compare
@athanatos yes. i just created PR #9972 for review, that adds the loading and caps whitelist changes for object classes. |
Noah, could you build against the system lua instead of bundling it into Ceph? (for example RHEL/CentOS 7 have lua-devel-5.1.4-14.el7) When we bundle lua's source code into Ceph, the Ceph build time becomes longer, and the Ceph project becomes responsible for fixing CVEs in the bundled version, etc. |
Does RHEL7 have Lua 5.3? Optionally building against the system Lua 5.3 sounds reasonable to me. Also, Lua's source is pretty small. On my humble laptop a parallel make builds in 2.5 seconds. |
I'm not opposed to linking against a system library, but it seems the precedent is to avoid this when embedding the VM mostly due to compatibility and customization issues. For instance Redis disables byte-code execution with a patch to the VM source, and other things are possible like switching out the native numeric data type. From the Lua documentation: "Different versions are really different. The API is likely to be a little different (but with compatibility switches), and there is no ABI compatibility: applications that embed Lua and C libraries for Lua must be recompiled. The virtual machine is also very likely to be different in a new version: Lua programs that have been precompiled for one version will not load in a different version." That might be manageable when creating releases, but strikes me as a headache waiting to happen especially for people mixing Lua versions. Thoughts? |
There are pros and cons to bundling, and I wanted to at least have the discussion so I understand why we're doing it in each case. As long as the team is ok maintaining it when security fixes come up, I'm ok with it. |
Sounds good. I'm happy to do any tests or research on the issue for everyone to agree on an approach. |
the libgmock_main.so problem was caused by some cmake stuff that the lua submodule was doing that was causing various other libraries to be built as shared libraries rather than the expected static variety. @yuriw anyway, let's give this a shot again. i was able to install from packages on deb/rhel and things are working now. |
@noahdesu in case you didn't find it, see https://github.com/ceph/lua/blob/lua-5.1/cmake/dist.cmake#L77 . i suffered from this when working with gmock also. we need to reset this variable after including the lua subdirectory, or save and restore it before and after including the lua subdirectory. |
@tchaikov nice thanks for the reference, that was a tough one to track down. is there any reason to patch the lua variable? when i was reading through dist.cmake i didn't see anything in there we care about. it was packaging and installation stuff. |
Noah, see https://cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html . this variable changes the default behavior of |
@tchaikov cool thanks. i'll get that fixed up tomorrow. |
@tchaikov I think I misread your comment. I understand the global impact of the |
@noahdesu, have you seen the thread on ceph-devel concerning Lua packaging? I'd link to it but gmane appears down (maybe permanently). In particular, I'm concerned about including Ceph libraries in the lua submodule. Can those be moved |
@batrick thanks for the pointer, i'll chime in on the list. about your question here: you are referring to cmsgpack and the bufferlist bindings? absolutely, they can be moved to src/cls/lua. lua was originally moved to a submodule and the reason people wanted that was that it 1) screwed up LOC stats and 2) ostensibly was easier to manage. Since I didn't author cmsgpack it seemed more appropriate there, but its easy to move. The reasoning behind leaving bufferlist bindings there was because it was general purpose. |
@noahdesu sorry, i failed to understand your question. ic. i thought a less intrusive way would be easier for maintenance. but when i am looking at https://github.com/ceph/lua/commits/lua-5.3-ceph: well, we have already added a handful of patches on top of lua-5.3 branch, yet another one won't hurt. =) |
What is the status on this? |
I need to take another look at the thread on ceph-devel to make sure nothing is missing, but I think we just need to slap needs-qa back on this. |
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Introduces cls_lua that allows object classes to be created dynamically using the Lua language. Each request is processed in an empty Lua VM instance, and scripts can be submitted using bufferlist or JSON encoding. Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
No description provided.