You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/09/16 06:11:34 UTC

[GitHub] [apisix] tokers commented on a change in pull request #2233: change: check etcd cluster version when init_etcd

tokers commented on a change in pull request #2233:
URL: https://github.com/apache/apisix/pull/2233#discussion_r489186175



##########
File path: bin/apisix
##########
@@ -885,20 +939,44 @@ local function init_etcd(show_output)
         yaml_conf.etcd.host = {yaml_conf.etcd.host}
     end
 
+    local cluster_version
     local host_count = #(yaml_conf.etcd.host)
-
-    local etcd_ok = false
+    -- check the etcd cluster version
     for index, host in ipairs(yaml_conf.etcd.host) do
-        -- check if etcd version above 3.4
-        cmd = "curl " .. host .. "/version 2>&1"
-        local res = excute_cmd(cmd)
-        local op_ver = str_split(res, "\"")[4]
-        local need_ver = "3.4.0"
-        if not check_version(op_ver, need_ver) then
-            io.stderr:write("etcd version must >=", need_ver, " current ", op_ver, "\n")
+        uri = host .. "/version"
+        local cmd = string.format("curl -s -m %d %s | sed -e 's/[{}]/''/g'", timeout * 2, uri)
+        local res = execute_cmd(cmd)
+        local m = split(res, [[%s*,%s*]])

Review comment:
       That'd be better.

##########
File path: bin/apisix
##########
@@ -885,20 +939,44 @@ local function init_etcd(show_output)
         yaml_conf.etcd.host = {yaml_conf.etcd.host}
     end
 
+    local cluster_version
     local host_count = #(yaml_conf.etcd.host)
-
-    local etcd_ok = false
+    -- check the etcd cluster version
     for index, host in ipairs(yaml_conf.etcd.host) do
-        -- check if etcd version above 3.4
-        cmd = "curl " .. host .. "/version 2>&1"
-        local res = excute_cmd(cmd)
-        local op_ver = str_split(res, "\"")[4]
-        local need_ver = "3.4.0"
-        if not check_version(op_ver, need_ver) then
-            io.stderr:write("etcd version must >=", need_ver, " current ", op_ver, "\n")
+        uri = host .. "/version"
+        local cmd = string.format("curl -s -m %d %s | sed -e 's/[{}]/''/g'", timeout * 2, uri)

Review comment:
       OK, will use jkjson.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org