fix(nacos): declare nacos-stream shared dict in the stream subsystem#13541
Open
AlinsRan wants to merge 1 commit into
Open
fix(nacos): declare nacos-stream shared dict in the stream subsystem#13541AlinsRan wants to merge 1 commit into
AlinsRan wants to merge 1 commit into
Conversation
b5dccbd to
5e9bfe9
Compare
The nacos discovery module picks its shared dict by subsystem:
local dict_name = is_http and "nacos" or "nacos-stream" -- apisix/discovery/nacos/init.lua:36
and errors out when the dict is missing:
error('lua_shared_dict "' .. dict_name .. '" not configured') -- init.lua:284
`nacos` is declared in the http block, but `nacos-stream` is declared
nowhere, so nacos discovery in the stream subsystem fails at init_worker.
Declare `nacos-stream` in the stream block, mirroring the unconditional
`nacos` dict in http.
Signed-off-by: AlinsRan <alinsran@apache.org>
5e9bfe9 to
7b275f2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Enabling nacos discovery while the stream subsystem is on crashes the stream worker at startup:
lua_shared_dict "nacos-stream" not configured.Cause
nacos selects its shared dict by subsystem (
nacosfor http,nacos-streamfor stream), butnacos-streamis declared nowhere.init_worker()errors out before any network call:Introduced by the refactor in #13201.
Fix
Declare
nacos-streamin thestreamblock ofngx_tpl.lua, mirroring the unconditionalnacosdict in the http block.Test
t/cli/test_discovery_nacos_stream.sh: starts APISIX withproxy_mode: stream+ nacos discovery and asserts the stream worker initializes without the error (no nacos server needed — the dict check runs before any network call). Verified locally: passes with the fix, fails (exit 1, with the exact error above) without it.The bug was missed because it lives in the production
ngx_tpl.luatemplate + the streaminit_worker, which the Test::Nginx.tsuite bypasses (it uses its own nginx config); only thet/clitests exercise the real generated config.Checklist