Skip to content

Commit 84f7434

Browse files
authored
Merge pull request #490 from mbaldessari/iib-output
Improve IIB
2 parents 4d04000 + 5702167 commit 84f7434

5 files changed

Lines changed: 22 additions & 89 deletions

File tree

ansible/roles/iib_ci/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,6 @@ use that. Run `make iib` with the following environment variables set:
6464
* `INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:492329`
6565
* `KUBEADMINPASS="11111-22222-33333-44444"`
6666

67-
### OCP 4.12 and previous versions
68-
69-
Due to the lack of v2 manifest support on the internal registry, we use an external
70-
registry. Run `make iib` with the following environment variables set:
71-
72-
* `INDEX_IMAGES=registry-proxy.engineering.redhat.com/rh-osbs/iib:492329`
73-
* `REGISTRY=quay.io/rhn_support_mbaldess/iib`
74-
* `REGISTRY_TOKEN=<username>:<token>`
75-
76-
*Note*: For the REGISTRY_TOKEN go to your quay repository, add a robot with "Write" permissions. The robot created will have a "username" and "password" fields. Set the REGISTRY_TOKEN environment variable to that value.
77-
7867
## Useful commands
7968

8069
* List IIBs for an operator:

ansible/roles/iib_ci/defaults/main.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
rh_internal_registry: registry-proxy.engineering.redhat.com
22
iib_image: "{{ lookup('env', 'INDEX_IMAGE') }}"
33

4-
external_registry: "{{ lookup('env', 'REGISTRY') }}"
5-
external_registry_token: "{{ lookup('env', 'REGISTRY_TOKEN') }}"
6-
external_registry_email: noemail@localhost
7-
84
kubeadminpass: "{{ lookup('env', 'KUBEADMINPASS') }}"
95

106
internal_registry_ns: openshift-marketplace

ansible/roles/iib_ci/tasks/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121

2222
- name: Is OCP pre OCP 4.13? (aka registry supports v2 manifests)
2323
ansible.builtin.set_fact:
24-
use_internal_registry: "{{ oc_version_raw.stdout is version('4.13', '>=') }}"
24+
ocp_413: "{{ oc_version_raw.stdout is version('4.13', '>=') }}"
25+
26+
- name: Fail if OCP < 4.13 as we do not support it for IIB testing any longer
27+
ansible.builtin.fail:
28+
msg: "OCP versions < 4.13 are not support for IIB loading"
29+
when: not ocp_413
2530

2631
- name: Set up internal registry (OCP >= 4.13)
2732
ansible.builtin.include_tasks: setup-internal-registry.yml
28-
when: use_internal_registry
29-
30-
- name: Set up external registry (OCP < 4.13)
31-
ansible.builtin.include_tasks: setup-external-registry.yml
32-
when: not use_internal_registry
3333

3434
- name: Install new IIB in cluster
3535
ansible.builtin.include_tasks: install-iib-in-cluster.yml

ansible/roles/iib_ci/tasks/mirror-related-images.yml

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@
3333
right=$(grep "{{ image }}" "{{ iib_local_folder }}/mapping.txt" | cut -f2 -d=)
3434
right_base=$(echo $right | sed -e 's/:.*$//' -e 's/@.*$//')
3535
right_log=$(echo "${right_base}@${left_sha}" | sed -e 's/\//-/g')
36-
if skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"{{ image }}" &> /tmp/skopeo-"{{ image | regex_replace('/', '-') }}".log; then
36+
left_out=$(skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"{{ image }}" 2>&1)
37+
left_ret=$?
38+
if [ $left_ret -eq 0 ]; then
3739
echo "{{ image }}"
38-
elif skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"${right_base}@${left_sha}" &> "/tmp/skopeo-${right_log}.log"; then
39-
echo "${right_base}@${left_sha}"
4040
else
41-
echo "ERROR: both {{ image }} and echo ${right_base}@${left_sha} could not be found"
42-
exit 1
41+
echo "${left_out}" > /tmp/skopeo-"{{ image | regex_replace('/', '-') }}".log
42+
right_out=$(skopeo inspect --authfile "{{ pull_secrets_tempfolder.path }}/.dockerconfigjson" --no-tags docker://"${right_base}@${left_sha}" 2>&1)
43+
right_ret=$?
44+
if [ $right_ret -eq 0 ]; then
45+
echo "${right_base}@${left_sha}"
46+
else # both left_ret and right_ret were != 0
47+
echo "${right_out}" > "/tmp/skopeo-${right_log}.log"
48+
echo "ERROR: both {{ image }} and echo ${right_base}@${left_sha} could not be found"
49+
echo "Printing both outputs:"
50+
echo "Left out: ${left_out}"
51+
echo "Right out: ${right_out}"
52+
exit 1
53+
fi
4354
fi
4455
register: all_existing_images
4556
with_items: "{{ all_images }}"
@@ -91,16 +102,6 @@
91102
'mirrordest_nosha': (mirror_dest + item | basename) | regex_replace('@.*$', ''),
92103
'mirrordest_tag': 'tag-' + item | basename | regex_replace('^.*@sha256:', '')}}, recursive=true) }}"
93104
loop: "{{ all_images }}"
94-
when: use_internal_registry
95-
96-
- name: Create dict with full image name+sha -> mirror destination (OCP < 4.13)
97-
ansible.builtin.set_fact:
98-
image_urls: "{{ image_urls | default({}) | combine({item:
99-
{'mirrordest': mirror_dest + '@' + item | basename | regex_replace('^.*@', ''),
100-
'mirrordest_nosha': mirror_dest,
101-
'mirrordest_tag': 'tag-' + item | basename | regex_replace('^.*@sha256:', '')}}, recursive=true) }}"
102-
loop: "{{ all_images }}"
103-
when: not use_internal_registry
104105

105106
- name: Create dict with full image name+sha -> image key without sha
106107
ansible.builtin.set_fact:
@@ -124,14 +125,6 @@
124125
src: ./templates/imageDigestMirror.yaml.j2
125126
dest: "{{ iib_local_folder }}/imageMirror.yaml"
126127
mode: "0644"
127-
when: use_internal_registry
128-
129-
- name: Template out imageMirror.yaml (OCP < 4.13)
130-
ansible.builtin.template:
131-
src: ./templates/imageContentSourcePolicy.yaml.j2
132-
dest: "{{ iib_local_folder }}/imageMirror.yaml"
133-
mode: "0644"
134-
when: not use_internal_registry
135128

136129
- name: Template out mirror.map
137130
ansible.builtin.template:

ansible/roles/iib_ci/tasks/setup-external-registry.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)