Bigwen-1 opened a new issue, #8118:
URL: https://github.com/apache/apisix/issues/8118

   ### Description
   
   hi,  你好: 
          我们希望upstream支持多泳道部署功能,即根据请求标签选择可以自行匹配不同的上游  在upstream.lua 
set_by_route方法做了些调整。但是发现下次请求时init.lua 中api_ctx 的node (字段:matched_route value 
upstream node)仍为上次筛选过的node, 非etcd中存储的全量  请问是否存在数据污染问题? 跟踪发现是从init.lua  
_M.http_access_phase()  router.router_http.match(api_ctx) -> radixtree_uri.lua 
_M.match(api_ctx)这步做的赋值
   
   upstream.lua 修改内容如下:
   function _M.set_by_route(route, api_ctx)
       if api_ctx.upstream_conf then
           -- upstream_conf has been set by traffic-split plugin
           return
       end
   
       local up_conf = api_ctx.matched_upstream
       if not up_conf then
           return 503, "missing upstream configuration in Route or Service"
       end
   
       local scheme = up_conf.scheme
       if up_conf.service_name then
           local new_nodes = up_conf.nodes
           if new_nodes == nil or next(new_nodes) == nil then
               new_nodes = up_conf.parent.value.upstream.nodes
           end
           up_conf.nodes = new_nodes
       end
   
       local hxlabel = ngx.req.get_headers()["X-Label"]
   
       local nodes_num = up_conf.nodes and #up_conf.nodes or 0
       if nodes_num == 0 then
           return HTTP_CODE_UPSTREAM_UNAVAILABLE, "no valid upstream node"
       end
       if ngx.req.get_headers()["X-Label"] then
           local label_nodes = up_conf.nodes
           local new_label_nodes = {}
           for i, n in ipairs(label_nodes) do
               if n.host == hxlabel then
                   local node = core.table.clone(n)
                   core.table.insert(new_label_nodes, node)
               end
           end
           label_nodes = new_label_nodes
           up_conf.nodes = label_nodes
       end
       set_directly(api_ctx, up_conf.type .. "#upstream_" .. tostring(up_conf),
               tostring(up_conf), up_conf)
       
       local nodes_count = up_conf.nodes and #up_conf.nodes or 0
       if nodes_count == 0 then
           return HTTP_CODE_UPSTREAM_UNAVAILABLE, "no valid upstream node"
       end
   
   .....
   
   ### Environment
   
   - APISIX version (run `apisix version`): 2.14.1
   - Operating system (run `uname -a`):
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`):
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to