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:
Ben: The BuildConfig Trigger should use the same mechanism for resolving the images as deployment config.
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?
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.
PR: https://github.com/openshift/origin/pull/12767
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"