Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set better default commands for loading images - take 2 #92314

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions cluster/gce/gci/configure.sh
Expand Up @@ -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:-}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't allow this case to succeed if the command is empty? maybe:

Suggested change
load_image_command="${LOAD_IMAGE_COMMAND:-}"
load_image_command="${LOAD_IMAGE_COMMAND:?}"

or better yet an explicit check + error message

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the latter is probably best. :? will just ensure it was set (but could still be empty I think)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is unsupported runtime, it should fail at line 390.
In theory, failing earlier will be better. But I did not see we
have functions like assert or exit in this file.

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))
Expand Down