Skip to content

fix(conf_loader): adjust Wasm shm_kv nginx.conf prefix #11919

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

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/kong/wasm-injected-shm-kv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
message: >
**BREAKING:** To avoid ambiguity with other Wasm-related nginx.conf directives,
the prefix for Wasm `shm_kv` nginx.conf directives was changed from
`nginx_wasm_shm_` to `nginx_wasm_shm_kv_`
type: breaking_change
scope: Core
2 changes: 1 addition & 1 deletion kong.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@
# The following namespaces are supported:
#
# - `nginx_wasm_<directive>`: Injects `<directive>` into the `wasm {}` block.
# - `nginx_wasm_shm_<name>`: Injects `shm_kv <name>` into the `wasm {}` block,
# - `nginx_wasm_shm_kv_<name>`: Injects `shm_kv <name>` into the `wasm {}` block,
# allowing operators to define custom shared memory zones which are usable by
# the `get_shared_data`/`set_shared_data` Proxy-Wasm SDK functions.
# - `nginx_wasm_wasmtime_<flag>`: Injects `flag <flag>` into the `wasmtime {}`
Expand Down
4 changes: 2 additions & 2 deletions kong/conf_loader/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ local DYNAMIC_KEY_NAMESPACES = {
ignore = EMPTY,
},
{
injected_conf_name = "nginx_wasm_main_shm_directives",
prefix = "nginx_wasm_shm_",
injected_conf_name = "nginx_wasm_main_shm_kv_directives",
prefix = "nginx_wasm_shm_kv_",
ignore = EMPTY,
},
{
Expand Down
2 changes: 1 addition & 1 deletion kong/templates/nginx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ events {

> if wasm then
wasm {
> for _, el in ipairs(nginx_wasm_main_shm_directives) do
> for _, el in ipairs(nginx_wasm_main_shm_kv_directives) do
shm_kv $(el.name) $(el.value);
> end

Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/04-prefix_handler_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,12 @@ describe("NGINX conf compiler", function()
assert.matches("wasm {.+socket_connect_timeout 10s;.+}", ngx_cfg({ wasm = true, nginx_wasm_socket_connect_timeout="10s" }, debug))
end)
it("injects a shm_kv", function()
assert.matches("wasm {.+shm_kv counters 10m;.+}", ngx_cfg({ wasm = true, nginx_wasm_shm_counters="10m" }, debug))
assert.matches("wasm {.+shm_kv counters 10m;.+}", ngx_cfg({ wasm = true, nginx_wasm_shm_kv_counters="10m" }, debug))
end)
it("injects multiple shm_kvs", function()
assert.matches(
"wasm {.+shm_kv cache 10m.+shm_kv counters 10m;.+}",
ngx_cfg({ wasm = true, nginx_wasm_shm_cache="10m", nginx_wasm_shm_counters="10m"}, debug)
ngx_cfg({ wasm = true, nginx_wasm_shm_kv_cache="10m", nginx_wasm_shm_kv_counters="10m"}, debug)
)
end)
it("injects default configurations if wasm=on", function()
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/custom_nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ events {

> if wasm then
wasm {
> for _, el in ipairs(nginx_wasm_main_shm_directives) do
> for _, el in ipairs(nginx_wasm_main_shm_kv_directives) do
shm_kv $(el.name) $(el.value);
> end

Expand Down