-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(build): build ngx_wasm_module as a dynamic Nginx module #10465
Conversation
bazel build //build:kong --//:wasmx=true --//:wasm_runtime=v8
* chore(build): nest wasmx under build/openresty * chore(build): install wasmx lua libs * drop extra flags for cp * fix bazel lint complaints
* feat(wasm): attach filters from the wasm_filter_chains model * fix(wasm): load proxy wasm modules in init_worker phase * fix(conf_loader): use correct log invocation * fix(wasm): match return value with other init_worker() calls
$ bazel build //build:venv --//:wasmx=true --//:wasm_runtime=v8 --//:dyn_ngx_wasm_module=true
Let's merge #10371 before merging this one. |
* fix(build): build on macos * style(build) fix bazel files formatting * fix(templates): do not check nil size
Do we build anything else as dynamic? Is there a particular reason for making it |
@bungle We don't build any other module as dynamic. But this one is still a tech preview and people may want to fully disable it. |
Could you please better explain what "disable" means here and how users can "fully disable" this module from a Kong package? I'm not familiar with dynamic nginx modules, so please bear with me. |
@hbagdi Sorry, I was not clear. By "disable" I mean users can set |
I'm more confused so here we go.
|
But you are right, when the module is built as dynamic we can remove the
I didn't check this. |
Ok, that makes more sense. I should also read nginx documentation more.
Do answers to these questions influence the decision of dynamic/static? |
"@ngx_wasm_module//:lua_libs", | ||
], | ||
"//conditions:default": [], | ||
}) | ||
|
||
wasmx_lua_libs_cmd = select({ | ||
"@kong//:wasmx_flag": """ | ||
"@kong//:static_wasmx_flag": """ | ||
for fname in $(locations @ngx_wasm_module//:lua_libs); do |
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 wonder if it's possible to de-dupe this shell command string so that it can be referenced only once for each flag in the select()
call.
Can you give this a shot and see if it works? Honestly it's not that much prettier, but w/ the state of bazel I'll take any kind of win we can get.
install_wasm_lua_libs_cmd = """
for fname in $(locations @ngx_wasm_module//:lua_libs); do
base=${fname##*/ngx_wasm_module/lib/}
dest="${BUILD_DESTDIR}/openresty/lualib/$base"
mkdir -p "$(dirname "$dest")"
cp "$fname" "$dest"
done
"""
wasmx_lua_libs_cmd = select({
"@kong//:static_wasmx_flag": install_wasm_lua_libs_cmd,
"@kong//:dyn_wasmx_flag": install_wasm_lua_libs_cmd,
"//conditions:default": "\n",
})
I wouldn't consider the duplicate string a blocker though. Don't spend too much time trying to make it work if bazel fights back.
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.
We can also use a config_settings_group
like https://github.com/Kong/kong/blob/master/BUILD.bazel#L231
then you can have a new condition on say @kong//:any_wasmx_flag
Nginx is in general really really small. Something like 1.7 MB on my machine (with all modules build in). I recently removed bunch of modules from our build. It did not have any effect to RSS, the binary size went down perhaps 100kB or so. The problem I see with dynamic is that it is something that we have never shipped, aka Kong has never tried to load modules dynamically. I am sure it works as expected, but there is always some unknowns that are hard to catch. If that module is done right, I guess it will not run anything if not asked to (?) |
ping @locao |
I share this opinion. I will convert this PR to draft and check in the next sync meeting if this is something we really should pursue. |
0823ad9
to
e357a7e
Compare
Superseded by #11100 |
Summary
Build
ngx_wasm_module
as a dynamic Nginx module.