kata-deploy: Don't fail if the runtimeclass is already deleted

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 <fabiano@fidencio.org>
This commit is contained in:
Fabiano Fidêncio
2025-09-05 17:22:28 +02:00
parent 34925ae740
commit 1d5124e8bc

View File

@@ -140,10 +140,13 @@ function delete_runtimeclasses() {
for shim in "${shims[@]}"; do for shim in "${shims[@]}"; do
echo "Deleting the kata-${shim} runtime class" echo "Deleting the kata-${shim} runtime class"
canonical_shim_name="kata-${shim}"
shim_name="${canonical_shim_name}"
if [ -n "${MULTI_INSTALL_SUFFIX}" ]; then 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 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 done
@@ -157,7 +160,7 @@ function delete_runtimeclasses() {
echo "Deleting the kata runtime class for the default shim (an alias for kata-${default_shim})" 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 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 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 rm -f /tmp/kata.yaml
fi fi
} }