Bug 1213769

Summary: Image tag value defined in imagerepository is picked up as image name during build
Product: OKD Reporter: Wenjing Zheng <wzheng>
Component: BuildAssignee: Andy Goldstein <agoldste>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.xCC: dmcphers, mmccomas, wzheng
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-07 23:45:58 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:
Attachments:
Description Flags
Template file I use none

Description Wenjing Zheng 2015-04-21 09:09:31 UTC
Description:
If define imagerepository ref in imagerepository part and use it to build, it will only just pick up tag name to find an image to build, not defined image plus specified tag.

Version-Release number of selected component (if applicable):
openshift v0.4.3-246-gd6028d1
kubernetes v0.14.1-582-gb12d75d

How reproducible:
always

steps to Reproduce:
1. Make changes in imageRepository pard to add tags info and update strategy part to use image and tag to build:
$vim application-template-stibuild.json
    {
      "apiVersion": "v1beta1",
      "kind": "ImageRepository",
      "metadata": {
        "name": "ruby-20-centos7"
      },
       "tags": {
        "validtag": "buildsuccess"
     },
      "spec": {
        "dockerImageRepository": "openshift/ruby-20-centos7"
      }
    },
...................................
        "strategy": {
          "stiStrategy": {
             "from": {
            "name": "ruby-20-centos7"
          },
          "tag": "validtag"
         },
             "type": "STI"
        }
      },
2. Process and create the update template
3. Start build
4. Check the build log after build fails

Actual results:
The build will go failed due to below error:
[fedora@ip-10-154-39-174 sample-app]$ osc build-logs ruby-sample-build-1 -n wzheng3
2015-04-21T07:29:02.966176544Z E0421 07:29:02.963575       1 cfg.go:50] /root/.dockercfg: stat /root/.dockercfg: no such file or directory
2015-04-21T07:29:05.501964910Z F0421 07:29:05.500573       1 builder.go:62] Build error: unable to get buildsuccess

It uses the image tag as build image to pull.

Expected results:
It should use openshift/ruby-20-centos7:buildsuccess to build.

Additional info:
If I tag the image to buildsuccess via docker tag openshift/ruby-20-centos7 buildsuccess, the build will succeed with build-log as below:
http://fpaste.org/213684/60058414/

Comment 2 Ben Parees 2015-04-21 22:04:46 UTC
your image repository is not properly specified, it should be:

 {
      "apiVersion": "v1beta1",
      "kind": "ImageRepository",
      "metadata": {
        "name": "ruby-20-centos7"
      },
       "tags": {
        "validtag": "buildsuccess"
     },
        "dockerImageRepository": "openshift/ruby-20-centos7"
},

Comment 3 Wenjing Zheng 2015-04-22 03:32:42 UTC
Try to reproduce again with above format, the result is the same from build-log:
builder.go:62] Build error: unable to get buildsuccess

Have attached the template file I use.

Comment 4 Wenjing Zheng 2015-04-22 03:33:20 UTC
Created attachment 1017210 [details]
Template file I use

Comment 5 Ben Parees 2015-04-22 04:13:16 UTC
this will be significantly refactored with https://github.com/openshift/origin/pull/1693 so going to defer until that merges.

Comment 6 Ben Parees 2015-04-29 18:36:16 UTC
Wenjing, the major refactor for buildconfigs has gone in (see my post on openshift-dev), please give this another shot and let me know your results if it doesn't work.

Comment 7 Wenjing Zheng 2015-04-30 02:54:57 UTC
Thanks, Ben!
Verified and test, no build with the same build name as tag will be used;
openshift v0.4.4-122-gda54ce5
kubernetes v0.14.1-582-gb12d75d

Comment 8 Wenjing Zheng 2015-04-30 10:15:06 UTC
It works well with image stream, but if try with image repository like the original bug steps, below error appears when try to start-build:
[fedora@ip-10-11-207-202 sample-app]$ osc start-build ruby-sample-build -n last
Error from server: unable to locate a value on the response: &etcd.Response{Action:"get", Node:(*etcd.Node)(0xc20d975920), PrevNode:(*etcd.Node)(nil), EtcdIndex:0xa62, RaftIndex:0x947b, RaftTerm:0x2}

Comment 9 Ben Parees 2015-04-30 20:23:22 UTC
The issue here is that you don't actually have a valid image to be associated with the "validtag", so we end up with this in the ImageStream that gets defined and is ultimately being queried during the build creation flow:

{
                        "tag": "validtag",
                        "items": [
                            {
                                "created": "2015-04-30T20:19:18Z",
                                "dockerImageReference": "buildsuccess",
                                "image": ""
                            }
                        ]
                    }


This error is coming back from GetImageStreamTag() and we propagate it as is.

I think maybe GetImageStreamTag() should be a little cleaner about how it handles this situation, but the point is you've got a reference to a tag that basically does not exist, so we can't run the build.

assigning to Andy for the GetImageStreamTag handling.

Comment 10 Andy Goldstein 2015-05-01 01:06:59 UTC
Pull https://github.com/openshift/origin/pull/2022 (not yet merged) updates the error returned to be a not-found error, instead of the cryptic etcd error message.

I'm not sure if there's actually a bug here (besides fixing the displayed error message)?

Comment 11 Wenjing Zheng 2015-05-11 09:17:29 UTC
No error like comment #8 appears and imageRepository has been refactored to imageStream, will close this bug now.