Uploaded image for project: 'OpenShift Image Registry'
  1. OpenShift Image Registry
  2. IR-340

Getting an ImageStreamImage may return an image with the wrong dockerImageReference

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • openshift-4.12
    • API
    • None
    • False
    • None
    • False

      Steps to reproduce:

      # import ubuntu:latest from quay.io/fmissi
      oc new-project myapp
      cat <<EOF | oc create -f -
      apiVersion: image.openshift.io/v1
      kind: ImageStreamImport
      metadata:
        name: app
        namespace: myapp
      spec:
        import: true
        images:
        - from:
            kind: DockerImage
            name: quay.io/fmissi/ubuntu
          to:
            name: latest
      EOF
      
      # copy quay.io/fmissi/ubuntu:latest to docker.io/fmissi/ubuntu:latest to ensure both our image streams point to the same image
      skopeo copy --all docker://quay.io/fmissi/ubuntu:latest docker://docker.io/fmissi/ubuntu:latest
      
      # create another image stream, on a different project, using the docker.io/fmissi reference
      oc new-project myotherapp
      cat <<EOF | oc create -f -
      apiVersion: image.openshift.io/v1
      kind: ImageStreamImport
      metadata:
        name: otherapp
        namespace: myotherapp
      spec:
        import: true
        images:
        - from:
            kind: DockerImage
            name: docker.io/fmissi/ubuntu
          to:
            name: latest
      EOF
      
      # now compare the dockerImageReferences from the ImageStream vs the ImageStreamImage
      oc get is app -ojson -nmyapp|jq '.status.tags[0].items[0].dockerImageReference'
      "quay.io/fmissi/ubuntu@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7"
      
      oc get imagestreamimage app@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7 -ojson -nmyapp|jq '.image.dockerImageReference'
      "quay.io/fmissi/ubuntu@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7"
      
      
      oc get is otherapp -ojson -nmyotherapp|jq '.status.tags[0].items[0].dockerImageReference'
      "docker.io/fmissi/ubuntu@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7"
      
      oc get imagestreamimage otherapp@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7 -ojson -nmyotherapp|jq '.image.dockerImageReference'
      "quay.io/fmissi/ubuntu@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7"
      
      

      Expected behavior
      The result of:

      oc get imagestreamimage otherapp@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7 -ojson -nmyotherapp|jq '.image.dockerImageReference'
      

      Should equal to what the ImageStreamImage api returns:

      oc get is otherapp -ojson -nmyotherapp|jq '.status.tags[0].items[0].dockerImageReference'
      "docker.io/fmissi/ubuntu@sha256:97923994fdc1c968eed6bdcb64be8e70d5356b88cfab0481cb6b73a4849361b7"
      

      Actual behavior
      The ImageStreamImage api returns the unchanged Image.DockerImageRegistry, rather than adapting it to the dockerImageRegistry of the related ImageStream.
      For reference, the image-registry itself handles this here: https://github.com/openshift/image-registry/blob/57ae5bb3a52e03e3a88faab498f0595ae75db7e2/pkg/imagestream/imagestream.go?plain=1#L187

              Unassigned Unassigned
              fmissi Flavian Missi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: