Skip to content

Commit

Permalink
Throw a different Exception when failing to download Bazel at a given…
Browse files Browse the repository at this point in the history
… commit (#1507)

Related
bazelbuild/bazel#16933 (comment)

BuildKiteException is always caught at

https://github.com/bazelbuild/continuous-integration/blob/4592271b2fdcf26f865d9c0082e1e53add7ea9a2/buildkite/bazelci.py#L3592-L3594

- The "Publish Bazel binaries" pipeline sometimes fails to publish Bazel
binaries for a commit, in this case, the Culprit Finder should
immediately fail instead consider the commit as a bad Bazel commit due
to failing build.

- Also removed some unused parameters in the function.
  • Loading branch information
meteorcloudy authored Dec 9, 2022
1 parent 1d56b5a commit d433d4f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions buildkite/bazelci.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,14 @@ class BuildkiteException(Exception):
pass


class BuildkiteInfraException(Exception):
"""
Raised whenever something goes wrong with the CI infra and we should immediately exit with an error.
"""

pass


class BinaryUploadRaceException(Exception):
"""
Raised when try_publish_binaries wasn't able to publish a set of binaries,
Expand Down Expand Up @@ -1604,13 +1612,11 @@ def download_bazel_nojdk_binary(dest_dir, platform):
return download_binary(dest_dir, platform, binary_name)


def download_binary_at_commit(
dest_dir, platform, bazel_git_commit, bazel_binary_url, bazel_binary_path
):
def download_binary_at_commit(bazel_git_commit, bazel_binary_url, bazel_binary_path):
try:
execute_command([gsutil_command(), "cp", bazel_binary_url, bazel_binary_path])
except subprocess.CalledProcessError as e:
raise BuildkiteException(
raise BuildkiteInfraException(
"Failed to download Bazel binary at %s, error message:\n%s" % (bazel_git_commit, str(e))
)
st = os.stat(bazel_binary_path)
Expand All @@ -1621,13 +1627,13 @@ def download_binary_at_commit(
def download_bazel_binary_at_commit(dest_dir, platform, bazel_git_commit):
url = bazelci_builds_gs_url(platform, bazel_git_commit)
path = os.path.join(dest_dir, "bazel.exe" if platform == "windows" else "bazel")
return download_binary_at_commit(dest_dir, platform, bazel_git_commit, url, path)
return download_binary_at_commit(bazel_git_commit, url, path)


def download_bazel_nojdk_binary_at_commit(dest_dir, platform, bazel_git_commit):
url = bazelci_builds_nojdk_gs_url(platform, bazel_git_commit)
path = os.path.join(dest_dir, "bazel_nojdk.exe" if platform == "windows" else "bazel_nojdk")
return download_binary_at_commit(dest_dir, platform, bazel_git_commit, url, path)
return download_binary_at_commit(bazel_git_commit, url, path)


def download_bazelci_agent(dest_dir, version):
Expand Down

0 comments on commit d433d4f

Please sign in to comment.