Bug 1420976

Summary: - [platformmanagement_public_852]RreferencePolicy: Source/Local options parameters should be added to 'oc import-image' also
Product: OpenShift Container Platform Reporter: ge liu <geliu>
Component: Image RegistryAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: Wei Sun <wsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.5.0CC: aos-bugs, mfojtik
Target Milestone: ---Keywords: RFE
Target Release: 3.6.z   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Feature: Ability to set reference policy with oc import-image. Reason: Reference policy was added to oc tag and should be available on oc import-image, as well. Result: One can set reference policy using --reference-policy flag when invoking oc import-image. In case of importing all tags (--all flag being used) all tags will get passed reference policy, including overwriting already present one.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-09-08 03:15:23 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 ge liu 2017-02-10 03:29:57 UTC
Description of problem:
this bug's background is: https://bugzilla.redhat.com/show_bug.cgi?id=1412050,
regarding to this card: an image stream author request that build config and deployment config change triggers use pullthrough (by specifying the Local TagReferencePolicyType, the bug:1412050 add the --reference-policy to command 'oc tag', but missed to add it to 'oc import-image'.

Version-Release number of selected component (if applicable):

# openshift version
openshift v1.5.0-alpha.2+98ad752-493
kubernetes v1.5.2+43a9be4
etcd 3.1.0

How reproducible:
always

Steps to Reproduce:
1.  #oc import-image --confirm --from=centos/ruby-22-centos7 ruby-22-centos7:latest
2. #oc get is ruby-22-centos7 -o yaml
  ..........
    referencePolicy:
      type: Source
    .....

3. #oc new-build --image-stream=ruby-22-centos7 https://github.com/openshift/ruby-ex.git

4. # oc get bc ruby-ex -o yaml
   ................
     lastTriggeredImageID: centos/ruby-22-centos7@sha256:460730627b1c32c10368aa754e7075e447394b76c5a213a819a11297000edd2d
   .....
Actual results:
'oc import-image' havent't option '--reference-policy'

Expected results:
'oc import-image' should support option '--reference-policy'

Additional info:

Comment 1 Michal Fojtik 2017-02-10 09:29:06 UTC
For 1.5, you can use `oc tag` to change the reference policy, the import-image is far more complex (as it have to be plumbed via REST API).

I'm moving to as RFE to upcoming release and we will deal with this for 1.6

Comment 2 Maciej Szulik 2017-03-10 08:47:54 UTC
Fix in https://github.com/openshift/origin/pull/13339.

Comment 3 openshift-github-bot 2017-03-15 06:54:55 UTC
Commits pushed to master at https://github.com/openshift/origin

https://github.com/openshift/origin/commit/aa80c856a9244dd624c9829c14238231c8410d2d
Bug 1420976 - Support passing reference-policy in import-image command

https://github.com/openshift/origin/commit/0009bfa6972b0c17f405a3c53b8965456a9cdbdc
Merge pull request #13339 from soltysh/bug1420976

Merged by openshift-bot

Comment 4 ge liu 2017-03-17 02:58:06 UTC
Verified in origin env:
openshift v1.5.0-alpha.3+9be07d7-397
kubernetes v1.5.2+43a9be4
etcd 3.1.0

# oc import-image --confirm --from=centos/ruby-22-centos7 ruby-22-centos7:latest --reference-policy='source'
The import completed successfully.
............

# oc get is ruby-22-centos7 -o yaml
apiVersion: v1
.......
    referencePolicy:
      type: Source
.....

# oc get bc ruby-ex -o yaml
- imageChange:
      lastTriggeredImageID: centos/ruby-22-centos7@sha256:9182cb1502d5967bbc727488586ee4b52da9d509f0d7d01bf14c3fb2faa39c43

# oc import-image --confirm --from=centos/ruby-22-centos7 ruby-22-centos7:latest --reference-policy='local'
The import completed successfully.
.............

# oc get is ruby-22-centos7 -o yaml
..............
- imageChange:
      lastTriggeredImageID: 172.x.78.x:5000/lgproj/ruby-22-centos7@sha256:9182cb1502d5967bbc727488586ee4b52da9d509f0d7d01bf14c3fb2faa39c43
    type: ImageChange
.................

Comment 8 errata-xmlrpc 2017-09-08 03:15:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2642