membphis commented on a change in pull request #1283: Add multiple etcd support.
URL: https://github.com/apache/incubator-apisix/pull/1283#discussion_r394040197
##########
File path: bin/apisix
##########
@@ -706,28 +706,43 @@ local function init_etcd(show_output)
end
local etcd_conf = yaml_conf.etcd
- local uri = etcd_conf.host .. "/v2/keys" .. (etcd_conf.prefix or "")
local timeout = etcd_conf.timeout or 3
+ local uri
+ local hostCount = table.getn(yaml_conf.etcd.host)
- for _, dir_name in ipairs({"/routes", "/upstreams", "/services",
- "/plugins", "/consumers", "/node_status",
- "/ssl", "/global_rules", "/stream_routes",
- "/proto"}) do
- local cmd = "curl " .. uri .. dir_name
+ for index, host in ipairs(yaml_conf.etcd.host) do
+
+ local is_success = true
+ uri = host .. "/v2/keys" .. (etcd_conf.prefix or "")
+
+ for _, dir_name in ipairs({"/routes", "/upstreams", "/services",
+ "/plugins", "/consumers", "/node_status",
+ "/ssl", "/global_rules", "/stream_routes",
+ "/proto"}) do
+ local cmd = "curl " .. uri .. dir_name
.. "?prev_exist=false -X PUT -d dir=true "
.. "--connect-timeout " .. timeout
.. " --max-time " .. timeout * 2 .. " --retry 1 2>&1"
- local res = exec(cmd)
- if not res:find("index", 1, true)
- and not res:find("createdIndex", 1, true) then
- error(cmd .. "\n" .. res)
+ local res = exec(cmd)
+ if not res:find("index", 1, true)
+ and not res:find("createdIndex", 1, true) then
+ is_success = false;
Review comment:
code style: no separator is used by default.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services