Quiet down stateful_update & add timeout for downloads.
Keeps the progress bar noise out of the autotest logs, and makes it easier to discover failures. Also caps the total time to 5 minutes.
Review URL: http://codereview.chromium.org/2392002
diff --git a/autoupdate.py b/autoupdate.py
index c541f6a..93d6b0d 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -20,6 +20,7 @@
*args, **kwargs):
super(Autoupdate, self).__init__(*args, **kwargs)
self.serve_only = serve_only
+ self.factory_config = factory_config_path
self.test_image = test_image
self.static_urlbase = urlbase
if serve_only:
@@ -28,13 +29,12 @@
# link to the build archive.
web.debug('Autoupdate in "serve update images only" mode.')
if os.path.exists('static/archive'):
- archive_symlink = os.readlink('static/archive')
- if archive_symlink != self.static_dir:
+ if self.static_dir != os.readlink('static/archive'):
web.debug('removing stale symlink to %s' % self.static_dir)
os.unlink('static/archive')
+ os.symlink(self.static_dir, 'static/archive')
else:
- os.symlink(self.static_dir, 'static/archive')
- self.factory_config = None
+ os.symlink(self.static_dir, 'static/archive')
if factory_config_path is not None:
self.ImportFactoryConfigFile(factory_config_path, validate_factory_config)
@@ -107,7 +107,11 @@
if os.path.exists(image):
return True
else:
- return os.system('cd %s && unzip -o image.zip %s unpack_partitions.sh' %
+ # -n, never clobber an existing file, in case we get invoked
+ # simultaneously by multiple request handlers. This means that
+ # we're assuming each image.zip file lives in a versioned
+ # directory (a la Buildbot).
+ return os.system('cd %s && unzip -n image.zip %s unpack_partitions.sh' %
(image_path, image_file)) == 0
def GetImageBinPath(self, image_path):
diff --git a/stateful_update b/stateful_update
index 5ed2345..b73d796 100755
--- a/stateful_update
+++ b/stateful_update
@@ -35,7 +35,9 @@
# Unzip mount and copy the relevant directories.
# Get the update.
-eval "wget -O - \"$STATEFUL_UPDATE_URL\"" | gzip -d > $STATEFUL_IMAGE
+eval "wget -qS -T 300 -O - \"$STATEFUL_UPDATE_URL\"" | \
+ gzip -d > $STATEFUL_IMAGE
+echo "Successfully downloaded update"
trap "rm -f \"$STATEFUL_IMAGE\"" EXIT
mount -n -o loop "$STATEFUL_IMAGE" "$STATEFUL_MOUNT_POINT"
if [ -d "$STATEFUL_MOUNT_POINT/var" ] && \