Skip to content

Commit e0d79e0

Browse files
committed
improve cleanup logic
Signed-off-by: Justin Alvarez <[email protected]>
1 parent 678771f commit e0d79e0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/thinpool.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ else
153153
if command -v ctr >/dev/null 2>&1; then
154154
echo "Cleaning up containerd snapshots..."
155155
# List and remove any active snapshots using containerd API
156-
for snap in $(ctr --address /run/firecracker-containerd/containerd.sock snapshots list -q 2>/dev/null || true); do
157-
echo "Removing containerd snapshot: $snap"
158-
ctr --address /run/firecracker-containerd/containerd.sock snapshots remove "$snap" 2>/dev/null || true
156+
for snap in $(ctr --address /run/firecracker-containerd/containerd.sock snapshots list 2>/dev/null | tail -n +2 | awk '{print $1}' || true); do
157+
if [ -n "$snap" ] && [ "$snap" != "KEY" ]; then
158+
echo "Removing containerd snapshot: $snap"
159+
ctr --address /run/firecracker-containerd/containerd.sock snapshots remove "$snap" 2>/dev/null || true
160+
fi
159161
done
160162

161163
# Give containerd time to release device references
@@ -164,7 +166,7 @@ else
164166

165167
# Sync filesystem and drop caches to help release any remaining references
166168
sync
167-
echo 1 > /proc/sys/vm/drop_caches 2>/dev/null || true
169+
sudo bash -c 'echo 1 > /proc/sys/vm/drop_caches' 2>/dev/null || true
168170

169171
pool_remove
170172
fi

0 commit comments

Comments
 (0)