Skip to content

Commit

Permalink
misc: Fix cleanup with k3s / rke2
Browse files Browse the repository at this point in the history
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 <fabiano.fidencio@intel.com>
  • Loading branch information
fidencio committed Mar 20, 2024
1 parent c7841c7 commit c60bd96
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions misc/snapshotter/snapshotter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [ "${CONTAINER_RUNTIME}" == "k3s" ] || [ "${CONTAINER_RUNTIME}" == "k3s-agent" ] || [ "${CONTAINER_RUNTIME}" == "rke2-agent" ] || [ "${CONTAINER_RUNTIME}" == "rke2-server" ]; then
ctr_args="--address /run/k3s/containerd/containerd.sock "
fi
ctr_args+="--namespace k8s.io --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"
Expand Down

0 comments on commit c60bd96

Please sign in to comment.