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
   ```
   
![image](https://github.com/apache/apisix/assets/24973084/1bdc17d1-c23d-4e4b-8cdf-ecb957b97d7d)
   
   
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to