Skip to content

Commit c2374ca

Browse files
Merge pull request #4261 from pacevedom/revert-skopeo-retry
[release-4.18] USHIFT-4737: Revert skopeo retry
2 parents 38e106a + 73d65bd commit c2374ca

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

scripts/mirror-images.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ function usage() {
1818
exit 1
1919
}
2020

21+
function skopeo_retry() {
22+
for attempt in $(seq 3) ; do
23+
if ! skopeo "$@" ; then
24+
echo "WARNING: Failed to run skopeo, retry #${attempt}"
25+
else
26+
return 0
27+
fi
28+
sleep $(( "${attempt}" * 10 ))
29+
done
30+
31+
echo "ERROR: Failed to run skopeo, quitting after 3 tries"
32+
return 1
33+
}
34+
2135
function mirror_registry() {
2236
local -r img_pull_file=$1
2337
local -r img_file_list=$2
@@ -39,15 +53,13 @@ function mirror_registry() {
3953

4054
# Run the image mirror and tag command
4155
echo "Mirroring '${src_img}' to '${dst_img}'"
42-
skopeo copy --all --quiet \
43-
--retry-times 3 \
56+
skopeo_retry copy --all --quiet \
4457
--preserve-digests \
4558
--authfile "${img_pull_file}" \
4659
docker://"${src_img}" docker://"${dst_img}"
4760

4861
echo "Tagging '${dst_img_no_tag}' as 'latest'"
49-
skopeo copy --all --quiet \
50-
--retry-times 3 \
62+
skopeo_retry copy --all --quiet \
5163
--preserve-digests \
5264
--authfile "${img_pull_file}" \
5365
docker://"${dst_img}" docker://"${dst_img_no_tag}:latest"
@@ -56,6 +68,7 @@ function mirror_registry() {
5668

5769
# Export functions for xargs to use
5870
export -f process_image_copy
71+
export -f skopeo_retry
5972
# Note that images are passed as one argument by replacing "{}" in xarg input.
6073
xargs -P 8 -I {} -a "${img_file_list}" \
6174
bash -c 'process_image_copy "$@"' _ "${img_pull_file}" "${dest_registry}" "{}"
@@ -78,15 +91,15 @@ function registry_to_dir() {
7891
# Run the image download command
7992
echo "Downloading '${src_img}' to '${local_dir}'"
8093
mkdir -p "${local_dir}/${dst_img}"
81-
skopeo copy --all --quiet \
82-
--retry-times 3 \
94+
skopeo_retry copy --all --quiet \
8395
--preserve-digests \
8496
--authfile "${img_pull_file}" \
8597
docker://"${src_img}" dir://"${local_dir}/${dst_img}"
8698
}
8799

88100
# Export functions for xargs to use
89101
export -f process_image_copy
102+
export -f skopeo_retry
90103
# Generate a list for each image and run copy in parallel.
91104
# Note that the image is passed by replacing "{}" in xarg input.
92105
xargs -P 8 -I {} -a "${img_file_list}" \
@@ -113,22 +126,21 @@ function dir_to_registry() {
113126

114127
# Run the image upload and tag commands
115128
echo "Uploading '${src_img}' to '${dst_img}'"
116-
skopeo copy --all --quiet \
117-
--retry-times 3 \
129+
skopeo_retry copy --all --quiet \
118130
--preserve-digests \
119131
--authfile "${img_pull_file}" \
120132
dir://"${local_dir}/${src_img}" docker://"${dst_img}"
121133

122134
echo "Tagging '${dst_img}' as '${dst_img_no_tag}:latest'"
123135
skopeo copy --all --quiet \
124-
--retry-times 3 \
125136
--preserve-digests \
126137
--authfile "${img_pull_file}" \
127138
docker://"${dst_img}" docker://"${dst_img_no_tag}:latest"
128139
}
129140

130141
# Export functions for xargs to use
131142
export -f process_image_copy
143+
export -f skopeo_retry
132144

133145
# Generate a list with an incremental counter for each image and run copy in parallel.
134146
# Note that the counter and image pairs are passed as one argument by replacing "{}" in xarg input.

0 commit comments

Comments
 (0)