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/10/02 09:19:12 UTC

[GitHub] [apisix] yocaning opened a new issue #5168: request help:

yocaning opened a new issue #5168:
URL: https://github.com/apache/apisix/issues/5168


   ### Issue description
   
   how to get etcd value in plugins
   
   this is my code
   
   ```
   authorizations_etcd, error = core.config.new("/authorizations", {
           automatic = true,
           item_schema = app_scheme
       })
       core.log.warn("key: " .. authorizations_etcd.key)
       if not authorizations_etcd then
           core.log.error("failed to create etcd instance for fetching authorizations: " .. error)
           return
       end
       local etcd_token ,err=authorizations_etcd:get("yocantest")
       for i =1 ,#etcd_token  do
           core.log.warn("etcd_token: " .. etcd_token[i])
       end
       if not err then
           core.log.warn(err)
       end
   ```
   
   the etcd has value ,but i cant get 
   
   > 
   
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):2.2
   - 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):3.4.0
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
   - 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] yocaning commented on issue #5168: request help:

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


   new request help:
   what should i do if i want the cache `authorizations_etcd` update after restart apisix 。or what i want is load the etcd data before restart apisix


-- 
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] yocaning commented on issue #5168: request help:

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


   ok ,i find that why i cant get ,because the etcd data dont change ,so the table dont update after i restart my apisix.
   by the way ,what should i do if i want the cache `authorizations_etcd` update after restart apisix 。


-- 
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] yocaning commented on issue #5168: request help: How to get ETCD data in plugins?

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


   > Is this related to #5234?
   
   yes,but the bug is that i find a unreasonable code design,so i add a bug report


-- 
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] yocaning commented on issue #5168: request help: How to get ETCD data in plugins?

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


   > > ok ,i find that why i cant get ,because the etcd data dont change ,so the table dont update after i restart my apisix. by the way ,what should i do if i want the cache `authorizations_etcd` update after restart apisix 。
   > 
   > Apache APISIX always fetch the full data from ETCD as it just starts. And now, the default behavior is that APISIX will load them in the init phase (before any requests can be handled).
   
   yes,see my code,init phase code
   function _M.init():
    authorizations_etcd, error = core.config.new("/authorizations", {
           automatic = true,
           item_schema = app_scheme
       })
       if not authorizations_etcd then
           core.log.error("failed to create etcd instance for fetching authorizations: " .. error)
           return
       end
   end 
   but when i restart apisix ,the etcd dont hava data until i change the key ,my etcd is ok ,and have data ,the apisix restart dont have 


-- 
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] tokers commented on issue #5168: request help:

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


   > ok ,i find that why i cant get ,because the etcd data dont change ,so the table dont update after i restart my apisix. by the way ,what should i do if i want the cache `authorizations_etcd` update after restart apisix 。
   
   Apache APISIX always fetch the full data from ETCD as it just starts. And now, the default behavior is that APISIX will load them in the init phase (before any requests can be handled).


-- 
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] tokers commented on issue #5168: request help: How to get ETCD data in plugins?

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


   Is this related to https://github.com/apache/apisix/issues/5234?


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