Bug 1412029 - [platformmanagement_public_852 ] Image streams usage(:referencePolicy=Local) doesn't work for build config triggers
Summary: [platformmanagement_public_852 ] Image streams usage(:referencePolicy=Local) ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Build
Version: 3.x
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: Michal Fojtik
QA Contact: Wang Haoran
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-01-11 02:26 UTC by ge liu
Modified: 2017-05-30 12:51 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-05-30 12:51:18 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description ge liu 2017-01-11 02:26:19 UTC
Description of problem:
After set "referencePolicy: type: Local" for imagestream, the build config should change the trigger with (local registry + image id) instead of the external reference as expected, but the test result is bc config still keep the external reference.

I run the same test with dc config, the test result worked as expected, so I doubt it limited in build config issue.

Version-Release number of selected component (if applicable):
openshift v1.5.0-alpha.1+ef2f635-67
kubernetes v1.4.0+776c994
etcd 3.1.0-rc.0

How reproducible:
Always

Steps to Reproduce:
1. Run import-image to create imagestream:

[root@ip-172-xx-4-xxx ~]# oc import-image --confirm --from=centos/ruby-22-centos7 ruby-22-centos7:latest
The import completed successfully.

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

2. Run the new-build and checke the bc config, the result worked as expected:
#oc new-build --image-stream=ruby-22-centos7 https://github.com/openshift/ruby-ex.git
[root@ip-172-xx-4-xx ~]# oc get bc ruby-ex -o yaml
.....................
 - imageChange:
      lastTriggeredImageID: centos/ruby-22-centos7@sha256:aace2b3ef701be868ef3a1feff7f1d766caa9e80026ba55dbf2d2e9c8f37b

3. delete the imagestream and bc created in step 1,2

4. Run import-image to create imagestream again and oc edit the imagestream just created:

referencePolicy:
      type: Source    to  type: Local 

5. Run the new-build and checke the bc config, the result have not change and same to step 2:
# oc get bc ruby-ex -o yaml

 imageChange:
      lastTriggeredImageID: centos/ruby-22-centos7@sha256:aace2b3ef701be868ef3a1feff7f1d766caa9e80026ba55dbf2d2e9c8f37bf7e




Actual results:
after set "referencePolicy: type: Local"  for imagestream, the build config still trigger with external reference+image id.

Expected results:
after set "referencePolicy: type: Local" for imagestream, the build config should change the trigger with (local registry + image id) instead of the external reference.



Additional info:

Comment 1 Michal Fojtik 2017-02-01 11:32:15 UTC
Ben: The BuildConfig Trigger should use the same mechanism for resolving the images as deployment config.

Comment 2 Ben Parees 2017-02-01 15:00:37 UTC
Michal, all we do is ask the imagestreamtag for the current imagereference.  Why is it not returning a local reference if that's the expected behavior?  Can you point to the "correct" resolution code?

Comment 3 Michal Fojtik 2017-02-01 15:22:01 UTC
The problem is basically that the resolveImageStreamReference() that sets the LastTriggeredImageID is not using the ResolveLatestTaggedImage() which was already plumbed to deal with reference policy... That said, the resolveImageStreamReference() just sets the DockerImageReference from the image (which does not take into account the reference policy).

To fix this, we should have helpers to handle ImageStreamTag and ImageStreamImage as well (ResolveLatestTaggedImage() just resolves the IS), and then plumb the resolveImageStreamReference() to use this helpers.

Comment 4 Michal Fojtik 2017-02-02 13:40:30 UTC
PR: https://github.com/openshift/origin/pull/12767

Comment 5 ge liu 2017-02-08 02:25:59 UTC
verified on env:

openshift v1.5.0-alpha.2+71a4378-423
kubernetes v1.5.2+43a9be4
etcd 3.1.0


1).# oc import-image --confirm --from=centos/ruby-22-centos7 ruby-22-centos7:latest
The import completed successfully.
2).# oc edit is ruby-22-centos7
change the referencePolicy:
      ‘type: Source‘ to ‘type: Local‘

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

4).# oc get bc ruby-ex -o json:

"imageChange": {
                    "lastTriggeredImageID": "172.xx.xx.xx:5000/lgproj/ruby-22-centos7@sha256:460730627b1c32c10368aa754e7075e447394b76c5a213a819a11297000edd2d"


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