bug: After upgrading to version 1.5, the attempt to call global'type' (a string value) error of ETCD appears
Issue description
After upgrading to version 1.5, the attempt to call global'type' (a string value) error of ETCD appears
2020/11/09 17:04:00 [error] 51#51: *341087 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/global_rules, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341094 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/global_rules, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341095 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/consumers, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341096 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/ssl, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341099 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/upstreams, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341100 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/services, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341101 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/proto, context: ngx.timer
2020/11/09 17:04:00 [error] 49#49: *341102 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/routes, context: ngx.timer
2020/11/09 17:04:00 [error] 50#50: *341113 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/ssl, context: ngx.timer
2020/11/09 17:04:00 [error] 50#50: *341114 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/consumers, context: ngx.timer
2020/11/09 17:04:00 [error] 50#50: *341115 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/global_rules, context: ngx.timer
2020/11/09 17:04:00 [error] 50#50: *341116 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/proto, context: ngx.timer
2020/11/09 17:04:00 [error] 50#50: *341117 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/services, context: ngx.timer
2020/11/09 17:04:00 [error] 48#48: *341118 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/consumers, context: ngx.timer
2020/11/09 17:04:00 [error] 48#48: *341119 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/global_rules, context: ngx.timer
2020/11/09 17:04:00 [error] 48#48: *341120 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/proto, context: ngx.timer
2020/11/09 17:04:00 [error] 48#48: *341121 [lua] config_etcd.lua:389: failed to fetch data from etcd: /usr/local/apisix//deps/share/lua/5.1/resty/etcd/utils.lua:67: attempt to call global 'type' (a string value), etcd key: /apisix/ssl, context: ngx.timer
Environment
- apisix version (cmd:
apisix version): 1.5 - OS:centos7 【K8S】 【docker】 ETCD:3.4.9
Minimal test code / Steps to reproduce the issue
1. 2. 3.
What's the actual result? (including assertion message & call stack if applicable)
adminAPI http 500 error
What's the expected result?
@backnero Have you executed make deps and ./bin/apisix init_etcd after you upgrading APISIX?
FROM centos:7
# 设置时区为上海
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ARG APISIX_VERSION=1.5
LABEL apisix_version="${APISIX_VERSION}"
RUN yum -y install yum-utils\
&& yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo \
&& yum install -y openresty \
&& yum install -y https://github.com/apache/apisix/releases/download/$APISIX_VERSION/apisix-$APISIX_VERSION-0.el7.noarch.rpm \
&& yum clean all \
&& sed -i 's/PASS_MAX_DAYS\t99999/PASS_MAX_DAYS\t60/g' /etc/login.defs
WORKDIR /usr/local/apisix
EXPOSE 9080 9443
CMD ["sh", "-c", "/usr/bin/apisix init && /usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
I use yum to install apisix 1.5
Have you installed etcd? could you try to check etcd data like this?
etcdctl get --prefix "/apisix"
I upgraded from 1.4.1 to version 1.5, so it is etcd api V2. When I use
etcdctl ls /apisix

I get the key information normally
But there are always errors in error.log
2020/11/12 15:07:56 [error] 49#49: *4695 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/init.lua:128: attempt to index a nil value
stack traceback:
coroutine 0:
/usr/local/apisix/apisix/init.lua: in function 'run_plugin'
/usr/local/apisix/apisix/init.lua:457: in function 'http_access_phase'
access_by_lua(nginx.conf:167):2: in main chunk, client: 127.0.0.1, server: , request: "GET /account/user/info HTTP/2.0", host: "t.com", referrer: "http://localhost:9527/"
2020/11/13 16:12:36 [warn] 48#48: *130332 [lua] plugins.lua:98: failed to load plugin [reload] err: module 'apisix.plugins.reload' not found:
no field package.preload['apisix.plugins.reload']
no file '/usr/local/apisix//deps/share/lua/5.1/apisix/plugins/reload.lua'
no file '/usr/local/apisix//deps/share/lua/5.1/apisix/plugins/reload/init.lua'
no file '/usr/local/apisix/apisix/plugins/reload.lua'
no file '/usr/local/apisix/apisix/plugins/reload/init.lua'
no file '/usr/local/openresty/site/lualib/apisix/plugins/reload.ljbc'
no file '/usr/local/openresty/site/lualib/apisix/plugins/reload/init.ljbc'
no file '/usr/local/openresty/lualib/apisix/plugins/reload.ljbc'
no file '/usr/local/openresty/lualib/apisix/plugins/reload/init.ljbc'
no file '/usr/local/openresty/site/lualib/apisix/plugins/reload.lua'
no file '/usr/local/openresty/site/lualib/apisix/plugins/reload/init.lua'
no file '/usr/local/openresty/lualib/apisix/plugins/reload.lua'
no file '/usr/local/openresty/lualib/apisix/plugins/reload/init.lua'
no file './apisix/plugins/reload.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/apisix/plugins/reload.lua'
no file '/usr/local/share/lua/5.1/apisix/plugins/reload.lua'
no file '/usr/local/share/lua/5.1/apisix/plugins/reload/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/reload.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/reload/init.lua'
no file '/usr/local/apisix/apisix/plugins/reload.lua'
no file './apisix/plugins/reload.lua'
no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/apisix/plugins/reload.lua'
no file '/usr/local/share/lua/5.1/apisix/plugins/reload.lua'
no file '/usr/local/share/lua/5.1/apisix/plugins/reload/init.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/reload.lua'
no file '/usr/local/openresty/luajit/share/lua/5.1/apisix/plugins/reload/init.lua'
no file '/usr/local/apisix//deps/lib64/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/apisix//deps/lib/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/openresty/site/lualib/apisix/plugins/reload.so'
no file '/usr/local/openresty/lualib/apisix/plugins/reload.so'
no file './apisix/plugins/reload.so'
no file '/usr/local/lib/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './apisix/plugins/reload.so'
no file '/usr/local/lib/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/apisix/plugins/reload.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/usr/local/apisix//deps/lib64/lua/5.1/apisix.so'
no file '/usr/local/apisix//deps/lib/lua/5.1/apisix.so'
no file '/usr/local/openresty/site/lualib/apisix.so'
no file '/usr/local/openresty/lualib/apisix.so'
no file './apisix.so'
no file '/usr/local/lib/lua/5.1/apisix.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/apisix.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './apisix.so'
no file '/usr/local/lib/lua/5.1/apisix.so'
no file '/usr/local/openresty/luajit/lib/lua/5.1/apisix.so'
no file '/usr/local/lib/lua/5.1/loadall.so', client: 127.0.0.1, server: , request: "GET /apisix/admin/plugins/reload HTTP/1.1", host: "
This error occurred when I used the api reload plugin. Never before
you can try make deps first.
First of all, I am rewriting the dockerfile in the official library, using the yum installation method of the centos system, and installing the compiled apisix. Secondly, I have used this method since 1.3. I don't know how you said make deps how to operate in this process, is it added to the dockerfile? Or does the generated docker image run at startup?
@nic-chen Can you answer it when you are free?
@backnero please use official image to confirm first. thanks.
use yum to install apisix 1.5
@backnero your way seems fine to me.
I guess it is because of your old data.
If you use a new etcd instance, can you still get this bug? And you can make a try with @nic-chen 's way.
I am trying to make a new deployment with version 2.0, including etcd database. However, with 130+ routing records, the workload of manual increase is still very large. During the inspection, I found that the routing data in etcd is not uniform because I have operated adminapi in different versions. Secondly, because I use ETCD in the k8S environment, I cannot use the etcdctl merge operation to perform V2->V3 operations in the online environment. Suggest:
- During the version change, it is recommended to add etcd data checker to perform data structure alignment operations, which will be more friendly to our operation and maintenance.
- v1.5->v2.0 recommends to do etcd version migration through program method. Although it will be very troublesome, the user experience will be greatly improved. For each official upgrade, we will deploy to production after multiple rounds of local testing. Still encounter unpredictable problems.
- The error prompt is too broad. By browsing the issues library, you can find that most loyal users have the same error for asking questions.
I wish apisix success and better and better! Thank you very much for your dedication.
Thank you very much for your suggestions, we will refer to it a lot.
thanks for suggestions. @backnero
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.