From 15745d520eebc4befc60b410c9e6b0fc6337b269 Mon Sep 17 00:00:00 2001 From: Andrew Jeddeloh Date: Mon, 16 Dec 2019 23:08:33 +0000 Subject: [PATCH] disk_util: retry loopback mounts if they fail This fails frequently but should succeed if retried. This should reduce failed builds. --- build_library/disk_util | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/build_library/disk_util b/build_library/disk_util index f45e03125c..4174d66911 100755 --- a/build_library/disk_util +++ b/build_library/disk_util @@ -598,9 +598,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.