Skip to content
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

fix(tcp failure) disabling tcp check on http(s) checks is not allowed #55

Merged
merged 1 commit into from
Sep 20, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)
and `post_local` won't anymore call `poll` on a running worker automatically,
for more information, see:
https://github.com/Kong/lua-resty-worker-events#200-16-september-2020
* BREAKING: tcp_failures can no longer be 0 on http(s) checks (unless http(s)_failures
are also set to 0) [#55](https://github.com/Kong/lua-resty-healthcheck/pull/55)
* feature: Added support for https_sni [#49](https://github.com/Kong/lua-resty-healthcheck/pull/49)
* fix: properly log line numbers by using tail calls [#29](https://github.com/Kong/lua-resty-healthcheck/pull/29)
* fix: when not providing a hostname, use IP [#48](https://github.com/Kong/lua-resty-healthcheck/pull/48)
Expand Down
16 changes: 16 additions & 0 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,22 @@ function _M.new(opts)
assert(self.checks.passive.unhealthy.http_failures < 255, "checks.passive.unhealthy.http_failures must be at most 254")
assert(self.checks.passive.unhealthy.timeouts < 255, "checks.passive.unhealthy.timeouts must be at most 254")

-- since counter types are independent (tcp failure does not also increment http failure)
-- a TCP threshold of 0 is not allowed for enabled http checks.
-- It would make tcp failures go unnoticed because the http failure counter is not
-- incremented and a tcp threshold of 0 means disabled, and hence it would never trip.
-- See https://github.com/Kong/lua-resty-healthcheck/issues/30
if self.checks.passive.type == "http" or self.checks.passive.type == "https" then
if self.checks.passive.unhealthy.http_failures > 0 then
assert(self.checks.passive.unhealthy.tcp_failures > 0, "self.checks.passive.unhealthy.tcp_failures must be >0 for http(s) checks with http_failures >0")
end
end
if self.checks.active.type == "http" or self.checks.active.type == "https" then
if self.checks.active.unhealthy.http_failures > 0 then
assert(self.checks.active.unhealthy.tcp_failures > 0, "self.checks.active.unhealthy.tcp_failures must be > 0 for http(s) checks with http_failures >0")
end
end

if opts.test then
self.test_get_counter = test_get_counter
end
Expand Down
4 changes: 2 additions & 2 deletions t/07-report_tcp_failure.t
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ qq{
unhealthy = {
interval = 999, -- we don't want active checks
tcp_failures = 0,
http_failures = 5,
http_failures = 0,
}
},
passive = {
Expand Down Expand Up @@ -208,7 +208,7 @@ qq{
},
unhealthy = {
tcp_failures = 0,
http_failures = 5,
http_failures = 0,
}
}
}
Expand Down