diff --git a/lib/resty/etcd/v3.lua b/lib/resty/etcd/v3.lua index 19708c11..b73e5c4c 100644 --- a/lib/resty/etcd/v3.lua +++ b/lib/resty/etcd/v3.lua @@ -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 diff --git a/t/v3/grpc/health_check.t b/t/v3/grpc/health_check.t index 0ad58d15..f08ebac0 100644 --- a/t/v3/grpc/health_check.t +++ b/t/v3/grpc/health_check.t @@ -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: /