Skip to content

Commit

Permalink
fix: watch timeout should not be considered as unhealthy (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacewander authored Apr 4, 2023
1 parent 354b5ff commit 4aedb10
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/resty/etcd/v3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,6 @@ end
function _grpc_M.read_grpc_watch_stream(self, watching_stream)
local res, err = watching_stream:recv()
if not res then
health_check.report_failure(self.conn.http_host)
return nil, err
end

Expand Down
37 changes: 37 additions & 0 deletions t/v3/grpc/health_check.t
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,40 @@ checked val as expect: abc
--- error_log
choose endpoint: http://127.0.0.1:12379
choose endpoint: http://127.0.0.1:22379
=== TEST 12: watch timeout should not be considered as unhealthy
--- http_config eval: $::HttpConfig
--- config
location /t {
content_by_lua_block {
local health_check, err = require "resty.etcd.health_check" .init({
shm_name = "etcd_cluster_health_check",
fail_timeout = 10,
max_fails = 1,
})
local etcd, err = require "resty.etcd" .new({
protocol = "v3",
http_host = {
"http://127.0.0.1:22379",
},
use_grpc = true,
init_count = -1,
})
local body_chunk_fun, err = etcd:create_grpc_watch_stream("/trigger_unhealthy", {}, {timeout = 1})
if not body_chunk_fun then
ngx.say(err)
return
end
local _, err = etcd:read_grpc_watch_stream(body_chunk_fun)
ngx.say(err)
}
}
--- no_error_log eval
qr/update endpoint: http:\/\/127.0.0.1:22379 to unhealthy/
--- response_body_like eval
qr/failed to recv: /

0 comments on commit 4aedb10

Please sign in to comment.