From bb9bcd886acd9677affb401cd0a0252475c0531e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 3 Sep 2024 09:52:25 +0200 Subject: [PATCH] kata-deploy: Add reset_cri_runtime() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will help to avoid code duplication on what's needed on the helm and non-helm cases. The reason it's not been added as part of the commit which adds the post-delete hook is simply for helping the reviewer (as the diff would be less readable with this change). Signed-off-by: Fabiano FidĂȘncio --- .../kata-deploy/scripts/kata-deploy.sh | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) 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