From d573911c141eb655cd80ae4857b1101ad2d83bf8 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 7 Nov 2023 03:17:32 -0600 Subject: [PATCH] fix(conf_loader): adjust Wasm shm_kv nginx.conf prefix (#11919) --- changelog/unreleased/kong/wasm-injected-shm-kv.yml | 6 ++++++ kong.conf.default | 2 +- kong/conf_loader/init.lua | 4 ++-- kong/templates/nginx.lua | 2 +- spec/01-unit/04-prefix_handler_spec.lua | 4 ++-- spec/fixtures/custom_nginx.template | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 changelog/unreleased/kong/wasm-injected-shm-kv.yml diff --git a/changelog/unreleased/kong/wasm-injected-shm-kv.yml b/changelog/unreleased/kong/wasm-injected-shm-kv.yml new file mode 100644 index 000000000000..0a5c72dfc6f9 --- /dev/null +++ b/changelog/unreleased/kong/wasm-injected-shm-kv.yml @@ -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 diff --git a/kong.conf.default b/kong.conf.default index 7d699c4ce1e9..4b673ba0c773 100644 --- a/kong.conf.default +++ b/kong.conf.default @@ -2054,7 +2054,7 @@ # The following namespaces are supported: # # - `nginx_wasm_`: Injects `` into the `wasm {}` block. -# - `nginx_wasm_shm_`: Injects `shm_kv ` into the `wasm {}` block, +# - `nginx_wasm_shm_kv_`: Injects `shm_kv ` 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_`: Injects `flag ` into the `wasmtime {}` diff --git a/kong/conf_loader/init.lua b/kong/conf_loader/init.lua index 69a92c3d4af2..9b04ed7a9fe2 100644 --- a/kong/conf_loader/init.lua +++ b/kong/conf_loader/init.lua @@ -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, }, { diff --git a/kong/templates/nginx.lua b/kong/templates/nginx.lua index d3552a9287d5..d6d01f03b2d9 100644 --- a/kong/templates/nginx.lua +++ b/kong/templates/nginx.lua @@ -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 diff --git a/spec/01-unit/04-prefix_handler_spec.lua b/spec/01-unit/04-prefix_handler_spec.lua index 27b109fba1a0..0337917237a4 100644 --- a/spec/01-unit/04-prefix_handler_spec.lua +++ b/spec/01-unit/04-prefix_handler_spec.lua @@ -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() diff --git a/spec/fixtures/custom_nginx.template b/spec/fixtures/custom_nginx.template index b5df446a7fed..abee4616d9bb 100644 --- a/spec/fixtures/custom_nginx.template +++ b/spec/fixtures/custom_nginx.template @@ -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