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(etcd): reuse cli and enable keepalive #9420

Merged
merged 4 commits into from
May 17, 2023
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
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
monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved
etcd auth failed
etcd auth failed
etcd auth failed
monkeyDluffy6017 marked this conversation as resolved.
Show resolved Hide resolved



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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hijacking resty.etcd.new does not work after the cli is created once, because it's reused afterwards.

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