diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 0780261d85..79bfab26fd 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -552,6 +552,18 @@ function remove_artifacts() { fi } +function restart_cri_runtime() { + local runtime="${1}" + + if [ "${runtime}" == "k0s-worker" ] || [ "${runtime}" == "k0s-controller" ]; then + # do nothing, k0s will automatically unload the config on the fly + : + else + host_systemctl daemon-reload + host_systemctl restart "${runtime}" + fi +} + function cleanup_cri_runtime() { case $1 in crio) @@ -565,13 +577,7 @@ function cleanup_cri_runtime() { [ "${HELM_POST_DELETE_HOOK}" == "false" ] && return # Only run this code in the HELM_POST_DELETE_HOOK - if [ "$1" == "k0s-worker" ] || [ "$1" == "k0s-controller" ]; then - # do nothing, k0s will automatically unload the config on the fly - : - else - host_systemctl daemon-reload - host_systemctl restart "$1" - fi + restart_cri_runtime "$1" } function cleanup_crio() { @@ -590,13 +596,7 @@ function cleanup_containerd() { function reset_runtime() { kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime- - if [ "$1" == "k0s-worker" ] || [ "$1" == "k0s-controller" ]; then - # do nothing, k0s will auto restart - : - else - host_systemctl daemon-reload - host_systemctl restart "$1" - fi + restart_cri_runtime "$1" if [ "$1" == "crio" ] || [ "$1" == "containerd" ]; then host_systemctl restart kubelet