You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/02/27 05:47:43 UTC
[GitHub] philipjkim opened a new issue #4308: How can I pass specific
environment variables in invokers to actions to be invoked?
philipjkim opened a new issue #4308: How can I pass specific environment variables in invokers to actions to be invoked?
URL: https://github.com/apache/incubator-openwhisk/issues/4308
<!--
We use the issue tracker for bugs and feature requests. For general questions and discussion please use http://slack.openwhisk.org/ or https://openwhisk.apache.org/contact.html instead.
Do NOT share passwords, credentials or other confidential information.
Before creating a new issue, please check if there is one already open that
fits the defect you are reporting.
If you open an issue and realize later it is a duplicate of a pre-existing
open issue, please close yours and add a comment to the other.
Issues can be created for either defects or enhancement requests. If you are a committer than please add the labels "bug" or "feature". If you are not a committer please make clear in the comments which one it is, so that committers can add these labels later.
If you are reporting a defect, please edit the issue description to include the
information shown below.
If you are reporting an enhancement request, please include information on what you are trying to achieve and why that enhancement would help you.
For more information about reporting issues, see
https://github.com/apache/incubator-openwhisk/blob/master/CONTRIBUTING.md#raising-issues
Use the commands below to provide key information from your environment:
You do not have to include this information if this is a feature request.
-->
## Environment details:
* Ubuntu 16.04
* Docker 18.09.2
My workplace has a private network, so http(s) proxy is required to request outside the intranet. I thought adding proxy-related environment variables such as `HTTP_PROXY`, `HTTPS_PROXY` and `NO_PROXY` to invoker docker can solve the problem.
So I added those environment varibles to `$OPENWHISK_HOME/ansible/roles/invoker/tasks/deploy.yml`:
```yaml
- name: populate environment variables for invoker
set_fact:
env:
# ...
"http_proxy": "http://my-proxy"
"HTTP_PROXY": "http://my-proxy"
"https_proxy": "http://my-proxy"
"HTTPS_PROXY": "http://my-proxy"
"no_proxy": "localhost,127.0.0.1,172.17.0.1,.my-domain.com"
"NO_PROXY": "localhost,127.0.0.1,172.17.0.1,.my-domain.com"
```
After adding them, I re-deployed invokers without issues. Also, the proxy worked as expected when I entered into a running invoker docker container and make a request using curl to external website:
```
# @ one of invoker servers
$ docker exec -it invoker0 /bin/bash
# set|grep -i proxy
HTTPS_PROXY=http://my-proxy
HTTP_PROXY=http://my-proxy
NO_PROXY=localhost,127.0.0.1,172.17.0.1,.my-domain.com
http_proxy=http://my-proxy
https_proxy=http://my-proxy
no_proxy=localhost,127.0.0.1,172.17.0.1,.my-domain.com
# curl -vL https://github.com
(successfully fetch the web page via proxy)
```
I expected the action I created would use proxy-related environment variables inside an action code, but I found that those environment variables are not shown in the action:
```python
import os
import urllib.request
from socket import timeout
def main(args):
envs = []
for e in os.environ:
envs.append(e)
print(envs) # no proxy-related variables imported
# error occurs since request sent without proxy: <urlopen timed out>
res = urllib.request.urlopen('https://github.com', timeout=5).read().decode('utf-8')
return {'success': True}
```
Result of `print(envs)`:
```
"2019-02-27T05:37:10.846105207Z stdout: ['LANG', 'HOSTNAME', 'GPG_KEY',
'FLASK_PROXY_PORT', 'PWD', 'HOME', '__OW_ALLOW_CONCURRENT',
'PYTHON_VERSION', 'SHLVL', '__OW_API_HOST', 'PATH', 'PYTHON_PIP_VERSION',
'OLDPWD', '_', '__OW_ACTION_NAME', '__OW_ACTIVATION_ID', '__OW_API_KEY',
'__OW_DEADLINE', '__OW_NAMESPACE']"
```
Is there a way passing proxy-related environment variables (which are set in Docker) to actions? If impossible, is it preferred to set proxy-related settings inside an action code?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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