Skip to content

Commit

Permalink
fix(etcd): reuse cli and enable keepalive (apache#9420)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingluo authored and AlinsRan committed Jul 7, 2023
1 parent 33de9a8 commit 80e0482
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
3 changes: 3 additions & 0 deletions apisix/cli/snippet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ upstream apisix_conf_backend {
local conf_server = require("apisix.conf_server")
conf_server.balancer()
}
keepalive 320;
keepalive_requests 1000;
keepalive_timeout 60s;
}
{% if trusted_ca_cert then %}
Expand Down
4 changes: 1 addition & 3 deletions apisix/core/etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,7 @@ do
return nil, nil, err
end

if tmp_etcd_cli.use_grpc then
etcd_cli = tmp_etcd_cli
end
etcd_cli = tmp_etcd_cli

return tmp_etcd_cli, prefix
end
Expand Down
1 change: 0 additions & 1 deletion t/core/config_etcd.t
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ qr/etcd auth failed/
etcd auth failed
etcd auth failed
etcd auth failed
etcd auth failed



Expand Down
32 changes: 0 additions & 32 deletions t/core/etcd.t
Original file line number Diff line number Diff line change
Expand Up @@ -401,35 +401,3 @@ qr/init_by_lua:\d+: \S+/
init_by_lua:12: ab
init_by_lua:19: 200
init_by_lua:26: 404



=== TEST 8: error handling in server_version
--- yaml_config
deployment:
role: traditional
role_traditional:
config_provider: etcd
etcd:
host:
- "http://127.0.0.1:2379"
prefix: "/apisix"
--- config
location /t {
content_by_lua_block {
local etcd_lib = require("resty.etcd")
-- the mock won't take effect when using gRPC because the connection will be cached
etcd_lib.new = function()
return nil, "ouch"
end
local etcd = require("apisix.core.etcd")
local res, err = etcd.server_version()
ngx.say(err)
}
}
--- request
GET /t
--- response_body
ouch
--- error_log
failed to get server_info from etcd

0 comments on commit 80e0482

Please sign in to comment.