Red Hat Bugzilla – Bug 1473270
Env variables (BuildDefaultsConfig, .s2i/environment or set with oc env bc) are not set in build pods
Last modified: 2017-07-20 16:20:06 EDT
Created attachment 1301668 [details]
An s2i build triggered to show results, also has BuildDefaultsConfig section of the master-config.yaml
Description of problem:
Version-Release number of selected component (if applicable):
How reproducible: Always
Steps to Reproduce:
1. Install an OCP 3.5 system. Add some environment vars in BuildDefaultsConfig section
2. Create a new project and add an application using one of the predefined templates (ex. oc new-app jws30-tomcat7-basic-s2i)
3. Set additional env vars using oc env bc/<bc-name>
None of the environment variables set in the build pod (neither BuildDefaultConfig nor env vars set with oc env).
All the custom environment variables specified through BuildDefaultsConfig,.s2i/environment and with oc env should be set in the build pod.
I experienced that issue during a PoC where we need to use a proxy to access resources on the internet. I used the jws30-tomcat7-basic-s2i template to test an s2i build but maven failed to download dependencies. Then I realized that theh proxy env vars that we set in the BuildDefaultsConfig section in master-config.yaml. Now, I installed another OCP 3.5 system in my lab environment and saw that the issue happens in this system too.
Please see the attached file (openshift_s2i.txt).
Please provide your master-config.yaml, the 3.5 instructions were incorrect (had you configuring the defaulter incorrectly). they've since been fixed. It should look like:
gitNoProxy: somedomain.com, otherdomain.com
- name: HTTP_PROXY
- name: HTTPS_PROXY
- name: BUILD_LOGLEVEL
- name: CUSTOM_VAR
Note that this does NOT go under the kubernetesMasterConfig section, admissionConfig is the top level field.
Also note that you will not see the env set on the buildconfig, build, or build pod. The only place you'll see the values is within the BUILD env that is set on the build pod (this env value contains the entire build json). (And of course your assemble scripts will see the value)
and if you set variables with .s2i/environment you definitely will not see them on the pod. That file is processed within the pod(after it is launched) and used to setup env before the assemble script is run, but it won't affect what you see as set on the the pod json.
And similar to build defaults if you set env on the BC, you will not see those env on the build pod, but you will see them in the BUILD env on the pod and your assemble script will see them.
Did you actually try to verify their presence by printing/using them in your assemble script?
Now I see that expecting to see the env vars in the build pod is my misunderstanding. I will check if assemble script can see these proxy env vars set through builddefaults.
My actual problem was maven can not download dependencies.
I read this https://docs.openshift.com/container-platform/3.5/install_config/http_proxies.html#s2i-builds and think that maven will also pick the proxy settings defined in builddefaults but now realized :) it's also documented right above s2i-builds proxy section at https://docs.openshift.com/container-platform/3.5/install_config/http_proxies.html#using-maven-behind-a-proxy
I think we can close this bug report. Sorry for this.