@@ -97,28 +97,29 @@ mkdir -p "${VM_DIR}/bib-tmp"
9797if [[ " ${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."
122123else
123124 echo " STEP-01 Pulling ${IMAGE} ..."
124125 sudo podman pull " ${IMAGE} "
0 commit comments