Commit 4be1b74a authored by Wez Furlong's avatar Wez Furlong Committed by Facebook Github Bot

getdeps: introduce TransientFailure exception type

Summary:
The goal is to return an error code > 127 in the case of a
transient, retryable, infrastructure error.  This diff generates
those in the case of failure in downloading a URL or from interacting
with LFS.

Reviewed By: strager

Differential Revision: D15266838

fbshipit-source-id: 4f52a791320123968869032c37912dded464a86e
parent ccb63d10
...@@ -16,6 +16,7 @@ import subprocess ...@@ -16,6 +16,7 @@ import subprocess
import sys import sys
from getdeps.buildopts import setup_build_options from getdeps.buildopts import setup_build_options
from getdeps.errors import TransientFailure
from getdeps.load import load_project, manifests_in_dependency_order from getdeps.load import load_project, manifests_in_dependency_order
from getdeps.manifest import ManifestParser from getdeps.manifest import ManifestParser
from getdeps.platform import HostType, context_from_host_tuple from getdeps.platform import HostType, context_from_host_tuple
...@@ -407,7 +408,14 @@ def main(): ...@@ -407,7 +408,14 @@ def main():
return 0 return 0
try: try:
return args.func(args) return args.func(args)
except subprocess.CalledProcessError: except TransientFailure as exc:
print("TransientFailure: %s" % str(exc))
# This return code is treated as a retryable transient infrastructure
# error by Facebook's internal CI, rather than eg: a build or code
# related error that needs to be fixed before progress can be made.
return 128
except subprocess.CalledProcessError as exc:
print("%s" % str(exc), file=sys.stderr)
print("!! Failed", file=sys.stderr) print("!! Failed", file=sys.stderr)
return 1 return 1
......
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
from __future__ import absolute_import, division, print_function, unicode_literals
class TransientFailure(Exception):
""" Raising this error causes getdeps to return with an error code
that Sandcastle will consider to be a retryable transient
infrastructure error """
pass
...@@ -21,6 +21,7 @@ import zipfile ...@@ -21,6 +21,7 @@ import zipfile
from .copytree import prefetch_dir_if_eden from .copytree import prefetch_dir_if_eden
from .envfuncs import Env from .envfuncs import Env
from .errors import TransientFailure
from .platform import is_windows from .platform import is_windows
from .runcmd import run_cmd from .runcmd import run_cmd
...@@ -548,7 +549,13 @@ def download_url_to_file_with_progress(url, file_name): ...@@ -548,7 +549,13 @@ def download_url_to_file_with_progress(url, file_name):
progress = Progress() progress = Progress()
start = time.time() start = time.time()
(_filename, headers) = urlretrieve(url, file_name, reporthook=progress.progress) try:
(_filename, headers) = urlretrieve(url, file_name, reporthook=progress.progress)
except OSError as exc:
raise TransientFailure(
"Failed to download %s to %s: %s" % (url, file_name, str(exc))
)
end = time.time() end = time.time()
sys.stdout.write(" [Complete in %f seconds]\n" % (end - start)) sys.stdout.write(" [Complete in %f seconds]\n" % (end - start))
sys.stdout.flush() sys.stdout.flush()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment