JetBrains / teamcity-bazel-plugin

TeamCity plugin for Bazel build system
Apache License 2.0
14 stars 6 forks source link

Bazel plugin consumes Bazel Event Service unconditionally. #7

Closed konste closed 4 years ago

konste commented 4 years ago

As far as I can tell Bazel plugin for TC subscribes to Bazel Event Service through --bes_backend. This is to keep track of the build progress and tests execution, as far as I understand. Unfortunately it prevents using of the other potential BES consumers, for instance https://github.com/buildbuddy-io/buildbuddy

Please think how BES can be used in a shared manner or at the very least there should be a way to prevent the plugin from stealing BES endpoint from what is configured through .bazelrc or the command line.

NikolayPianikov commented 4 years ago

@konste Yes you are right. TeamCity uses BES to have a structural build log, build status events and test results. We can add an internal property to avoid using BES but in this case the TeamCity integration will not work at all and as workaround you could just use the command line runner with the same effect.

Theoretically TeamCity could use --build_event_binary_file or --build_event_json_file to process events or it can provide some of transparent proxy to transfer all events for Bazel - TeamCity BES - BES. May be you are ready to investigate this thing? But in the last case we should constantly update all proto contracts and keep track of other exotic stuff from a version to version.

From other side why buildbuddy does not do this thing? Or why it does not use --build_event_binary_file or --build_event_json_file to get events?

konste commented 4 years ago

https://github.com/buildbuddy-io/buildbuddy is just one example. There also is https://build.bzl.io which we also want to use and I am sure more are coming. I could not find grpc splitter so far, but early or later something like that would emerge. At this time at the very least we need a flag for bazel plugin to prevent it from unconditionally stealing and reassigning BES endpoint to itself. Otherwise the only workaround is indeed to remove it.

NikolayPianikov commented 4 years ago

What is the reason to use bazel runner without TeamCity integration? Is it just for running command line? Or you wanted to switch off TeamCity integration for some steps only?

I think the only way is to use a special mode "getting events from file" for this case. I am going to deep into the content of these files, mentioned above and to estimate what should be done to switch to this new mode.

konste commented 4 years ago

-- What is the reason to use bazel runner without TeamCity integration?

You are right - not much reason,

Regarding events from file - are you even sure that --build_event_json_file still works when --bes_backend is specified? I don't know.

The most direct problem right now it that plugin intercepts --bes_backend unconditionally, regardless of what is (or maybe) configured in .bazelrc. Because of that we cannot for instance switch between plugin using BES and something else using BES for the different runs. As soon as we want to use something else, even occasionally, we have to give up on plugin and remove it, otherwise it gets in the way. If you are able to implement (optional) gRPC forwarding, then we can come out with something smarter, such as detect if BES is used and if it is, then intercept it, but then forward to the originally configured endpoint. That would be perfect.

NikolayPianikov commented 4 years ago

@konste please try SNAPSHOT-20200313120421