You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/27 11:37:07 UTC

[GitHub] [apisix] nanamikon opened a new issue #4683: request help: How to filter node according to the metadata in the balance phase

nanamikon opened a new issue #4683:
URL: https://github.com/apache/apisix/issues/4683


   ### Issue description
   Sometimes,  we should shield traffic immediately ,  for example, a dedicated network  occurs an exception。 
   We can shield nodes in the specific idc  marked by the metadata to recovery at once。
   
   So I think global plugin is a good choice to do this, but I have  to modify the balance.lua,  such as passing plugin conf to *create_server_picker* and so on.
   
   Now I find that new balance phase has been added to apisix in version 2.8,    should I  filter the node in this phase?
   Or add ing a new balance type is a good choice?
   
   ### Environment
   
   Request help without environment information will be ignored or closed.
   
   * apisix version (cmd: `apisix version`):
   * OS (cmd: `uname -a`):
   * OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   * etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   * apisix-dashboard version, if have:
   * luarocks version, if the issue is about installation (cmd: `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: notifications-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander closed issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #4683:
URL: https://github.com/apache/apisix/issues/4683


   


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] tzssangglass commented on issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #4683:
URL: https://github.com/apache/apisix/issues/4683#issuecomment-887491956


   > 添加一个新的平衡类型是一个不错的选择
   
   I think it's better.


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander commented on issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4683:
URL: https://github.com/apache/apisix/issues/4683#issuecomment-888122177


   The balancer belongs to Upstream, while plugin config belongs to Route. If multiple routes have the same upstream, filter the nodes with plugin config when creating balancer is not correct. We need to filter it in the balancer's `get(ctx)` method, which already can access plugin config via ctx.


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] nanamikon commented on issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
nanamikon commented on issue #4683:
URL: https://github.com/apache/apisix/issues/4683#issuecomment-888913846


   Thanks,  I get it


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] spacewander commented on issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4683:
URL: https://github.com/apache/apisix/issues/4683#issuecomment-887933857


   +1
   The node metadata is designed to work with user-defined balancer.


-- 
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-unsubscribe@apisix.apache.org

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



[GitHub] [apisix] nanamikon commented on issue #4683: request help: How to filter node according to the metadata in the balance phase

Posted by GitBox <gi...@apache.org>.
nanamikon commented on issue #4683:
URL: https://github.com/apache/apisix/issues/4683#issuecomment-887965991


   Thanks for suggestion,  if I perfer to  create a new balance type ,  the following issues have to be solved
   1. I have to modify the new function of balance type implements,  because I have to pass plugin conf for determining which node to be shielded
   And then I have to modify balance.lua to pass plugin conf too. 
   2.  Idc Traffic shield is a global feature,  and I think it is not related with special balance type.  Refer to priority.lua , I should add a new  loadbalance type to filter nodes by plugin conf, and then forward to others; 
   
   Add new lua file, traffic_shield.lua
   ```
   function _M.new(up_nodes, upstream, plugin_conf, picker_mod)
      local filter_nodes = filter_by_meta(up_nodes, plugin_conf)
      local picker = picker_mod.new(filter_nodes , upstream)
       ......
   end
   ```
   
   Modify balance.lua
   ```
   local function create_server_picker(upstream, checker, plugin_conf)
      ....
     if picker then
           local traffic_shield_picker = require("apisix.balancer.traffic_shield")
           local up_nodes = fetch_health_nodes(upstream, checker, filter_idc_ids)
           if #up_nodes._priority_index > 1 then
               core.log.info("upstream nodes: ", core.json.delay_encode(up_nodes))
               return traffic_shield_picker.new(up_nodes, upstream, plugin_conf, priority_balancer,  picker)
           end
   
           core.log.info("upstream nodes: ",
                         core.json.delay_encode(up_nodes[up_nodes._priority_index[1]]))
           return traffic_shield_picker.new(up_nodes[up_nodes._priority_index[1]], upstream, plugin_conf, picker)
       end
       ....
   end
   
   ```
   
   
   But I think I will run into trouble when merging code from newest apisix version later,   because I modify balance.lua....
   So what about adding a new balance filter phase for filter nodes
   
   
   
   


-- 
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-unsubscribe@apisix.apache.org

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