jiangfucheng opened a new issue, #9992:
URL: https://github.com/apache/apisix/issues/9992
### Current Behavior
When add "set route" and "hit route" logic in one "TEST" block, I found the
"set route" will not effect, eg:
```
=== TEST 1: test route
--- ONLY
--- yaml_config
deployment:
role: traditional
role_traditional:
config_provider: etcd
admin:
admin_key: null
etcd:
prefix: "/apisix-test"
--- config
location /t {
content_by_lua_block {
-- ngx.sleep(0.5)
local http = require "resty.http"
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"uri": "/hello",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}]]
)
if code >= 300 then
ngx.status = code
return
end
ngx.say(body)
-- hit
local httpc = http.new()
local uri = "http://127.0.0.1:" .. ngx.var.server_port ..
"/hello"
local res, err = httpc:request_uri(uri, {
method = "GET"
})
if not res then
ngx.log(ngx.ERR, err)
return
end
ngx.print(res.body)
}
}
--- request
GET /t
--- response_body
passed
hello world
```
I debug APISIX and found the reason is in this logic:
https://github.com/apache/apisix/blob/fed6f79b1e284590e91c03c90fda3b6ba6c4aa06/apisix/core/config_etcd.lua#L509-L522
the `values` variable is a object but not a `list(table)`
the calling code is here:
https://github.com/apache/apisix/blob/fed6f79b1e284590e91c03c90fda3b6ba6c4aa06/apisix/core/config_etcd.lua#L621C19-L621C19
1. Through the above logic, we can find that APISIX received the events but
did not handle it correctly.
2. According to my test, only the key is `prefix: /apisix-test` this format
will cause this bug.
I am currently not familiar with the code for `lua-resty-etcd`, so I haven't
find the real reason yet.
### Expected Behavior
The test case should be passed no matter execute any times
### Error Logs
_No response_
### Steps to Reproduce
1. execute the test case pasted above.(most of the time it fails, so we need
execute multiple to validations)
### Environment
- APISIX version (run `apisix version`):
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]