bugfix: failed to set server peer when upstreams.node is address in apisix.yaml (#1824)

Fix #1798
This commit is contained in:
wrl96 2020-07-10 18:47:11 +08:00 committed by GitHub
parent e598e6fa6a
commit 54abe58315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 4 deletions

View File

@ -311,7 +311,7 @@ end
function _M.fetch_created_obj(key)
return created_obj[key]
return created_obj[sub_str(key, 2)]
end

View File

@ -313,9 +313,14 @@ function _M.http_access_phase()
local enable_websocket
local up_id = route.value.upstream_id
if up_id then
local upstreams_etcd = core.config.fetch_created_obj("/upstreams")
if upstreams_etcd then
local upstream = upstreams_etcd:get(tostring(up_id))
local upstreams = core.config.fetch_created_obj("/upstreams")
if upstreams then
local upstream = upstreams:get(tostring(up_id))
if not upstream then
core.log.error("failed to find upstream by id: " .. up_id)
return core.response.exit(500)
end
if upstream.has_domain then
local _, err = parsed_domain(upstream, api_ctx.conf_version,
parse_domain_in_up, upstream)

View File

@ -139,3 +139,25 @@ GET /hello
hello world
--- no_error_log
[error]
=== TEST 5: upstream domain
--- yaml_config eval: $::yaml_config
--- apisix_yaml
routes:
-
uri: /get
upstream_id: 1
upstreams:
-
id: 1
nodes:
"httpbin.org:80": 1
type: roundrobin
#END
--- request
GET /get
--- error_code: 200
--- no_error_log
[error]