Bug 1290317

Summary: When start a build manually, --env option does't work with --from-repo --from-dir, --from-file binary build option
Product: OKD Reporter: Wang Haoran <haowang>
Component: BuildAssignee: Michal Fojtik <mfojtik>
Status: CLOSED CURRENTRELEASE QA Contact: Wenjing Zheng <wzheng>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.xCC: aos-bugs, mfojtik, misalunk, wsun, wzheng, xiazhao
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-12 17:14:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Wang Haoran 2015-12-10 08:43:39 UTC
Description of problem:

When  start a build manually,  --env option does't work with --from-repo --from-dir, --from-file binary build option
Version-Release number of selected component (if applicable):

ami:devenv-rhel7_2913
openshift v1.1-389-g84776cf
kubernetes v1.1.0-origin-1107-g4c8e6f4
How reproducible:
always
Steps to Reproduce:
1.start openshift and create a project
2.create imagestream under openshift namespace
3.oc new-app -f https://raw.githubusercontent.com/openshift-qe/v3-testfiles/master/build/ruby22rhel7-template-docker.json
4. clone the ruby-hello-world repo to local
  $git clone https://github.com/openshift/ruby-hello-world
5. start a build using from-repo option
  $oc start-build <bcname> --from-repo=./ruby-hello-world --env=RACK_ENV=development
6. oc logs -f <pod>

Actual results:
The env RACK_ENV=development should replace RACK_ENV=production in the Dockerfile

[root@ip-172-18-2-6 ruby-hello-world]# oc logs ruby22-sample-build-5-build -f 
Step 0 : FROM registry.access.redhat.com/rhscl/ruby-22-rhel7
 ---> 9416bc460d0c
Step 1 : ENV "EXAMPLE" "sample-app"
 ---> Using cache
 ---> c72e4041bdd9
Step 2 : USER default
 ---> Using cache
 ---> 56500b8b4789
Step 3 : EXPOSE 8080
 ---> Using cache
 ---> 71caac7c76cb
Step 4 : ENV RACK_ENV production
 ---> Using cache
 ---> b3d66932c12b
Step 5 : ENV RAILS_ENV production
 ---> Using cache
 ---> 07b568cafc1b
Step 6 : COPY . /opt/app-root/src/
 ---> abb0b4e85b58
Removing intermediate container 76169cdccb5a
Step 7 : RUN scl enable rh-ruby22 "bundle install"
 ---> Running in b658e7601d64
Fetching gem metadata from https://rubygems.org/..........
Installing rake 10.3.2
Installing i18n 0.6.11
Installing json 1.8.3
Installing minitest 5.4.2
Installing thread_safe 0.3.4
Installing tzinfo 1.2.2
Installing activesupport 4.1.7
Installing builder 3.2.2
Installing activemodel 4.1.7
Installing arel 5.0.1.20140414130214
Installing activerecord 4.1.7

Expected results:
The env should replace the env RACK_ENV=production defined in the Dockerfile

Additional info:

Comment 1 Xia Zhao 2015-12-11 10:20:46 UTC
1. This has nothing to do with options --from-repo --from-dir, --from-file, issue reproduced if trigger new build without these options:
$oc start-build <bcname>  --env=RACK_ENV=development

2. The step4 of command output "oc logs -f" kept saying "Step 4 : ENV RACK_ENV production" regardless of how we set value to RACK_ENV in --env when doing "oc start-build"

Comment 2 Wang Haoran 2015-12-14 02:07:21 UTC
(In reply to Xia Zhao from comment #1)
> 1. This has nothing to do with options --from-repo --from-dir, --from-file,
> issue reproduced if trigger new build without these options:
> $oc start-build <bcname>  --env=RACK_ENV=development
> 
I think it's different code logic , both exists the problem.
> 2. The step4 of command output "oc logs -f" kept saying "Step 4 : ENV
> RACK_ENV production" regardless of how we set value to RACK_ENV in --env
> when doing "oc start-build"
If start the build like what you said , it will add the env in the step 1. and then overlaped by step 4. if there is a new env not exits in previous dockerfile , this option will work.So problem is the env passed through --env option haven't replace the exits one in dockerfile .

Comment 3 Michal Fojtik 2015-12-14 09:43:19 UTC
I think this is a bug but not related to the binary build. The --env option was added recently, I will have a look.

Comment 4 Michal Fojtik 2015-12-14 10:57:50 UTC
After some investigation the bug that the --env option is passed into a BuildRequest from CLI, but the binary builds are using BinaryBuildRequest, where this field is missing. I'm fixing this now, so you're right, this is actually related to the binary builds ;-)

Comment 5 Michal Fojtik 2015-12-14 13:26:22 UTC
Upstream issue about this: https://github.com/kubernetes/kubernetes/issues/18649

Comment 6 Michal Fojtik 2015-12-14 15:14:42 UTC
Wang: This bug will be fixed by showing a warning when you use --env/--build-loglevel with combination with binary build source.

The warning PR is here: https://github.com/openshift/origin/pull/6298

I think this bug can be verified and closed.

Comment 7 Wang Haoran 2015-12-15 10:20:54 UTC
will verify this once the PR is merged.

Comment 8 Wang Haoran 2015-12-18 10:30:17 UTC
the --env options is removed from the oc start-build command , so this senario will disappear. 
origin version:
openshift v1.1-428-ged29520

Comment 9 Wenjing Zheng 2015-12-29 01:50:04 UTC
Moving NeedInfo tag.

Comment 10 Eric Rich 2016-05-18 20:36:14 UTC
*** Bug 1257254 has been marked as a duplicate of this bug. ***