Bug 1386543 - [platformmanagement_public_802]Can't create ImageStream correctly with docker image has more than two slashes
Summary: [platformmanagement_public_802]Can't create ImageStream correctly with docker...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Image Registry
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Alexey Gladkov
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-19 08:46 UTC by zhou ying
Modified: 2016-12-09 21:50 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-12-09 21:50:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description zhou ying 2016-10-19 08:46:40 UTC
Description of problem:
Use docker image which have more than two slashes to create new build, the ImageStream created failed with error:name may not contain "/"

Version-Release number of selected component (if applicable):
openshift version
openshift v1.4.0-alpha.0+852f1fe
kubernetes v1.4.0+776c994
etcd 3.1.0-alpha.1

oc v1.4.0-alpha.0+852f1fe
kubernetes v1.4.0+776c994
features: Basic-Auth GSSAPI Kerberos SPNEGO

How reproducible:
always


Steps to Reproduce:
1. Prepare image with more than two slashes;
2. Login OpenShift and create project;
3. Use the image to create build:
  `oc new-build https://github.com/openshift/django-ex --docker-image=5e993f89.ngrok.io/test/openshift3/python-33-rhel7:latest`



Actual results:
3. Met error: ImageStream "openshift3/python-33-rhel7" is invalid: metadata.name: Invalid value: "openshift3/python-33-rhel7": name may not contain "/"


Expected results:
3. Create the Imagestream correctly.


Additional info:
oc new-build https://github.com/openshift/django-ex --docker-image=5e993f89.ngrok.io/test/openshift3/python-33-rhel7:latest
--> Found Docker image 7d8355d (4 weeks old) from 5e993f89.ngrok.io for "5e993f89.ngrok.io/test/openshift3/python-33-rhel7:latest"

    Python 3.3 
    ---------- 
    Platform for building and running Python 3.3 applications

    Tags: builder, python, python33

    * An image stream will be created as "openshift3/python-33-rhel7:latest" that will track the source image
    * The source repository appears to match: python
    * A source build using source code from https://github.com/openshift/django-ex will be created
      * The resulting image will be pushed to image stream "django-ex:latest"
      * Every time "openshift3/python-33-rhel7:latest" changes a new build will be triggered

--> Creating resources with label build=django-ex ...
    error: ImageStream "openshift3/python-33-rhel7" is invalid: metadata.name: Invalid value: "openshift3/python-33-rhel7": name may not contain "/"
    imagestream "django-ex" created
    error: BuildConfig "django-ex" is invalid: spec.strategy.sourceStrategy.from.name: Invalid value: "openshift3/python-33-rhel7": ImageStreamTag name contains invalid syntax
--> Failed

Comment 3 Alexey Gladkov 2016-10-27 12:39:25 UTC
This is not a bug. We can't allow to create imagestreams with `/` in the name.
You can create imagestream like this:

oc import-image --confirm --from=myregistty.io/foo/bar/baz mystream

Comment 4 zhou ying 2016-10-31 03:09:51 UTC
Still met error:

[root@zhouy testjson]# oc import-image --confirm --from=562e8933.ngrok.io/test/centos/ruby-22-centos7 ruby-22-centos7:latest
The import completed successfully.

Name:			ruby-22-centos7
Namespace:		test
Created:		Less than a second ago
Labels:			<none>
Annotations:		openshift.io/image.dockerRepositoryCheck=2016-10-31T02:57:20Z
Docker Pull Spec:	172.30.174.36:5000/test/ruby-22-centos7
Unique Images:		1
Tags:			1

latest
  tagged from 562e8933.ngrok.io/test/centos/ruby-22-centos7

  *
562e8933.ngrok.io/test/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325
      Less than a second ago


[root@zhouy testjson]# oc new-build  https://github.com/openshift/ruby-ex.git --docker-image=562e8933.ngrok.io/test/centos/ruby-22-centos7:latest
--> Found Docker image a6e2b03 (9 days old) from 562e8933.ngrok.io for
"562e8933.ngrok.io/test/centos/ruby-22-centos7:latest"

    Ruby 2.2 
    -------- 
    Platform for building and running Ruby 2.2 applications

    Tags: builder, ruby, ruby22

    * An image stream will be created as "centos/ruby-22-centos7:latest" that will track the source image
    * The source repository appears to match: ruby
    * A source build using source code from https://github.com/openshift/ruby-ex.git will be created
      * The resulting image will be pushed to image stream "ruby-ex:latest"
      * Every time "centos/ruby-22-centos7:latest" changes a new build will be triggered

--> Creating resources with label build=ruby-ex ...
    error: ImageStream "centos/ruby-22-centos7" is invalid: metadata.name: Invalid value: "centos/ruby-22-centos7": name may not contain "/"
    error: imagestreams "ruby-ex" already exists
    error: BuildConfig "ruby-ex" is invalid: spec.strategy.sourceStrategy.from.name: Invalid value: "centos/ruby-22-centos7": ImageStreamTag name contains invalid syntax
