Skip to content

Commit 6b40832

Browse files
dabueSaberMaster
authored andcommitted
[bugfix(CLI)]: check whether the user has enabled etcd v2 protocol. (apache#1665)
1 parent 2aba8c2 commit 6b40832

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.travis/apisix_cli_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ fi
115115

116116
set -ex
117117

118-
echo "rollback to the default admin config"
118+
echo "passed: rollback to the default admin config"

bin/apisix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,17 @@ local function init_etcd(show_output)
781781

782782
local host_count = #(yaml_conf.etcd.host)
783783

784+
-- check whether the user has enabled etcd v2 protocol
785+
for index, host in ipairs(yaml_conf.etcd.host) do
786+
uri = host .. "/v2/keys"
787+
local cmd = "curl -i -m ".. timeout * 2 .. " -o /dev/null -s -w %{http_code} " .. uri
788+
local res = excute_cmd(cmd)
789+
if res == "404" then
790+
io.stderr:write(string.format("failed: please make sure that you have enabled the v2 protocol of etcd on %s.\n", host))
791+
return
792+
end
793+
end
794+
784795
local etcd_ok = false
785796
for index, host in ipairs(yaml_conf.etcd.host) do
786797

0 commit comments

Comments
 (0)