From 1d5124e8bc84d23347b966057fa1c06574caa970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 5 Sep 2025 17:22:28 +0200 Subject: [PATCH] kata-deploy: Don't fail if the runtimeclass is already deleted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I've hit this when using a machine with slow internet connection, which took ages to download the kata-cleanup image, and then helm timed out in the middle of the cleanup, leading to the cleanup job being restarted and then bailing with an error as the runtimeclasses that kata-deploy tries to delete were already deleted. Signed-off-by: Fabiano FidĂȘncio --- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 745e2f6740..9930e13d6c 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -140,10 +140,13 @@ function delete_runtimeclasses() { for shim in "${shims[@]}"; do echo "Deleting the kata-${shim} runtime class" + canonical_shim_name="kata-${shim}" + shim_name="${canonical_shim_name}" if [ -n "${MULTI_INSTALL_SUFFIX}" ]; then - sed -i -e "s|kata-${shim}|kata-${shim}-${MULTI_INSTALL_SUFFIX}|g" /opt/kata-artifacts/runtimeclasses/kata-${shim}.yaml + shim_name+="-${MULTI_INSTALL_SUFFIX}" + sed -i -e "s|${canonical_shim_name}|${shim_name}|g" /opt/kata-artifacts/runtimeclasses/${canonical_shim_name}.yaml fi - kubectl delete -f /opt/kata-artifacts/runtimeclasses/kata-${shim}.yaml + kubectl delete --ignore-not-found -f /opt/kata-artifacts/runtimeclasses/${canonical_shim_name}.yaml done @@ -157,7 +160,7 @@ function delete_runtimeclasses() { echo "Deleting the kata runtime class for the default shim (an alias for kata-${default_shim})" cp /opt/kata-artifacts/runtimeclasses/kata-${default_shim}.yaml /tmp/kata.yaml sed -i -e 's/name: kata-'${default_shim}'/name: kata/g' /tmp/kata.yaml - kubectl delete -f /tmp/kata.yaml + kubectl delete --ignore-not-found -f /tmp/kata.yaml rm -f /tmp/kata.yaml fi }