Skip to content

Commit ec80ffd

Browse files
committed
fix(KONFLUX-11837): make sure the resolved index is published
This PR changes the publish-index-image task to make sure the index_image_resolved image is published to the repo with its unique floating tag. This is due to the fact that another process writing to the same OCP index might change the sha while the build is happening and a different sha is actually published. Signed-off-by: Leandro Mendes <lmendes@redhat.com>
1 parent df37882 commit ec80ffd

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,18 @@ spec:
147147
pipelinerun_label="internal-services.appstudio.openshift.io/pipelinerun-uid"
148148
149149
LENGTH="$(jq -r '.components | length' "$(params.dataDir)/$(params.internalRequestResultsFile)")"
150+
sourceIndex=()
150151
for((i=0; i<LENGTH; i++)); do
151152
targetIndex=$(jq -r --argjson i "$i" \
152153
'.components[$i].target_index' "$(params.dataDir)/$(params.internalRequestResultsFile)")
153154
154-
sourceIndex=$(jq -r --argjson i "$i" \
155-
'.components[$i].index_image' "$(params.dataDir)/$(params.internalRequestResultsFile)")
155+
sourceIndex+=("$(jq -r --argjson i "$i" \
156+
'.components[$i].index_image' "$(params.dataDir)/$(params.internalRequestResultsFile)")")
157+
158+
# we need the resolved index_image as the published pub index might be replaced by another process,
159+
# causing pyxis to fail, so we need to publish the resolved as the timestamped one.
160+
sourceIndex+=("$(jq -r --argjson i "$i" \
161+
'.components[$i].index_image_resolved' "$(params.dataDir)/$(params.internalRequestResultsFile)")")
156162
157163
buildTimestamp=$(jq -r --argjson i "$i" '.components[$i].completion_time' \
158164
"$(params.dataDir)/$(params.internalRequestResultsFile)")
@@ -171,11 +177,11 @@ spec:
171177
for((x=0; x<${#publishingImages[@]}; x++ )); do
172178
echo "=== Creating internal request to publish image:"
173179
echo ""
174-
echo "- from: ${sourceIndex}"
180+
echo "- from: ${sourceIndex[$x]}"
175181
echo "- to: ${publishingImages[$x]}"
176182
177183
internal-request --pipeline "${request}" \
178-
-p sourceIndex="${sourceIndex}" \
184+
-p sourceIndex="${sourceIndex[$x]}" \
179185
-p targetIndex="${publishingImages[$x]}" \
180186
-p publishingCredentials="${credentials}" \
181187
-p retries="$(params.retries)" \

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,19 @@ spec:
189189
exit 1
190190
fi
191191
192-
if [ "$(jq -r '.sourceIndex' <<< "${params}")" != "redhat.com/rh-stage/iib:01" ]; then
192+
targetIndex=$(jq -r '.targetIndex' <<< "${params}")
193+
expectedSourceIndex="redhat.com/rh-stage/iib:01"
194+
if [[ "$targetIndex" == *"2023-03-06T16:39:11.314092Z" ]]; then
195+
expectedSourceIndex="redhat.com/rh-stage/iib@sha256:abcdefghijk"
196+
fi
197+
198+
if [ "$(jq -r '.sourceIndex' <<< "${params}")" != "$expectedSourceIndex" ]; then
193199
echo "sourceIndex image does not match"
194200
exit 1
195201
fi
196202
197203
targetIndex=$(jq -r '.targetIndex' <<< "${params}")
198-
if [ $i = 0 ]; then
204+
if [ "$i" -eq 0 ]; then
199205
if [ "$targetIndex" != "quay.io/scoheb/fbc-target-index-testing:v4.12" ]; then
200206
echo "targetIndex image does not match"
201207
exit 1

0 commit comments

Comments
 (0)