From f684d00d50d838ea5d0d8744ef3565bfacfe0f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Mon, 5 Sep 2022 14:17:44 +0200 Subject: [PATCH] kata-deploy-cc: Simplify the script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As containerd is the only supported container engine, let's simplify the script and, at the same time, make it clear that other container engines are not supported yet. Signed-off-by: Fabiano FidĂȘncio --- .../kata-deploy-cc/scripts/kata-deploy.sh | 72 +++++++------------ 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh index 27f139dff5..c290cdd0e7 100755 --- a/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy-cc/scripts/kata-deploy.sh @@ -204,11 +204,7 @@ function remove_artifacts() { function cleanup_cri_runtime() { cleanup_different_shims_base - case $1 in - containerd | k3s | k3s-agent | rke2-agent | rke2-server) - cleanup_containerd - ;; - esac + cleanup_containerd } @@ -223,9 +219,7 @@ function reset_runtime() { kubectl label node "$NODE_NAME" katacontainers.io/kata-runtime- systemctl daemon-reload systemctl restart "$1" - if [ "$1" == "containerd" ]; then - systemctl restart kubelet - fi + systemctl restart kubelet } function main() { @@ -236,21 +230,13 @@ function main() { fi runtime=$(get_container_runtime) + if [ "$runtime" != "containerd" ]; then + die "$runtime is not supported for now" + fi - if [ "$runtime" == "k3s" ] || [ "$runtime" == "k3s-agent" ] || [ "$runtime" == "rke2-agent" ] || [ "$runtime" == "rke2-server" ]; then - containerd_conf_tmpl_file="${containerd_conf_file}.tmpl" - if [ ! -f "$containerd_conf_tmpl_file" ]; then - cp "$containerd_conf_file" "$containerd_conf_tmpl_file" - fi - - containerd_conf_file="${containerd_conf_tmpl_file}" - containerd_conf_file_backup="${containerd_conf_file}.bak" - elif [ "$runtime" == "containerd" ]; then - # runtime == containerd - if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && \ - [ -x $(command -v containerd) ]; then - containerd config default > "$containerd_conf_file" - fi + if [ ! -f "$containerd_conf_file" ] && [ -d $(dirname "$containerd_conf_file") ] && \ + [ -x $(command -v containerd) ]; then + containerd config default > "$containerd_conf_file" fi action=${1:-} @@ -259,29 +245,25 @@ function main() { die "invalid arguments" fi - # only install / remove / update if we are dealing with containerd - if [[ "$runtime" =~ ^(containerd|k3s|k3s-agent|rke2-agent|rke2-server)$ ]]; then - - case "$action" in - install) - install_artifacts - configure_cri_runtime "$runtime" - kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true - ;; - cleanup) - cleanup_cri_runtime "$runtime" - kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup - remove_artifacts - ;; - reset) - reset_runtime $runtime - ;; - *) - echo invalid arguments - print_usage - ;; - esac - fi + case "$action" in + install) + install_artifacts + configure_cri_runtime "$runtime" + kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=true + ;; + cleanup) + cleanup_cri_runtime "$runtime" + kubectl label node "$NODE_NAME" --overwrite katacontainers.io/kata-runtime=cleanup + remove_artifacts + ;; + reset) + reset_runtime $runtime + ;; + *) + echo invalid arguments + print_usage + ;; + esac #It is assumed this script will be called as a daemonset. As a result, do # not return, otherwise the daemon will restart and rexecute the script