From caf0be52054e972af40ae994344e60cad052d5c8 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Mon, 17 Jul 2023 16:16:28 +0100 Subject: [PATCH] [stf-run-ci] create_catalog: Update image for operator registry Check whether the default image can be accessed (registry.redhat.io requires login) and use the upstream image if the default isn't available. --- build/stf-run-ci/tasks/create_catalog.yml | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/build/stf-run-ci/tasks/create_catalog.yml b/build/stf-run-ci/tasks/create_catalog.yml index cb4e1fb8d..b67bb5e01 100644 --- a/build/stf-run-ci/tasks/create_catalog.yml +++ b/build/stf-run-ci/tasks/create_catalog.yml @@ -59,10 +59,37 @@ register: ose_op_registry_is ignore_errors: true -- name: Create ImageStream for ose-operator-registry - ansible.builtin.command: oc import-image -n {{ namespace }} ose-operator-registry:{{ default_operator_registry_image_tag }} --from={{ default_operator_registry_image_base }}:{{ default_operator_registry_image_tag }} --confirm - # when: query('kubernetes.core.k8s', api_version='v1', kind='ImageStream', resource_name='ose-operator-registry', namespace=namespace) | length == 0 +- ansible.builtin.set_fact: + operator_registry_image: "{{ default_operator_registry_image_base }}:{{ default_operator_registry_image_tag }}" + + # --show-multiarch=true is used because you get an error (and rc!=0) when you query a multi-arch image without specifying the arch, even when the image exists +- name: "Try to get the image info for the operator registry image" + ansible.builtin.command: + cmd: oc image info --show-multiarch=true "{{ operator_registry_image }}" + ignore_errors: true + register: image_info + + # TODO: try docker pull on the image and set accordingly. + # i.e. if we can pull/query the registry.redhat.io image, use it, else use quay + # TODO: Fix this to actually honour the check. +- name: "Test alternative operator image" + ansible.builtin.set_fact: + #operator_registry_image: "registry.redhat.io/openshift4/ose-operator-registry:v4.13" + operator_registry_image: "quay.io/openshift/origin-operator-registry:4.13" + #when: image_info.rc != 0 + + # TODO: Clean up the nameing and versioning, so we can have a source-agnostic image stream. + # TODO: Use the same tag as the image, using an appropriate filter to extract the version from the image. +- name: Create ImageStream for ose-operator-registry, if it doesn't already exist + ansible.builtin.command: + cmd: | + oc import-image -n {{ namespace }} ose-operator-registry:{{ default_operator_registry_image_tag }} --from={{ operator_registry_image }} --confirm when: ose_op_registry_is.rc != 0 + register: create_ose_is + +- name: "Show the image stream" + ansible.debug.debug: + var: create_ose_is - name: "Delete the existing imagestream, if it exists" ansible.builtin.command: oc delete imagestream -n {{ namespace }} service-telemetry-framework-index @@ -106,7 +133,7 @@ dockerfile: | # The base image is expected to contain # /bin/opm (with a serve subcommand) and /bin/grpc_health_probe - FROM registry.redhat.io/openshift4/ose-operator-registry:v4.13 + FROM {{ operator_registry_image }} COPY --chmod=666 index.yaml /configs/