mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
kata-deploy: Improve shim backup / restore
We're currently backing up and restoring all the possible shim files, but the default one ("containerd-shim-kata-v2"). Let's ensure this is also backed up and restored. Fixes: #6957 Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
parent
7c9faab523
commit
428041624a
@ -92,6 +92,20 @@ function configure_cri_runtime() {
|
|||||||
wait_till_node_is_ready
|
wait_till_node_is_ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function backup_shim() {
|
||||||
|
local shim_file="$1"
|
||||||
|
local shim_backup="${shim_file}.bak"
|
||||||
|
|
||||||
|
if [ -f "${shim_file}" ]; then
|
||||||
|
echo "warning: ${shim_file} already exists" >&2
|
||||||
|
if [ ! -f "${shim_backup}" ]; then
|
||||||
|
mv "${shim_file}" "${shim_backup}"
|
||||||
|
else
|
||||||
|
rm "${shim_file}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function configure_different_shims_base() {
|
function configure_different_shims_base() {
|
||||||
# Currently containerd has an assumption on the location of the shimv2 implementation
|
# Currently containerd has an assumption on the location of the shimv2 implementation
|
||||||
# This forces kata-deploy to create files in a well-defined location that's part of
|
# This forces kata-deploy to create files in a well-defined location that's part of
|
||||||
@ -100,21 +114,15 @@ function configure_different_shims_base() {
|
|||||||
# https://github.com/containerd/containerd/issues/3073
|
# https://github.com/containerd/containerd/issues/3073
|
||||||
# https://github.com/containerd/containerd/issues/5006
|
# https://github.com/containerd/containerd/issues/5006
|
||||||
|
|
||||||
|
local default_shim_file="/usr/local/bin/containerd-shim-kata-v2"
|
||||||
|
|
||||||
mkdir -p /usr/local/bin
|
mkdir -p /usr/local/bin
|
||||||
|
|
||||||
for shim in "${shims[@]}"; do
|
for shim in "${shims[@]}"; do
|
||||||
local shim_binary="containerd-shim-kata-${shim}-v2"
|
local shim_binary="containerd-shim-kata-${shim}-v2"
|
||||||
local shim_file="/usr/local/bin/${shim_binary}"
|
local shim_file="/usr/local/bin/${shim_binary}"
|
||||||
local shim_backup="/usr/local/bin/${shim_binary}.bak"
|
|
||||||
|
|
||||||
if [ -f "${shim_file}" ]; then
|
backup_shim "${shim_file}"
|
||||||
echo "warning: ${shim_binary} already exists" >&2
|
|
||||||
if [ ! -f "${shim_backup}" ]; then
|
|
||||||
mv "${shim_file}" "${shim_backup}"
|
|
||||||
else
|
|
||||||
rm "${shim_file}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "${shim}" == "dragonball" ]]; then
|
if [[ "${shim}" == "dragonball" ]]; then
|
||||||
ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}"
|
ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}"
|
||||||
@ -124,26 +132,37 @@ function configure_different_shims_base() {
|
|||||||
chmod +x "$shim_file"
|
chmod +x "$shim_file"
|
||||||
|
|
||||||
if [ "${shim}" == "${default_shim}" ]; then
|
if [ "${shim}" == "${default_shim}" ]; then
|
||||||
|
backup_shim "${default_shim_file}"
|
||||||
|
|
||||||
echo "Creating the default shim-v2 binary"
|
echo "Creating the default shim-v2 binary"
|
||||||
ln -sf "${shim_file}" /usr/local/bin/containerd-shim-kata-v2
|
ln -sf "${shim_file}" "${default_shim_file}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_different_shims_base() {
|
function restore_shim() {
|
||||||
for shim in "${shims[@]}"; do
|
local shim_file="$1"
|
||||||
local shim_binary="containerd-shim-kata-${shim}-v2"
|
local shim_backup="${shim_file}.bak"
|
||||||
local shim_file="/usr/local/bin/${shim_binary}"
|
|
||||||
local shim_backup="/usr/local/bin/${shim_binary}.bak"
|
|
||||||
|
|
||||||
rm "${shim_file}" || true
|
|
||||||
|
|
||||||
if [ -f "${shim_backup}" ]; then
|
if [ -f "${shim_backup}" ]; then
|
||||||
mv "$shim_backup" "$shim_file"
|
mv "$shim_backup" "$shim_file"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup_different_shims_base() {
|
||||||
|
local default_shim_file="/usr/local/bin/containerd-shim-kata-v2"
|
||||||
|
|
||||||
|
for shim in "${shims[@]}"; do
|
||||||
|
local shim_binary="containerd-shim-kata-${shim}-v2"
|
||||||
|
local shim_file="/usr/local/bin/${shim_binary}"
|
||||||
|
|
||||||
|
rm "${shim_file}" || true
|
||||||
|
|
||||||
|
restore_shim "${shim_file}"
|
||||||
done
|
done
|
||||||
|
|
||||||
rm /usr/local/bin/containerd-shim-kata-v2
|
rm "${default_shim_file}" || true
|
||||||
|
restore_shim "${default_shim_file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_crio_runtime() {
|
function configure_crio_runtime() {
|
||||||
|
Loading…
Reference in New Issue
Block a user