Bug 1473270 - Env variables (BuildDefaultsConfig, .s2i/environment or set with oc env bc) are not set in build pods
Env variables (BuildDefaultsConfig, .s2i/environment or set with oc env bc) a...
Status: CLOSED NOTABUG
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build (Show other bugs)
3.5.0
Unspecified Linux
unspecified Severity high
: ---
: ---
Assigned To: Ben Parees
Wenjing Zheng
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-20 07:19 EDT by kseremet
Modified: 2017-07-20 16:20 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-07-20 16:20:06 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
An s2i build triggered to show results, also has BuildDefaultsConfig section of the master-config.yaml (5.65 KB, text/plain)
2017-07-20 07:19 EDT, kseremet
no flags Details

  None (edit)
Description kseremet 2017-07-20 07:19:47 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>

Actual results:
None of the environment variables set in the build pod (neither BuildDefaultConfig nor env vars set with oc env). 

Expected results:
All the custom environment variables specified through BuildDefaultsConfig,.s2i/environment and with oc env should be set in the build pod.

Additional info:
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).
Comment 1 Ben Parees 2017-07-20 08:51:28 EDT
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:

admissionConfig:
  pluginConfig:
    BuildDefaults:
      configuration:
        apiVersion: v1
        kind: BuildDefaultsConfig
        gitHTTPProxy: http://my.proxy:8080 
        gitHTTPSProxy: https://my.proxy:8443 
        gitNoProxy: somedomain.com, otherdomain.com 
        env:
        - name: HTTP_PROXY 
          value: http://my.proxy:8080
        - name: HTTPS_PROXY 
          value: https://my.proxy:8443
        - name: BUILD_LOGLEVEL 
          value: 4
        - name: CUSTOM_VAR 
          value: custom_value

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)
Comment 2 Ben Parees 2017-07-20 08:54:01 EDT
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?
Comment 3 kseremet 2017-07-20 09:45:16 EDT
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.
Comment 4 Ben Parees 2017-07-20 16:20:06 EDT
cool, thanks.

Note You need to log in before you can comment on or make changes to this bug.