wklken commented on issue #12436:
URL: https://github.com/apache/apisix/issues/12436#issuecomment-3093188583

   apisix/init.lua
   
   ```lua
   local function parse_domain_in_route(route)
       local nodes = route.value.upstream.nodes
       core.log.error("parse_domain_in_route: route.value.upstream.nodes=", 
core.json.delay_encode(nodes, true))  -- add log here
       local new_nodes, err = upstream_util.parse_domain_for_nodes(nodes)
       if not new_nodes then
           return nil, err
       end
   
       local up_conf = route.dns_value and route.dns_value.upstream
       local ok = upstream_util.compare_upstream_node(up_conf, new_nodes)
       if ok then
           return route
       end
   
       -- don't modify the modifiedIndex to avoid plugin cache miss because of 
DNS resolve result
       -- has changed
   
       -- Here we copy the whole route instead of part of it,
       -- so that we can avoid going back from route.value to route during 
copying.
       route.dns_value = core.table.deepcopy(route).value
       route.dns_value.upstream.nodes = new_nodes
       core.log.info("parse route which contain domain: ",
                     core.json.delay_encode(route, true))
       core.log.error("parse_domain_in_route after parse domain: 
route.value.upstream=", core.json.delay_encode(route.value.upstream, true))   
-- add log here
       core.log.error("parse_domain_in_route after parse domain: 
route.value.upstream.nodes=", 
core.json.delay_encode(route.value.upstream.nodes, true))   -- add log here
       return route
   end
   ```
   
   got the logs
   
   1. here the route.value.upstream.nodes is original nodes(hots is domain)
   
   ``` 
   2025/07/20 03:41:08 [error] 519#519: *12037 [lua] init.lua:234: 
parse_domain_in_route(): parse_domain_in_route after parse domain: 
route.value.upstream.nodes=[{"port":80,"priority":1,"host":"httpbin","weight":100}],
 client: 10.1.1.1, server: _, request: "GET /api/apigw/prod/anything HTTP/1.1", 
host: "bkapi.example.com"
   ```
   
   2. here, the new reuqest, the route.value.upstream.nodes is original 
