Try to migrate to a supported OCI runtime if 'podman start' suggests so
Toolbox containers using runc as their runtime don't work on host operating systems using cgroups v2. They need to be migrated to crun. 'podman start' throws a specific error for such containers: ERRO[0000]: oci runtime "runc" does not support CGroups V2: use system migrate to mitigate Error: unable to start container "fedora-toolbox-30": this version of runc doesn't work on cgroups v2: OCI runtime error This error is identified by the phrase "use system migrate to mitigate" to avoid encoding any assumptions about updating from cgroups v1 to v2 or downgrading in the other direction. If the migration fails, 'toolbox reset' is suggested as the last hope. https://github.com/containers/toolbox/pull/309
This commit is contained in:
parent
3496029ed7
commit
2e7ba83be2
1 changed files with 38 additions and 3 deletions
41
toolbox
41
toolbox
|
@ -249,9 +249,44 @@ container_start()
|
|||
(
|
||||
container="$1"
|
||||
|
||||
if ! podman start "$container" >/dev/null 2>&3; then
|
||||
echo "$base_toolbox_command: failed to start container $container" >&2
|
||||
return 1
|
||||
error_message=$( (podman start "$container" >/dev/null) 2>&1)
|
||||
ret_val="$?"
|
||||
[ "$error_message" != "" ] 2>&3 && echo "$error_message" >&3
|
||||
|
||||
if [ "$ret_val" -ne 0 ] 2>&3; then
|
||||
if echo "$error_message" | grep "use system migrate to mitigate" >/dev/null 2>&3; then
|
||||
echo "$base_toolbox_command: checking if 'podman system migrate' supports --new-runtime" >&3
|
||||
|
||||
if ! (podman system migrate --help 2>&3 | grep "new-runtime" >/dev/null 2>&3); then
|
||||
echo "$base_toolbox_command: container $container doesn't support cgroups v$cgroups_version" >&2
|
||||
echo "Update Podman to version 1.6.2 or newer." >&2
|
||||
return 1
|
||||
else
|
||||
echo "$base_toolbox_command: 'podman system migrate' supports --new-runtime" >&3
|
||||
|
||||
oci_runtime_required="runc"
|
||||
[ "$cgroups_version" -eq 2 ] 2>&3 && oci_runtime_required="crun"
|
||||
|
||||
echo "$base_toolbox_command: migrating containers to OCI runtime $oci_runtime_required" >&3
|
||||
|
||||
if ! podman system migrate --new-runtime "$oci_runtime_required" >/dev/null 2>&3; then
|
||||
echo "$base_toolbox_command: failed to migrate containers to OCI runtime $oci_runtime_required" >&2
|
||||
echo "Factory reset with: toolbox reset" >&2
|
||||
echo "Try '$base_toolbox_command --help' for more information." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! podman start "$container" >/dev/null 2>&3; then
|
||||
echo "$base_toolbox_command: container $container doesn't support cgroups v$cgroups_version" >&2
|
||||
echo "Factory reset with: toolbox reset" >&2
|
||||
echo "Try '$base_toolbox_command --help' for more information." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "$base_toolbox_command: failed to start container $container" >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue