From a55e8ef01fd23f81629379a35171ad2b471c0b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Fri, 21 Oct 2022 13:41:02 +0800 Subject: [PATCH] chore: don't implement "server_version" twice (#8131) --- apisix/core/config_etcd.lua | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua index e432b05d950d..80d6d23e2493 100644 --- a/apisix/core/config_etcd.lua +++ b/apisix/core/config_etcd.lua @@ -716,32 +716,17 @@ function _M.fetch_created_obj(key) end -local function read_etcd_version(etcd_cli) - if not etcd_cli then - return nil, "not inited" - end - - local data, err = etcd_cli:version() - if not data then - return nil, err - end - - local body = data.body - if type(body) ~= "table" then - return nil, "failed to read response body when try to fetch etcd " - .. "version" - end - - return body -end - - function _M.server_version(self) if not self.running then return nil, "stopped" end - return read_etcd_version(self.etcd_cli) + local res, err = etcd_apisix.server_version() + if not res then + return nil, err + end + + return res.body end