Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazelisk is pulling a non existing release ( 3.5.1 ) when invoked w/o .bazelversion #170

Closed
jerrymarino opened this issue Sep 25, 2020 · 7 comments · Fixed by #172
Closed
Labels
type:bug Something isn't working

Comments

@jerrymarino
Copy link

jerrymarino commented Sep 25, 2020

Invoking bazelisk build is attempting to pull a non-existent release.

This afternoon, a handful of xchammer github jobs started failing that used bazelisk. For example:
https://github.com/pinterest/xchammer/pull/259/checks?check_run_id=1168118720

The xchammer CI runs bazelisk and we don't have a version specified in the repository. Without the version, it attempts to pull a non-existing URL:

2020/09/25 21:40:42 Downloading https://releases.bazel.build/3.5.1/release/bazel-3.5.1-darwin-x86_64...
2020/09/25 21:40:42 could not download Bazel: HTTP GET https://releases.bazel.build/3.5.1/release/bazel-3.5.1-darwin-x86_64 failed with error 404
make: *** [build-impl] Error 1
Error: Process completed with exit code 2.

I checked on Bazel releases this afternoon, and it looks like there is no 3.5.1 bazel release: https://github.com/bazelbuild/bazel/releases

@philwo
Copy link
Member

philwo commented Sep 25, 2020

@fweikert Any idea what causes this? Is this related to your work where we fetch the Version info from GCS instead of GitHub?

Maybe the code doesn’t recognize that 3.5.1 isn’t a released version yet and only has an rc1?

@philwo
Copy link
Member

philwo commented Sep 25, 2020

@jerrymarino I’m so sorry for this :( I’m not sure yet what causes this, whether it’s an issue with Bazelisk or something weird about the Bazel 3.5.1rc1 release, but will look into it tomorrow.

@junyer
Copy link

junyer commented Sep 27, 2020

RE2 is also seeing this for macOS builds with GitHub Actions. We weren't actually intending to use Bazelisk, so I'm guessing that the GitHub-hosted runners have bazel pointing to Bazelisk? Is there a flag or an environment variable that can be passed that will prevent Bazelisk from doing anything? As opposed to configuring a version, I mean.

P.S. Hi, @philwo!

@philwo
Copy link
Member

philwo commented Sep 27, 2020

I found the reason for this. Bazelisk has two methods to find out what the latest Bazel is:

  1. Query the available Bazel releases in our repo via the GitHub API
  2. Infer it from the versions available on our Google Cloud Storage release download bucket

Bazelisk uses GitHub API by default, but falls back to GCS, if that doens't work for some reason. Unfortunately the GCS strategy has a bug - it sees a 3.5.1 folder on GCS and assumes that's the latest version, without verifying that this is already a final release. But as the 3.5.1 folder only contains the rc1 version, the download then fails.

While we fix this, you have two workarounds for this:

  1. Add a .bazelversion file to your repo, then Bazelisk will use that version and not query for the latest one. This is a good idea in general, because you can then test Bazel version upgrades simply by bumping the version in that file and upgrade at your own pace, instead of having your build break when Bazel releases an incompatible version.
  2. Alternatively, you'd have to ensure that Bazelisk can successfully query GitHub's API for the version information. This usually works fine, but on GitHub Actions you'll often run into rate-limiting (HTTP error 403 for the API request) as the CI workers all share common IPs. To fix this, you'll have to pass GitHub Action's API Token to Bazelisk via the environment variable BAZELISK_GITHUB_TOKEN.

Reference for how that works:

How I think this should work (for re2): google/re2#282

Sorry for the problems 😞

@philwo philwo added the type:bug Something isn't working label Sep 27, 2020
@junyer
Copy link

junyer commented Sep 27, 2020

Confirmed that setting BAZELISK_GITHUB_TOKEN mitigates the problem. Many thanks, @philwo! :D

@philwo
Copy link
Member

philwo commented Sep 27, 2020

@junyer Yay! Thanks for reporting back (and nice to see you around here 😊)

gjasny added a commit to jupp0r/prometheus-cpp that referenced this issue Sep 27, 2020
bazelisk has a bug when retrieving the bazle version from
GCS due to github rate limiting. See
bazelbuild/bazelisk#170

Until we export our GITHUB_TOKEN or bazelisk is fixed
we pin the bazel version to 3.5.0 (to avoid unreleased 3.5.1).
fweikert added a commit that referenced this issue Sep 27, 2020
If `latest-n` was requested, Bazelisk previously only examined the most recent version to see whether it had a release (and not just candidates).
If there was no release, Bazelisk simply returned the second-to-last without checking whether that version had a release, too.

Now Bazelisk checks the latest versions until it finds one with a release.

Fixes #170
Progress towards #171
@fweikert
Copy link
Member

This is what happened:

Bazelisk saw that the latest version was 3.6.0, but without a release -> it returned the second most recent version, 3.5.1, without actually checking whether that version had a release either. Since there was no 3.5.1 release you got a 404. I'll send a fix.

fweikert added a commit that referenced this issue Oct 1, 2020
If `latest-n` was requested, Bazelisk previously only examined the most recent version to see whether it had a release (and not just candidates).
If there was no release, Bazelisk simply returned the second-to-last without checking whether that version had a release, too.

Now Bazelisk checks the latest versions until it finds one with a release.

Fixes #170
Progress towards #171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants