Skip to content

feat: support retry in health-check#131

Merged
spacewander merged 6 commits into
api7:masterfrom
Yiyiyimu:feat/health-check-retry
Jun 22, 2021
Merged

feat: support retry in health-check#131
spacewander merged 6 commits into
api7:masterfrom
Yiyiyimu:feat/health-check-retry

Conversation

@Yiyiyimu

@Yiyiyimu Yiyiyimu commented Jun 21, 2021

Copy link
Copy Markdown
Contributor

Signed-off-by: yiyiyimu [email protected]

  1. add option retry in health-check. When it is enabled, operations would keep trying the same endpoint till unhealthy, and then other endpoints, until success or no endpoints healthy. So we could ensure each operation would send to etcd with best effort.
    Currently not support for read_watch since it would be better to close the original connection and create a new watch with a new endpoint.
  2. move choose_enpoint into request_uri and request_chunk so it could find alternative endpoint easier

@Yiyiyimu
Yiyiyimu force-pushed the feat/health-check-retry branch from a6c14c2 to 3daee06 Compare June 21, 2021 23:15
@Yiyiyimu Yiyiyimu changed the title feat: support retry in health-check for non-watch operation feat: support retry in health-check Jun 21, 2021
@Yiyiyimu

Copy link
Copy Markdown
Contributor Author

cc @tzssangglass @spacewander

Comment thread lib/resty/etcd/v3.lua
end

self.init_count = (self.init_count or 0) + 1
local pos = self.init_count % endpoints_len + 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended to skip the first endpoint? As the minimal init_count here is 1.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also failed to figure out the purpose of this. It's the implementation of the earliest v3 API.
Hi @nic-chen do you remember why is it set so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about self.init_count = (self.init_count or -1) + 1 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don’t remember, it’s contributed by the community

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Fixed as suggested. Thanks!

Comment thread lib/resty/etcd/v3.lua Outdated
Comment thread lib/resty/etcd/v3.lua Outdated
elseif body.error and body.error.http_code >= 500 then
if health_check.conf ~= nil then
-- health_check retry should do nothing here
-- and let connection broke to create a new one

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

broke => broker?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I mean closed 🤣 fixed

Comment thread lib/resty/etcd/v3.lua Outdated
Comment thread lib/resty/etcd/v3.lua Outdated
Comment thread lib/resty/etcd/v3.lua
return _request_uri(self, endpoint, "GET",
endpoint.http_host .. "/v2/stats/self",
nil, self.timeout)
return _request_uri(self, "GET", "/v2/stats/self", nil, self.timeout)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not about this PR: is there /v2 API in the /v3 file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for API exists in both version, like /get and /put

Yiyiyimu added 4 commits June 21, 2021 23:43
Signed-off-by: yiyiyimu <[email protected]>
Signed-off-by: yiyiyimu <[email protected]>
Signed-off-by: yiyiyimu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants