Skip to content

Commit f3d84db

Browse files
committed
fix: Aggressively clean podman storage before image transfer
Kill running podman processes and remove all locks/db files before transferring localhost images to rootful storage. Unconditionally re-transfer to avoid stale state issues. pre-commit.check-secrets: ENABLED
1 parent 3108b0d commit f3d84db

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

scripts/start-bootc-vm.sh

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,29 @@ mkdir -p "${VM_DIR}/bib-tmp"
9797
if [[ "${IMAGE}" == localhost/* ]]; then
9898
echo "STEP-01 Using local image ${IMAGE}..."
9999

100-
# For localhost images, always transfer to rootful storage to ensure it's available
101-
# Clean up any stale locks first
102-
echo "STEP-01 Cleaning up container storage locks..."
103-
sudo find /var/lib/containers/storage -name '*.lock' -type f -mmin +10 -delete 2>/dev/null || true
104-
105-
# Check if image exists in rootful storage
106-
if sudo podman image exists "${IMAGE}" 2>/dev/null; then
107-
echo "STEP-01 Image already in rootful storage, verifying..."
108-
# Verify it's accessible by getting the image ID
109-
if ! sudo podman image inspect "${IMAGE}" --format '{{.Id}}' >/dev/null 2>&1; then
110-
echo "STEP-01 Image corrupted, removing and re-transferring..."
111-
sudo podman rmi "${IMAGE}" 2>/dev/null || true
112-
else
113-
echo "STEP-01 Image verified in rootful storage."
114-
fi
115-
fi
116-
117-
# If image doesn't exist or was removed, transfer it
118-
if ! sudo podman image exists "${IMAGE}" 2>/dev/null; then
119-
echo "STEP-01 Transferring ${IMAGE} to rootful podman storage..."
120-
podman save "${IMAGE}" | sudo podman load
100+
# For localhost images, transfer to rootful storage
101+
# Stop any running podman processes that might hold locks
102+
echo "STEP-01 Stopping podman processes..."
103+
sudo pkill -9 podman 2>/dev/null || true
104+
sleep 2
105+
106+
# Clean up stale locks and corrupted storage
107+
echo "STEP-01 Cleaning up container storage..."
108+
sudo find /var/lib/containers/storage -name '*.lock' -delete 2>/dev/null || true
109+
sudo rm -f /var/lib/containers/storage/libpod/bolt_state.db-shm 2>/dev/null || true
110+
sudo rm -f /var/lib/containers/storage/libpod/bolt_state.db-wal 2>/dev/null || true
111+
112+
# Unconditionally transfer the image to ensure it's fresh
113+
echo "STEP-01 Transferring ${IMAGE} to rootful podman storage..."
114+
sudo podman rmi "${IMAGE}" 2>/dev/null || true
115+
podman save "${IMAGE}" | sudo podman load
116+
117+
# Verify the image is now accessible
118+
if ! sudo podman image inspect "${IMAGE}" --format '{{.Id}}' >/dev/null 2>&1; then
119+
echo "ERROR: Failed to transfer ${IMAGE} to rootful storage"
120+
exit 1
121121
fi
122+
echo "STEP-01 Image verified in rootful storage."
122123
else
123124
echo "STEP-01 Pulling ${IMAGE}..."
124125
sudo podman pull "${IMAGE}"

0 commit comments

Comments
 (0)