Commit 6a20ecd8 authored by Martin Peres's avatar Martin Peres
Browse files

podman: use the create/init/start sequence rather than run to catch setup errors

This enables us to retry setting up the container, in case of network
issues, or cache issues.
parent a461eafa
......@@ -217,8 +217,36 @@ function setup_container_runtime {
log "Container runtime setup: DONE"
}
function create_container {
log "Pull, create, and init the container"
# Podman is not super good at explaining what went wrong when creating a
# container, so just try multiple times, each time increasing the size of
# the hammer!
for i in 0 1 2 3; do
# Set up the wanted container
container_id=`podman create --rm --privileged --network=host --runtime /bin/crun-no-pivot $@` \
&& podman init "$container_id" && return 0
# The command failed... Ignore the first 3 times, as we want to check it
# is not a shortlived-network error
if [ $i -eq 3 ]; then
# Try resetting the entire state of podman, before trying again!
podman system reset -f
fi
sleep 1
done
return 1
}
function start_container {
podman run --rm --privileged --network=host --runtime /bin/crun-no-pivot $@
container_id=""
create_container $@ || return 1
log "Start the container"
podman start -a "$container_id"
}
# Do not print all the early commands
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment