Merge pull request #92314 from dims/set-better-default-for-loading-images-2

Set better default commands for loading images - take 2
This commit is contained in:
Kubernetes Prow Robot 2020-06-21 05:12:39 -07:00 committed by GitHub
commit 4c8207dc1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -376,9 +376,18 @@ function try-load-docker-image {
set +e
local -r max_attempts=5
local -i attempt_num=1
until timeout 30 ${LOAD_IMAGE_COMMAND:-docker load -i} "${img}"; do
if [[ "${CONTAINER_RUNTIME_NAME:-}" == "docker" ]]; then
load_image_command=${LOAD_IMAGE_COMMAND:-docker load -i}
elif [[ "${CONTAINER_RUNTIME_NAME:-}" == "containerd" ]]; then
load_image_command=${LOAD_IMAGE_COMMAND:-ctr -n=k8s.io images import}
else
load_image_command="${LOAD_IMAGE_COMMAND:-}"
fi
until timeout 30 ${load_image_command} "${img}"; do
if [[ "${attempt_num}" == "${max_attempts}" ]]; then
echo "Fail to load docker image file ${img} after ${max_attempts} retries. Exit!!"
echo "Fail to load docker image file ${img} using ${load_image_command} after ${max_attempts} retries. Exit!!"
exit 1
else
attempt_num=$((attempt_num+1))