Skip to content

Commit bf52d36

Browse files
committed
fix: use index_image_resolved for ts index
Signed-off-by: Leandro Mendes <lmendes@redhat.com>
1 parent 3cd581b commit bf52d36

3 files changed

Lines changed: 43 additions & 6 deletions

File tree

tasks/managed/publish-index-image/publish-index-image.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ spec:
152152
153153
sourceIndex="$(jq -r --argjson i "$i" \
154154
'.components[$i].index_image' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
155+
sourceResolvedIndex="$(jq -r --argjson i "$i" \
156+
'.components[$i].index_image_resolved' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
155157
156158
targetOcpVersion=$(jq -r --argjson i "$i" \
157159
'.components[$i].ocp_version' "$(params.dataDir)/$(params.internalRequestResultsFile)")
@@ -173,6 +175,13 @@ spec:
173175
for((x=0; x<${#publishingImages[@]}; x++ )); do
174176
echo "=== Creating internal request to publish image:"
175177
echo ""
178+
179+
# if we are pushing the timestamped index (always the index #1), we should
180+
# use index_image_resolved instead, because the target_index sha can poten_
181+
# tially be changed by a concurrent fbc process.
182+
if [ "$x" -eq 1 ]; then
183+
sourceIndex="$sourceResolvedIndex"
184+
fi
176185
echo "- from: ${sourceIndex}"
177186
echo "- to: ${publishingImages[$x]}"
178187

tasks/managed/publish-index-image/tests/test-publish-index-image-with-timestamp.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,23 @@ spec:
193193
exit 1
194194
fi
195195
196-
if [ "$(jq -r '.sourceIndex' <<< "${params}")" != "redhat.com/rh-stage/iib:01" ]; then
197-
echo "sourceIndex image does not match for IR $i"
198-
exit 1
196+
sourceIndex=$(jq -r '.sourceIndex' <<< "${params}")
197+
# IR 0 (first created, x=0) should use index_image (tag)
198+
# IR 1 (second created, x=1) should use index_image_resolved (digest)
199+
if [ $i = 0 ]; then
200+
if [ "$sourceIndex" != "redhat.com/rh-stage/iib:01" ]; then
201+
echo "sourceIndex image does not match for IR 0"
202+
echo "Expected: redhat.com/rh-stage/iib:01"
203+
echo "Got: $sourceIndex"
204+
exit 1
205+
fi
206+
else
207+
if [ "$sourceIndex" != "redhat.com/rh-stage/iib@sha256:abcdefghijk" ]; then
208+
echo "sourceIndex image does not match for IR 1"
209+
echo "Expected: redhat.com/rh-stage/iib@sha256:abcdefghijk"
210+
echo "Got: $sourceIndex"
211+
exit 1
212+
fi
199213
fi
200214
201215
targetIndex=$(jq -r '.targetIndex' <<< "${params}")

tasks/managed/publish-index-image/tests/test-publish-index-image.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,23 @@ spec:
188188
exit 1
189189
fi
190190
191-
if [ "$(jq -r '.sourceIndex' <<< "${params}")" != "redhat.com/rh-stage/iib:01" ]; then
192-
echo "sourceIndex image does not match"
193-
exit 1
191+
sourceIndex=$(jq -r '.sourceIndex' <<< "${params}")
192+
# IR 0 (first created, x=0) should use index_image (tag)
193+
# IR 1 (second created, x=1) should use index_image_resolved (digest)
194+
if [ $i = 0 ]; then
195+
if [ "$sourceIndex" != "redhat.com/rh-stage/iib:01" ]; then
196+
echo "sourceIndex image does not match for IR 0"
197+
echo "Expected: redhat.com/rh-stage/iib:01"
198+
echo "Got: $sourceIndex"
199+
exit 1
200+
fi
201+
else
202+
if [ "$sourceIndex" != "redhat.com/rh-stage/iib@sha256:abcdefghijk" ]; then
203+
echo "sourceIndex image does not match for IR 1"
204+
echo "Expected: redhat.com/rh-stage/iib@sha256:abcdefghijk"
205+
echo "Got: $sourceIndex"
206+
exit 1
207+
fi
194208
fi
195209
196210
targetIndex=$(jq -r '.targetIndex' <<< "${params}")

0 commit comments

Comments
 (0)