Merge pull request #891 from bgilbert/loopback-2303

disk_util: retry loopback mounts if they fail on 2303
This commit is contained in:
Benjamin Gilbert 2020-02-06 04:22:34 -05:00 committed by GitHub
commit 3af7d6d5d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -586,9 +586,22 @@ def Mount(options):
mount_opts.append('subvol=%s' % mount['fs_subvolume'])
Sudo(['mkdir', '-p', full_path])
Sudo(['mount', '-t', mount.get('fs_type', 'auto'),
'-o', ','.join(mount_opts),
options.disk_image, full_path])
# This tends to fail, retry if it does
err = None
for i in range(0,5):
try:
Sudo(['mount', '-t', mount.get('fs_type', 'auto'),
'-o', ','.join(mount_opts),
options.disk_image, full_path])
err = None
break
except subprocess.CalledProcessError as e:
print("Error mounting %s, attempt %d" % (full_path, i))
err = e
time.sleep(5)
if err is not None:
raise err
for src, dst in mount.get('binds', {}).iteritems():
# src may be relative or absolute, os.path.join handles this.