Bug 1290317 - When start a build manually, --env option does't work with --from-repo --from-dir, --from-file binary build option
When start a build manually, --env option does't work with --from-repo --fr...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Build (Show other bugs)
3.x
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Michal Fojtik
Wenjing Zheng
:
: 1257254 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-10 03:43 EST by Wang Haoran
Modified: 2016-05-18 16:36 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-05-12 13:14:01 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)

  None (edit)
Description Wang Haoran 2015-12-10 03:43:39 EST
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 05:20:46 EST
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-13 21:07:21 EST
(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 04:43:19 EST
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 05:57:50 EST
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 08:26:22 EST
Upstream issue about this: https://github.com/kubernetes/kubernetes/issues/18649
Comment 6 Michal Fojtik 2015-12-14 10:14:42 EST
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 05:20:54 EST
will verify this once the PR is merged.
Comment 8 Wang Haoran 2015-12-18 05:30:17 EST
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-28 20:50:04 EST
Moving NeedInfo tag.
Comment 10 Eric Rich 2016-05-18 16:36:14 EDT
*** Bug 1257254 has been marked as a duplicate of this bug. ***

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