Skip to content

Commit 4aedb10

Browse files
authored
fix: watch timeout should not be considered as unhealthy (#205)
1 parent 354b5ff commit 4aedb10

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/resty/etcd/v3.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,6 @@ end
10861086
function _grpc_M.read_grpc_watch_stream(self, watching_stream)
10871087
local res, err = watching_stream:recv()
10881088
if not res then
1089-
health_check.report_failure(self.conn.http_host)
10901089
return nil, err
10911090
end
10921091

t/v3/grpc/health_check.t

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,40 @@ checked val as expect: abc
449449
--- error_log
450450
choose endpoint: http://127.0.0.1:12379
451451
choose endpoint: http://127.0.0.1:22379
452+
453+
454+
455+
=== TEST 12: watch timeout should not be considered as unhealthy
456+
--- http_config eval: $::HttpConfig
457+
--- config
458+
location /t {
459+
content_by_lua_block {
460+
local health_check, err = require "resty.etcd.health_check" .init({
461+
shm_name = "etcd_cluster_health_check",
462+
fail_timeout = 10,
463+
max_fails = 1,
464+
})
465+
466+
local etcd, err = require "resty.etcd" .new({
467+
protocol = "v3",
468+
http_host = {
469+
"http://127.0.0.1:22379",
470+
},
471+
use_grpc = true,
472+
init_count = -1,
473+
})
474+
475+
local body_chunk_fun, err = etcd:create_grpc_watch_stream("/trigger_unhealthy", {}, {timeout = 1})
476+
if not body_chunk_fun then
477+
ngx.say(err)
478+
return
479+
end
480+
481+
local _, err = etcd:read_grpc_watch_stream(body_chunk_fun)
482+
ngx.say(err)
483+
}
484+
}
485+
--- no_error_log eval
486+
qr/update endpoint: http:\/\/127.0.0.1:22379 to unhealthy/
487+
--- response_body_like eval
488+
qr/failed to recv: /

0 commit comments

Comments
 (0)