Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Fix cleanup with k3s / rke2 #586

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 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 [[ " 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"
Expand Down Expand Up @@ -252,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}"
Expand Down
Loading