hmthoo commented on issue #8117:
URL: https://github.com/apache/apisix/issues/8117#issuecomment-1288765824

   > > How to get the node information of an existing upstream to add to 
up_conf?For example, get the nodes information in my test upstream 
"upstream-test-a" and add it to the variable up_conf.
   > 
   > `ctx.matched_upstream`, you can dump ctx by `ngx.log(ngx.WARN, "ctx : ", 
require("inspect")(ctx, {depth = 2}))`, and search info in ctx.
   
   ### code 
   ```
       local up_conf = {
           type = "roundrobin",
           nodes = {
               {host = "192.168.100.92" , port = 8088 , weight = 10},
               {host = "192.168.100.91" , port = 8088 , weight = 10},
           }
       }
   
       core.log.warn(core.json.delay_encode(up_conf.nodes, true))
   
       local upstream_key = up_conf.type .. "#route_" .. matched_route.value.id
       upstream.set(ctx, upstream_key, ctx.conf_version, up_conf)
   ```
   
   ### error.log
   ```
   2022/10/24 09:51:57 [warn] 6666#6666: *35590445 [lua] 
saas-canary-dispatch.lua:63: phase_func(): 
[{"weight":10,"host":"192.168.100.91","port":8088},{"weight":10,"host":"192.168.100.92","port":8088}],
 client: 10.10.40.52, server: _, request: "GET /test/tologin HTTP/2.0", host: 
"test.com"
   2022/10/24 09:51:57 [error] 6666#6666: *35590445 lua entry thread aborted: 
runtime error: /usr/local/apisix/apisix/balancer.lua:55: table index is nil
   stack traceback:
   coroutine 0:
        /usr/local/apisix/apisix/balancer.lua: in function 'transform_node'
        /usr/local/apisix/apisix/balancer.lua:69: in function 
'fetch_health_nodes'
        /usr/local/apisix/apisix/balancer.lua:115: in function 'create_obj_fun'
        /usr/local/apisix/apisix/core/lrucache.lua:95: in function 
'lrucache_server_picker'
        /usr/local/apisix/apisix/balancer.lua:247: in function 'pick_server'
        /usr/local/apisix/apisix/init.lua:547: in function 'http_access_phase'
        access_by_lua(nginx.conf:344):2: in main chunk, client: 10.10.40.52, 
server: _, request: "GET /test/tologin HTTP/2.0", host: "test.com"
   ```
   
   ### question
   when I try to add more than one nodes in "up_conf.nodes" , an error is 
reported 


-- 
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