You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "zxyao145 (via GitHub)" <gi...@apache.org> on 2023/08/28 09:32:29 UTC
[GitHub] [apisix] zxyao145 opened a new issue, #10096: bug: os.getenv always is nil
zxyao145 opened a new issue, #10096:
URL: https://github.com/apache/apisix/issues/10096
### Current Behavior
In the lua plugin, when using `os.getenv` to get environment variable, the return value is always nil:
```
local pod_ip
function _M.getpod_ip()
if pod_ip then
return pod_ip
end
pod_ip = os.getenv("POD_IP")
log.error("get pod_ip result: ", pod_ip)
if pod_ip == nil then
pod_ip = "127.0.0.1"
end
return pod_ip
end
```

### Expected Behavior
get environment variables correctly.
### Error Logs
see the picture
### Steps to Reproduce
Code as described above, and use it in plugins.
In my case, it's in the OpenTelemetry plugin and we need to expose the IP address.
### Environment
- APISIX version (run `apisix version`): 2.14.1
- Operating system (run `uname -a`): api7/apisix-base:1.19.9.1.6
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): 1.19.9.1
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): 3.4.0
- 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: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] Revolyssup commented on issue #10096: bug: os.getenv always is nil
Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on issue #10096:
URL: https://github.com/apache/apisix/issues/10096#issuecomment-1695558520
@zxyao145 The env variables are not automatically passed in the nginx process. You need to declare them [here](https://github.com/apache/apisix/blob/704645f6114ce6f2a4fe79857a8049e693f3878c/conf/config-default.yaml#L168) so that APISIX can add them explicitly in your config.
--
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] zxyao145 commented on issue #10096: bug: os.getenv always is nil
Posted by "zxyao145 (via GitHub)" <gi...@apache.org>.
zxyao145 commented on issue #10096:
URL: https://github.com/apache/apisix/issues/10096#issuecomment-1695596573
@Revolyssup Thanks a lot! This is helpful!
--
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] zxyao145 closed issue #10096: bug: os.getenv always is nil
Posted by "zxyao145 (via GitHub)" <gi...@apache.org>.
zxyao145 closed issue #10096: bug: os.getenv always is nil
URL: https://github.com/apache/apisix/issues/10096
--
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