Add retries and wait after disk attach operation

This commit is contained in:
Gennady Lipenkov 2020-11-24 19:15:46 +03:00
parent 73b7499811
commit 138e3a081b
1 changed files with 15 additions and 1 deletions

View File

@ -110,8 +110,22 @@ if ! yc compute instance attach-disk ${INSTANCE_ID} --disk-name ${DISKNAME} --de
Exit 1
fi
DISK_LINK="/dev/disk/by-id/virtio-doexport"
echo "Waiting for disk..."
for attempt in 1 2 3; do
if [ -L "${DISK_LINK}" ]; then
break
fi
echo "Attempt ${attempt}"
if [ ${attempt} -eq 3 ]; then
echo "Symlink ${DISK_LINK} not found"
Exit 1
fi
sleep 3
done
echo "Dumping disk..."
if ! qemu-img convert -O qcow2 -o cluster_size=2M /dev/disk/by-id/virtio-doexport disk.qcow2 ; then
if ! qemu-img convert -O qcow2 -o cluster_size=2M "${DISK_LINK}" disk.qcow2 ; then
echo "Failed to dump disk to qcow2 image."
Exit 1
fi