Skip to content

Commit

Permalink
fix(conf_loader): adjust Wasm shm_kv nginx.conf prefix (#11919)
Browse files Browse the repository at this point in the history
  • Loading branch information
flrgh authored Nov 7, 2023
1 parent 9ca82dd commit d573911
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
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 @@ -2054,7 +2054,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

1 comment on commit d573911

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:d573911c141eb655cd80ae4857b1101ad2d83bf8
Artifacts available https://github.com/Kong/kong/actions/runs/6782372037

Please sign in to comment.