bazel-contrib / bazel-gazelle

Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.2k stars 380 forks source link

Make go_repository timeout configurable #1144

Open sluongng opened 2 years ago

sluongng commented 2 years ago

What version of gazelle are you using?

latest

What version of rules_go are you using?

latest

What version of Bazel are you using?

4.2.1

Does this issue reproduce with the latest releases of all the above?

Yes

What operating system and processor architecture are you using?

MacOS ARM64

What did you do?

bazel fetch //...
# wait a long time
# timeout error

What did you expect to see?

In special CI environment where dependencies are cached in GOPROXY, slow network connection is a sign of failure. Having a high timeout value does not allow CI worker to fail fast.

In a high traffic monorepo CI pipeline, this translates to CI worker spending more time waiting for bazel action to timeout. Thus the pipelines take longer to complete and job get queued up, leading to worker starvation.

Being able to configure custom timeout on go_repository targets would be an ideal solution

What did you see instead?

Timeout is hard coded right now in go_repository starlark rule https://github.com/bazelbuild/bazel-gazelle/blob/6ce3318b09d545b0f4fb689e715a5fdb237abf26/internal/go_repository.bzl

There are workarounds which is either:

robfig commented 2 years ago

Maybe it could be part of the toolchain configuration?


go_register_toolchains(
  go_version = "1.17.6",
  repository_timeout = 30,
)