fabric8io/fabric8-pipeline-library

Utils.groovy findTagSha logic

Opened this issue · 0 comments

The following assumption in the code is not true in any of the OpenShift deployments I have tried

def findTagSha(OpenShiftClient client, String imageStreamName, String namespace) {

...

// latest tag is the first
TAG_EVENT_LIST:
for (def list : tags) {

The order of the tags in an ImageStream seems to be random, so picking the first tag found does not work reliably.

eg.

status:
dockerImageRepository: 172.30.209.124:5000/mta/simontest123
tags:

  • items:
    • created: 2017-05-09T23:58:58Z
      dockerImageReference: 172.30.209.124:5000/mta/simontest123@sha256:7b92ede95898259a8976fbd0013f81309c330b7a0a4d4b794f98bb08174e62a3
      generation: 1
      image: sha256:7b92ede95898259a8976fbd0013f81309c330b7a0a4d4b794f98bb08174e62a3
      tag: 6ea89bb
  • items:
    • created: 2017-05-10T01:18:03Z
      dockerImageReference: 172.30.209.124:5000/mta/simontest123@sha256:59e235aeabc89a3038cc16275c8d3cd7d70a16cfee1f45a1484a890acaae51db
      generation: 1
      image: sha256:59e235aeabc89a3038cc16275c8d3cd7d70a16cfee1f45a1484a890acaae51db
      tag: 7d0ef5a
  • items:
    • created: 2017-05-10T01:02:03Z
      dockerImageReference: 172.30.209.124:5000/mta/simontest123@sha256:4bbf3a31a5474d2455b3c005f55c1d94b23c41324089e4bca710b8f3e86cc037
      generation: 1
      image: sha256:4bbf3a31a5474d2455b3c005f55c1d94b23c41324089e4bca710b8f3e86cc037
      tag: e2b3b93
  • items:
    • created: 2017-05-10T00:57:41Z
      dockerImageReference: 172.30.209.124:5000/mta/simontest123@sha256:2ef9f96201fe7b349ba0fb3afcb9f630d4662c4c59896803cb4e4bd7e732c1b9
      generation: 1
      image: sha256:2ef9f96201fe7b349ba0fb3afcb9f630d4662c4c59896803cb4e4bd7e732c1b9
      tag: e5ad8f0

Fabric8 always picks up old image 7b92ede95898259a8976fbd0013f81309c330b7a0a4d4b794f98bb08174e62a3 and deploys it to staging and production, when it should have used the newer image 59e235aeabc89a3038cc16275c8d3cd7d70a16cfee1f45a1484a890acaae51db