--> Failed

Comment 5 Alexey Gladkov 2016-10-31 16:46:42 UTC
It's because you are again trying to create an imagestream with multi-segments name. You need to do something like this:

oc import-image --confirm --from=562e8933.ngrok.io/test/centos/ruby-22-centos7 ruby-22-centos7:latest myimagestream

oc new-build --image-stream=myimagestream https://github.com/openshift/ruby-ex.git

Comment 6 zhou ying 2016-11-01 02:01:38 UTC
Build failed with logs:
oc build-logs ruby-ex-1
Command "build-logs" is deprecated, use "oc logs build/<build-name>" instead.
The Build "ruby-ex-1" is invalid: spec.strategy.sourceStrategy.from.name: Invalid value:
"3af3c226.ngrok.io/test/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325":
name is not a valid Docker pull specification: the docker pull spec
"3af3c226.ngrok.io/test/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325"
must be two or three segments separated by slashes

Comment 7 Alexey Gladkov 2016-11-01 09:55:58 UTC
I can't reproduce it:

$ oc import-image --confirm --insecure --from=10.34.129.55:5005/foo/centos/ruby-22-centos7:latest myimagestream

$ oc new-build --image-stream=myimagestream https://github.com/openshift/ruby-ex.git

$ oc get imagestreams
NAME            DOCKER REPO                                  TAGS      UPDATED
myimagestream   172.30.49.221:5000/myproject/myimagestream   latest    17 hours ago
ruby-ex         172.30.49.221:5000/myproject/ruby-ex         latest    17 hours ago

$ oc get -o yaml imagestreams/myimagestream
apiVersion: v1
kind: ImageStream
metadata:
  annotations:
    openshift.io/image.dockerRepositoryCheck: 2016-10-31T16:38:45Z
  creationTimestamp: 2016-10-31T16:38:45Z
  generation: 1
  name: myimagestream
  namespace: myproject
  resourceVersion: "1213"
  selfLink: /oapi/v1/namespaces/myproject/imagestreams/myimagestream
  uid: 7d944eec-9f88-11e6-a189-507b9d472d2b
spec:
  tags:
  - annotations: null
    from:
      kind: DockerImage
      name: 10.34.129.55:5005/foo/centos/ruby-22-centos7:latest
    generation: 1
    importPolicy:
      insecure: true
    name: latest
status:
  dockerImageRepository: 172.30.49.221:5000/myproject/myimagestream
  tags:
  - items:
    - created: 2016-10-31T16:38:45Z
      dockerImageReference:
10.34.129.55:5005/foo/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325
      generation: 1
      image: sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325
    tag: latest

$ oc get builds
NAME        TYPE      FROM          STATUS     STARTED        DURATION
ruby-ex-1   Source    Git@f63d076   Complete   17 hours ago   35s

$ oc get -o yaml builds/ruby-ex-1
apiVersion: v1
kind: Build
metadata:
  annotations:
    openshift.io/build-config.name: ruby-ex
    openshift.io/build.number: "1"
    openshift.io/build.pod-name: ruby-ex-1-build
  creationTimestamp: 2016-10-31T16:40:38Z
  labels:
    build: ruby-ex
    buildconfig: ruby-ex
    openshift.io/build-config.name: ruby-ex
    openshift.io/build.start-policy: Serial
  name: ruby-ex-1
  namespace: myproject
  resourceVersion: "1262"
  selfLink: /oapi/v1/namespaces/myproject/builds/ruby-ex-1
  uid: c0cc3939-9f88-11e6-a189-507b9d472d2b
spec:
  nodeSelector: null
  output:
    pushSecret:
      name: builder-dockercfg-syned
    to:
      kind: ImageStreamTag
      name: ruby-ex:latest
  postCommit: {}
  resources: {}
  revision:
    git:
      author:
        email: mi
        name: Michal Fojtik
      commit: f63d076b602441ebd65fd0749c5c58ea4bafaf90
      committer:
        email: noreply
        name: GitHub
      message: 'Merge pull request #2 from mfojtik/add-puma'
    type: Git
  serviceAccount: builder
  source:
    git:
      uri: https://github.com/openshift/ruby-ex.git
    type: Git
  strategy:
    sourceStrategy:
      from:
        kind: DockerImage
        name:
10.34.129.55:5005/foo/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325
    type: Source
  triggeredBy:
  - message: Build configuration change
status:
  completionTimestamp: 2016-10-31T16:41:15Z
  config:
    kind: BuildConfig
    name: ruby-ex
    namespace: myproject
  duration: 35000000000
  phase: Complete
  startTimestamp: 2016-10-31T16:40:40Z

$ oc logs builds/ruby-ex-1
Cloning "https://github.com/openshift/ruby-ex.git" ...
	Commit:	f63d076b602441ebd65fd0749c5c58ea4bafaf90 (Merge pull request #2 from mfojtik/add-puma)
	Author:	Michal Fojtik <mi>
	Date:	Thu Jun 30 10:47:53 2016 +0200
---> Installing application source ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
Fetching gem metadata from https://rubygems.org/...............
Installing puma 3.4.0
Installing rack 1.6.4
Using bundler 1.7.8
Your bundle is complete!
It was installed into ./bundle
---> Cleaning up unused ruby gems ...
Pushing image 172.30.49.221:5000/myproject/ruby-ex:latest ...
Pushed 0/9 layers, 11% complete
Pushed 1/9 layers, 13% complete
Pushed 2/9 layers, 23% complete
Pushed 3/9 layers, 34% complete
Pushed 4/9 layers, 46% complete
Pushed 5/9 layers, 56% complete
Pushed 6/9 layers, 67% complete
Pushed 7/9 layers, 84% complete
Pushed 8/9 layers, 100% complete
Pushed 9/9 layers, 100% complete
Push successful

Comment 9 zhou ying 2016-11-02 09:40:05 UTC
Alexey Gladkov:

  Thanks . Confirmed with the latest OCP. the issue has fixed:
openshift version
openshift v3.4.0.18+ada983f
kubernetes v1.4.0+776c994
etcd 3.1.0-rc.0


[root@zhouy testjson]# oc describe is myimagestream
Name:			myimagestream
Namespace:		testsecure
Created:		4 minutes ago
Labels:			<none>
Annotations:		openshift.io/image.dockerRepositoryCheck=2016-11-02T09:34:39Z
Docker Pull Spec:	172.30.187.114:5000/testsecure/myimagestream
Unique Images:		1
Tags:			1

latest
  tagged from e29e7de8.ngrok.io/test/centos/ruby-22-centos7:latest

  *
e29e7de8.ngrok.io/test/centos/ruby-22-centos7@sha256:c6f69b255484916c562752357c12089be10091b1810758aa243d90e793997325
      4 minutes ago



oc new-build --image-stream=myimagestream https://github.com/openshift/ruby-ex.git
--> Found image a6e2b03 (11 days old) in image stream "testsecure/myimagestream" under tag "latest" for "myimagestream"

    Ruby 2.2 
    -------- 
    Platform for building and running Ruby 2.2 applications

    Tags: builder, ruby, ruby22

    * The source repository appears to match: ruby
    * A source build using source code from https://github.com/openshift/ruby-ex.git will be created
      * The resulting image will be pushed to image stream "ruby-ex:latest"
      * Use 'start-build' to trigger a new build

--> Creating resources with label build=ruby-ex ...
    imagestream "ruby-ex" created
    buildconfig "ruby-ex" created
--> Success
    Build configuration "ruby-ex" created and build triggered.
    Run 'new-build logs -f bc/ruby-ex' to stream the build progress.
[root@zhouy testjson]# oc get build
NAME        TYPE      FROM      STATUS    STARTED                  DURATION
ruby-ex-1   Source    Git       Running   Less than a second ago   2s
[root@zhouy testjson]# oc build-logs ruby-ex-1
Command "build-logs" is deprecated, use "oc logs build/<build-name>" instead.
Cloning "https://github.com/openshift/ruby-ex.git" ...
	Commit:	f63d076b602441ebd65fd0749c5c58ea4bafaf90 (Merge pull request #2 from mfojtik/add-puma)
	Author:	Michal Fojtik <mi>
	Date:	Thu Jun 30 10:47:53 2016 +0200

---> Installing application source ...
---> Building your Ruby application from source ...
---> Running 'bundle install --deployment' ...
Fetching gem metadata from https://rubygems.org/...............
Installing puma 3.4.0
Installing rack 1.6.4
Using bundler 1.7.8
Your bundle is complete!
It was installed into ./bundle
---> Cleaning up unused ruby gems ...


Pushing image 172.30.187.114:5000/testsecure/ruby-ex:latest ...
Pushed 0/9 layers, 1% complete
Pushed 1/9 layers, 22% complete
Pushed 2/9 layers, 31% complete
Pushed 3/9 layers, 39% complete
Pushed 4/9 layers, 54% complete
Pushed 5/9 layers, 60% complete
Pushed 6/9 layers, 70% complete
Pushed 7/9 layers, 84% complete
Pushed 7/9 layers, 90% complete
Pushed 7/9 layers, 97% complete
Pushed 8/9 layers, 100% complete
Pushed 9/9 layers, 100% complete
Push successful


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