This repository was archived by the owner on Jan 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,24 +192,38 @@ function get_new_context {
192192
193193 log debug " Mounting CD-ROM ${dev_context} on ${MOUNT_DIR} "
194194
195- case " ${distro} " in
196- Linux)
197- mount -o ro " ${dev_context} " " ${MOUNT_DIR} " 2> /dev/null
198- ;;
199- BSD)
200- mount_cd9660 " ${dev_context} " " ${MOUNT_DIR} " 2> /dev/null
201- ;;
202- * )
203- echo " ERROR: Unsupported distro ${distro} "
204- exit 1
205- esac
206-
207- if [ " $? " != ' 0' ]; then
195+ # Retry mounting several times
196+ # https://github.com/OpenNebula/addon-context-linux/issues/247
197+ _timeout=6
198+ while [ " $_timeout " -gt 0 ] ; do
199+ case " ${distro} " in
200+ Linux)
201+ mount -o ro " ${dev_context} " " ${MOUNT_DIR} " 2> /dev/null
202+ ;;
203+ BSD)
204+ mount_cd9660 " ${dev_context} " " ${MOUNT_DIR} " 2> /dev/null
205+ ;;
206+ * )
207+ echo " ERROR: Unsupported distribution - ${distro} " >&2
208+ exit 1
209+ esac
210+
211+ if [ $? -eq 0 ] ; then
212+ _mount_dir_mounted=yes
213+ break
214+ else
215+ # sleep and retry
216+ _timeout=$(( _timeout - 1 ))
217+ log debug " Mount failed (retries left: (${_timeout} )"
218+ sleep 1
219+ fi
220+ done
221+
222+ if [ " ${_timeout} " -eq 0 ] || [ " ${_mount_dir_mounted} " != ' yes' ]; then
208223 log err " Error: Failed to mount ${dev_context} " 2
209224 exit 1
210225 fi
211226
212- _mount_dir_mounted=yes
213227 context_sh $MOUNT_DIR
214228
215229 elif find ' /context' -mindepth 1 -print 2> /dev/null | grep -q . ; then
You can’t perform that action at this time.
0 commit comments