SkyeYoung commented on code in PR #12383: URL: https://github.com/apache/apisix/pull/12383#discussion_r2215262792
########## apisix/core/config_etcd.lua: ########## @@ -1001,7 +1001,7 @@ function _M.new(key, opts) sync_times = 0, running = true, conf_version = 0, - values = nil, + values = {}, Review Comment: Without this modification, the following problems will be encountered: ``` Failed test 't/core/config_etcd.t TEST 12: test route with special character "-" - pattern "[error]" should not match any line in error.log but matches line "2025/07/09 14:24:01 [error] 1169428#1169428: *26 [lua] exporter.lua:534: Failed to collect metrics: /home/iskyex/apisix/apisix/consumer.lua:77: attempt to get length of local 'data_list' (a nil value), context: ngx.timer" (req 0) ``` After discussion, there are two ways to handle it, one is the current one, and the other is as follows: ```lua -- add between https://github.com/SkyeYoung/apisix/blob/7a06f5c2f7b74cf621a0c2ff6878e8aa0e4e99a7/apisix/core/config_etcd.lua#L1030-L1031 else load_full_data(obj, { nodes: {}}, nil) self.need_reload = true -- ^ This is why not use this method, -- there is a hidden variable in this function that needs to be reset ``` Without resetting this variable, the [etcd-sync.t#TEST 5](https://github.com/apache/apisix/blob/4377d05491ae2af228d40e3900362371363a8f46/t/core/etcd-sync.t#L141-L160) will be failed. (The reason is that the subsequent execution of `load_full_data` is missing) Thanks for the help from @bzp2010 , I was lost in the code. ########## apisix/core/config_etcd.lua: ########## @@ -1001,7 +1001,7 @@ function _M.new(key, opts) sync_times = 0, running = true, conf_version = 0, - values = nil, + values = {}, Review Comment: Without this modification, the following problems will be encountered: ``` Failed test 't/core/config_etcd.t TEST 12: test route with special character "-" - pattern "[error]" should not match any line in error.log but matches line "2025/07/09 14:24:01 [error] 1169428#1169428: *26 [lua] exporter.lua:534: Failed to collect metrics: /home/iskyex/apisix/apisix/consumer.lua:77: attempt to get length of local 'data_list' (a nil value), context: ngx.timer" (req 0) ``` After discussion, there are two ways to handle it, one is the current one, and the other is as follows: ```lua -- add between https://github.com/SkyeYoung/apisix/blob/7a06f5c2f7b74cf621a0c2ff6878e8aa0e4e99a7/apisix/core/config_etcd.lua#L1030-L1031 else load_full_data(obj, { nodes: {}}, nil) self.need_reload = true -- ^ This is why not use this method, -- there is a hidden variable in this function that needs to be reset ``` Without resetting this variable, the [etcd-sync.t#TEST 5](https://github.com/apache/apisix/blob/4377d05491ae2af228d40e3900362371363a8f46/t/core/etcd-sync.t#L141-L160) will be failed. (The reason is that the subsequent execution of `load_full_data` is missing) Thanks for the help from @bzp2010 , I was lost in the code. -- 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: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org