From 5a8dc3116ff47e0f63e5c7f85fa80ff6a870332d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 20 Mar 2024 15:16:37 +0100 Subject: [PATCH 1/2] misc: Fix cleanup with k3s / rke2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When performing the cleanup with k3s / rke2, we must specify the containerd socket address that's been created by them, instead of using the default one. For both k3s and rke2 the containerd address socket is the same: `/run/k3s/containerd/containerd.sock`. Signed-off-by: Fabiano FidĂȘncio --- misc/snapshotter/snapshotter.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/misc/snapshotter/snapshotter.sh b/misc/snapshotter/snapshotter.sh index ac73fa6d0a..067bb28b19 100644 --- a/misc/snapshotter/snapshotter.sh +++ b/misc/snapshotter/snapshotter.sh @@ -197,8 +197,13 @@ function cleanup_snapshotter() { pid=$(ps -ef | grep containerd-nydus-grpc | grep -v grep | awk '{print $1}') if [ ! -z "$pid" ]; then - for i in $(nsenter -t 1 -m ctr -n k8s.io snapshot --snapshotter nydus list | grep -v KEY | cut -d' ' -f1); do - nsenter -t 1 -m ctr -n k8s.io snapshot --snapshotter nydus rm $i || true + local ctr_args="" + if [[ " k3s k3s-agent rke2-agent rke2-server " =~ " ${CONTAINER_RUNTIME} " ]]; then + ctr_args="--address /run/k3s/containerd/containerd.sock " + fi + ctr_args+="--namespace k8s.io snapshot --snapshotter nydus" + for i in $(nsenter -t 1 -m ctr ${ctr_args} list | grep -v KEY | cut -d' ' -f1); do + nsenter -t 1 -m ctr ${ctr_args} rm $i || true done fi echo "Recover containerd config" From 1b21030182556ee70864e7ef266253f47abab20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 21 Mar 2024 00:07:37 +0100 Subject: [PATCH 2/2] misc: Simplify check for k3s / rke2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's make it simpler, following the same pattern introduced in the cleanup function. Signed-off-by: Fabiano FidĂȘncio --- misc/snapshotter/snapshotter.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/snapshotter/snapshotter.sh b/misc/snapshotter/snapshotter.sh index 067bb28b19..0386543806 100644 --- a/misc/snapshotter/snapshotter.sh +++ b/misc/snapshotter/snapshotter.sh @@ -257,7 +257,7 @@ function main() { fi CONTAINER_RUNTIME=$(get_container_runtime) - if [ "${CONTAINER_RUNTIME}" == "k3s" ] || [ "${CONTAINER_RUNTIME}" == "k3s-agent" ] || [ "${CONTAINER_RUNTIME}" == "rke2-agent" ] || [ "${CONTAINER_RUNTIME}" == "rke2-server" ]; then + if [[ " k3s k3s-agent rke2-agent rke2-server " =~ " ${CONTAINER_RUNTIME} " ]]; then CONTAINER_RUNTIME_CONFIG_TMPL="${CONTAINER_RUNTIME_CONFIG}.tmpl" if [ ! -f "${CONTAINER_RUNTIME_CONFIG_TMPL}" ]; then cp "${CONTAINER_RUNTIME_CONFIG}" "${CONTAINER_RUNTIME_CONFIG_TMPL}"