Skip to content

Commit 5702167

Browse files
committed
Rearchitect the code so we can print out the actual error
1 parent f50deb9 commit 5702167

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

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

Lines changed: 16 additions & 5 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 }}"

0 commit comments

Comments
 (0)