Skip to content

test: fix logic of retry in health check #141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/resty/etcd/v3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ local function _request_uri(self, method, uri, opts, timeout, ignore_auth)
end
else
local max_retry = #self.endpoints * health_check.conf.max_fails + 1
for _ = 1, max_retry do
for i = 1, max_retry do
res, err = http_request_uri(self, http_cli, method, uri, body, headers, keepalive)
if err then
if err == "has no healthy etcd endpoint available" then
Expand All @@ -152,9 +152,16 @@ local function _request_uri(self, method, uri, opts, timeout, ignore_auth)
else
break
end
if i == max_retry then
return nil, err
end
end
end

if not res then
return nil, "request etcd get nil response"
end

if not typeof.string(res.body) then
return res
end
Expand Down