nodes(hots is domain); but `after parse domain` it replaced to the parsed nodes 
(host is ip)
   
   ```
   2025/07/20 03:41:45 [error] 519#519: *14537 [lua] init.lua:212: 
parse_domain_in_route(): parse_domain_in_route: 
route.value.upstream.nodes=[{"port":80,"priority":1,"host":"httpbin","weight":100}],
 client: 10.1.1.1, server: _, request: "GET /api/apigw/prod/anything HTTP/1.1", 
host: "bkapi.example.com"
   
   2025/07/20 03:41:45 [info] 519#519: *14537 [lua] init.lua:231: 
parse_domain_in_route(): parse route which contain domain: 
{"has_domain":true,"key":"/bk-gateway-apisix/services/apigw.prod.stage-4","dns_value":{"name":"apigw-prod-anything-get","upstream":{"parent":{"update_count":0,"key":"/bk-gateway-apisix/routes/apigw.prod.2347","createdIndex":5360,"value":{"name":"apigw-prod-anything-get","priority":0,"methods":["GET"],"labels":{"gateway.bk.tencent.com/gateway":"apigw","gateway.bk.tencent.com/stage":"prod"},"id":"apigw.prod.2347","desc":"Returns
 anything passed in request 
data.","create_time":1752566944,"status":1,"timeout":{"read":30,"connect":30,"send":30},"uris":["/api/apigw/prod/anything","/api/apigw/prod/anything/"],"upstream":"table:
 
0x7f1c8356f638","update_time":1752566944,"plugins":{"bk-proxy-rewrite":{"subpath_param_name":":ext","use_real_request_uri_unsafe":false,"uri":"/anything","match_subpath":false,"method":"GET"},"bk-resource-context":{"bk_resource_id":2347,"bk_res
 
ource_name":"anything_get","bk_resource_auth":{"verified_app_required":false,"verified_user_required":false,"resource_perm_required":false,"skip_user_verification":false},"bk_resource_auth_obj":{"verified_app_required":false,"verified_user_required":false,"resource_perm_required":false,"skip_user_verification":false}}},"service_id":"apigw.prod.stage-4"},"modifiedIndex":5360,"orig_modifiedIndex":5360,"has_domain":true,"clean_handlers":{}},"nodes":[{"priority":1,"domain":"httpbin","port":80,"host":"10.100.183.135","weight":100}],"pass_host":"node","type":"roundrobin","scheme":"http","hash_on":"vars","timeout":{"read":30,"connect":30,"send":30}},"desc":"正式环境","id":"apigw.prod.2347","labels":"table:
 0x7f1c8356f000","create_time":1752482957,"timeout":"table: 
0x7f1c8356f048","update_time":1752566944,"plugins":{"bk-auth-validate":{},"bk-proxy-rewrite":"table:
 
0x7f1c8356f2d0","bk-delete-cookie":{},"bk-log-context":{},"prometheus":{"prefer_name":false},"bk-real-ip":{},"bk-stage-conte
 xt":{"jwt_private_key":"
   
   2025/07/20 03:41:45 [error] 519#519: *14537 [lua] init.lua:233: 
parse_domain_in_route(): parse_domain_in_route after parse domain: 
route.value.upstream={"parent":{"update_count":0,"key":"/bk-gateway-apisix/routes/apigw.prod.2347","createdIndex":5360,"value":{"name":"apigw-prod-anything-get","priority":0,"methods":["GET"],"labels":{"gateway.bk.tencent.com/gateway":"apigw","gateway.bk.tencent.com/stage":"prod"},"id":"apigw.prod.2347","desc":"Returns
 anything passed in request 
data.","create_time":1752566944,"status":1,"timeout":{"read":30,"connect":30,"send":30},"uris":["/api/apigw/prod/anything","/api/apigw/prod/anything/"],"upstream":{"parent":"table:
 
0x7f1c827a2378","nodes":[{"priority":1,"domain":"httpbin","port":80,"host":"10.100.183.135","weight":100}],"pass_host":"node","type":"roundrobin","scheme":"http","hash_on":"vars","timeout":{"read":30,"connect":30,"send":30}},"update_time":1752566944,"plugins":{"bk-proxy-rewrite":{"subpath_param_name":":ext","use_real_request_uri_unsa
 
fe":false,"uri":"/anything","match_subpath":false,"method":"GET"},"bk-resource-context":{"bk_resource_id":2347,"bk_resource_name":"anything_get","bk_resource_auth":{"verified_app_required":false,"verified_user_required":false,"resource_perm_required":false,"skip_user_verification":false},"bk_resource_auth_obj":{"verified_app_required":false,"verified_user_required":false,"resource_perm_required":false,"skip_user_verification":false}}},"service_id":"apigw.prod.stage-4"},"modifiedIndex":5360,"orig_modifiedIndex":5360,"has_domain":true,"clean_handlers":{}},"nodes":"table:
 
0x7f1c82da69f0","pass_host":"node","type":"roundrobin","scheme":"http","hash_on":"vars","timeout":"table:
 0x7f1c8356f818"}, client: 10.1.1.1, server: _, request: "GET 
/api/apigw/prod/anything HTTP/1.1", host: "bkapi.example.com"
   ```
   
   3. all the following request will use the parsed nodes, and can't detect the 
change of the domain ip.
   
   ```
   2025/07/20 03:41:45 [error] 519#519: *14537 [lua] init.lua:234: 
parse_domain_in_route(): parse_domain_in_route after parse domain: 
route.value.upstream.nodes=[{"priority":1,"domain":"httpbin","port":80,"host":"10.100.183.135","weight":100}],
 client: 10.1.1.1, server: _, request: "GET /api/apigw/prod/anything HTTP/1.1", 
host: "bkapi.example.com"
   ```
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to