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 2020/04/19 08:46:29 UTC

[GitHub] [incubator-apisix] membphis opened a new issue #1473: bug: 'global_rule' is a boolean value

membphis opened a new issue #1473: bug: 'global_rule' is a boolean value
URL: https://github.com/apache/incubator-apisix/issues/1473
 
 
   ![image](https://user-images.githubusercontent.com/6814606/79683506-299dd380-825d-11ea-9ef0-ca1a34645382.png)
   
   ```diff
   [proxychains] DLL init
   diff --git a/apisix/init.lua b/apisix/init.lua
   index aa8598e8..1e6b1efb 100644
   --- a/apisix/init.lua
   +++ b/apisix/init.lua
   @@ -264,14 +264,16 @@ function _M.http_access_phase()
           and #router.global_rules.values > 0 then
            local plugins = core.tablepool.fetch("plugins", 32, 0)
            for _, global_rule in ipairs(router.global_rules.values) do
   -            api_ctx.conf_type = "global_rule"
   -            api_ctx.conf_version = global_rule.modifiedIndex
   -            api_ctx.conf_id = global_rule.value.id
   -
   -            core.table.clear(plugins)
   -            api_ctx.plugins = plugin.filter(global_rule, plugins)
   -            run_plugin("rewrite", plugins, api_ctx)
   -            run_plugin("access", plugins, api_ctx)
   +            if type(global_rule) == "table" then
   +                api_ctx.conf_type = "global_rule"
   +                api_ctx.conf_version = global_rule.modifiedIndex
   +                api_ctx.conf_id = global_rule.value.id
   +
   +                core.table.clear(plugins)
   +                api_ctx.plugins = plugin.filter(global_rule, plugins)
   +                run_plugin("rewrite", plugins, api_ctx)
   +                run_plugin("access", plugins, api_ctx)
   +            end
            end
   
            core.tablepool.release("plugins", plugins)
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-apisix] spacewander commented on issue #1473: bug: 'global_rule' is a boolean value

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


   In Lua, we can implement custom iterator to iterate table, for instance:
   ```lua
   local t = {{"a"}, false, {"b"}}
   
   local function _iterate_values(self, tab)
       while true do
           self.idx = self.idx + 1
           local v = tab[self.idx]
           if type(v) == "table" then
               return self.idx, v
           end
           if v == nil then
               return nil, nil
           end
           -- skip other type of values
       end
   end
   
   local function iterate_values(tab)
       local iter = setmetatable({idx = 0}, {__call = _iterate_values})
       return iter, tab, 0
   end
   
   local j = 0
   for k = 1, 1e5 do
       for i, v in iterate_values(t) do
           j = j + i
       end
   end
   
   ```


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

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



[GitHub] [incubator-apisix] membphis commented on issue #1473: bug: 'global_rule' is a boolean value

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1473:
URL: https://github.com/apache/incubator-apisix/issues/1473#issuecomment-617592379


   Well done, a very good solution. We can use this method to iterate over all values.


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

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



[GitHub] [incubator-apisix] spacewander commented on issue #1473: bug: 'global_rule' is a boolean value

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


   I guess the problem happens there: 
   https://github.com/apache/incubator-apisix/blob/7440192f8fdf679dadc3e816767762e6047d0893/apisix/core/config_etcd.lua#L284
   
   I am not quite understand the tombstone mechanism. Is the memory footprint so high that we need to use some trick? Can we implement an iterator to hide the detail?


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

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



[GitHub] [incubator-apisix] membphis edited a comment on issue #1473: bug: 'global_rule' is a boolean value

Posted by GitBox <gi...@apache.org>.
membphis edited a comment on issue #1473:
URL: https://github.com/apache/incubator-apisix/issues/1473#issuecomment-617211595


   @spacewander you are right.
   
   If the original data is deleted, it is marked as "false".
   
   This is why we need to check the data type first.
   
   > Can we implement an iterator to hide the detail?
   
   can you provide an example?  I can't imagine 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.

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



[GitHub] [incubator-apisix] membphis commented on issue #1473: bug: 'global_rule' is a boolean value

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1473:
URL: https://github.com/apache/incubator-apisix/issues/1473#issuecomment-617211595


   @spacewander you are right.
   
   If the original data is deleted, it is marked as "false".
   
   This is why we need to check the data type first.


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

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