Skip to content

Add an option for printing selected server logs on failure.#6591

Closed
EdSchouten wants to merge 2 commits intobazelbuild:masterfrom
EdSchouten:print-server-log-on-failure
Closed

Add an option for printing selected server logs on failure.#6591
EdSchouten wants to merge 2 commits intobazelbuild:masterfrom
EdSchouten:print-server-log-on-failure

Conversation

@EdSchouten
Copy link
Copy Markdown
Contributor

Bazel Buildbarn recently gained a web frontend called bbb_browser that
can be used to explore the CAS/AC. It allows users to get better insight
in how remote execution works under the hood. It also makes it possible
for users to more easily share information on build failures with their
peers.

In order to make it easy for people to access this service, we'd like
build failures to automatically print links to the corresponding page in
bbb_browser to the terminal. RE's server_logs feature is ideally suited
for this. Unfortunately, there exists no mechanism to print the output
of these files to the terminal yet.

This change adds a new command line flag, --print_server_log_on_failure,
that can print selected server logs to the terminal automatically. Logs
are identified by the key that was used to store them in the map.

@EdSchouten
Copy link
Copy Markdown
Contributor Author

Obligatory screenshot. Notice the "Build failure details" line, which was stored in a server log.

screenshot_2018-11-04_10-53-21

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Nov 5, 2018

Hi Ed,

have you considered implementing a BES service in Buildbarn? I think that might be a more idiomatic way to do what you want to do. We also have the --build_results_url= flag in Bazel to display a URL where a user can look up details.

See e.g. https://source.cloud.google.com/results/invocations/48d7938b-2f43-4585-b51d-19fd7113c776/targets and
https://docs.bazel.build/versions/master/build-event-protocol.html

@EdSchouten
Copy link
Copy Markdown
Contributor Author

EdSchouten commented Nov 5, 2018

Hi Jakob. Hope you're doing well! \o/

The Build Event Service looks pretty neat as well, but I think it fulfills a different purpose. The BES acts as a high-level logging system for full Bazel build/test runs (the 'top half' of Bazel). The page I built is intended for inspecting the literal data structures used by remote execution (the 'bottom half' of Bazel). It can, for example, be used to browse the input root of a build action stored in the CAS. This is quite valuable when diagnosing issues in the remote build implementation or self-made build rules.

For those who are curious, below is a screenshot of bbb_browser showing information about a failed build action:

screencapture-buildbarn-browser-dev-prodrive-technologies-actionfailure-debian8-439c4273c478a1892524bbbd60c11c91c27c40c5556d7a5e536612a92a542351-273-2018-11-05-14_34_43

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Nov 5, 2018

Thanks for explaining. You are indeed correct. This looks great!

I have two questions:

  • How would this look like with multiple failing targets?
  • Wouldn't ExecuteResponse.status.message be a better fit than putting this into a server log file? I would be more comfortable with unconditionally printing the message for failed executions than printing a server log.

@EdSchouten
Copy link
Copy Markdown
Contributor Author

Below is a screenshot of what this looks like for a couple of errors in a row. Notice that they are all printed right above the corresponding ERROR statements.

screenshot_2018-11-05_15-55-34

With regards to using ExecuteResponse.status.message: in case of simple build failures (i.e., the builder as a whole functioned properly, but it's just that we saw a non-zero exit code), ExecuteResponse.status is intended to be nil/OK, right? That likely means that there's no room for returning any info.

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Nov 5, 2018

You are right with regard to status - I always mix this up :-).

We can do this. I am not convinced that using server_log is the right approach in the long term but it's an acceptable solution for now:

  • This seems like a feature all remote execution systems will want to have eventually. So this should just work by default without having to specify a flag and agreeing on a log name.
  • INFO events are expected to be short (ideally < 80 characters) and thus a generic mechanism to dump a log file content as an INFO event doesn't seem ideal.

I think a better approach would be to add an additional_info_url field to the ExecuteResponse message. What do you think? Would you mind opening an issue for discussion here: https://github.com/bazelbuild/remote-apis?

EdSchouten pushed a commit to EdSchouten/remote-apis that referenced this pull request Nov 5, 2018
As mentioned in bazelbuild/bazel#6591, Bazel
Buildbarn now ships with a web service that can be used to explore data
stored in the CAS and AC.

By adding an extra field to ExecuteResponse, we can let Bazel
automatically report URLs to the user pointing to the correct page.
These URLs could, for example, be printed for build steps that fail.
@EdSchouten
Copy link
Copy Markdown
Contributor Author

Having an additional_info_url as part of the protocol would be a very good idea:

  • As Bazel only downloads server logs upon failure, this patch doesn't allow me to get the URL for actions that do build properly.
  • It reduces the amount of stuff that needs to be written in the CAS.

I just opened this pull request: bazelbuild/remote-apis#36. Let's close this one and continue discussion there. Thanks!

@EdSchouten EdSchouten closed this Nov 5, 2018
Copy link
Copy Markdown
Contributor

@buchgr buchgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would make sense to simply append this information to the stderr instead of posting it as an info event. That has the additional advantage of this information being printed after the error message, which seems nicer to me.

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Nov 5, 2018

@EdSchouten I wasn't suggesting for you to close this one. I think we could certainly merge this as-is and iterate.

@EdSchouten EdSchouten reopened this Nov 5, 2018
@EdSchouten EdSchouten force-pushed the print-server-log-on-failure branch 2 times, most recently from fd0698e to 915fdfd Compare November 5, 2018 20:03
@EdSchouten EdSchouten force-pushed the print-server-log-on-failure branch 2 times, most recently from b9bdc82 to 249aace Compare November 23, 2018 13:58
@EdSchouten
Copy link
Copy Markdown
Contributor Author

Hi Jakob,

I've just altered this pull request to no longer use server logs. Instead, it now uses the ExecuteResponse's message field. The change is equivalent featurewise; it prints the information upon build failures.

That said, it would also be interesting to show this information for successful targets when not too noisy. Being able to obtains links to those would allow people to share build output (e.g., firmware images) with each other.

I was thinking that BuildResultPrinter's showBuildResult() would be the right spot for printing that. The only thing that isn't clear to me is how I can get that information to trickle all the way up to the BuildResultPrinter. Do you have any idea what would be the cleanest way to realise that?

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Nov 23, 2018

That said, it would also be interesting to show this information for successful targets when not too noisy. Being able to obtains links to those would allow people to share build output (e.g., firmware images) with each other.

I think this is the classic BEP/BES use case and best implemented there. The BEP will reference all outputs of top level targets and Bazel can upload this information via the BES protocol and also print a link (--bes_results_url) to a user readable page. The BEP can reference output files as a link to the CAS of the remote execution system. So I think that would be perfect for what you want to do.

String message = reply.getMessage();
if ((reply.getResult().getExitCode() != 0 ||
reply.getStatus().getCode() != Code.OK.value()) && !message.isEmpty()) {
outErr.printErr(message + "\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify:

  • For build failures Bazel will print this to the UI
  • For test failures this will be the last line in the test.log

Correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. It's printed in those two conditions.

@buchgr
Copy link
Copy Markdown
Contributor

buchgr commented Dec 13, 2018

Ping @EdSchouten :-)

Ed Schouten added 2 commits December 23, 2018 15:23
This includes the new ExecuteResponse's message field that is dedicated
to containing log entries that may be printed to the user.
The message may contain additional information that the user may use to
diagnose failures. Bazel Buildbarn will emit messages containing links
to its web frontend that can be used to inspect actions (command, input
root, etc.) in more detail.
@EdSchouten EdSchouten force-pushed the print-server-log-on-failure branch from 249aace to b5afa24 Compare December 23, 2018 14:24
@EdSchouten
Copy link
Copy Markdown
Contributor Author

Ping @EdSchouten :-)

Pong! Sorry for letting you folks wait.

@jin jin added team-Remote-Exec Issues and PRs for the Execution (Remote) team and removed team-Execution labels Jan 14, 2019
buchgr pushed a commit to buchgr/bazel that referenced this pull request Jan 24, 2019
…uild#6591

Bazel Buildbarn recently gained a web frontend called bbb_browser that
can be used to explore the CAS/AC. It allows users to get better insight
in how remote execution works under the hood. It also makes it possible
for users to more easily share information on build failures with their
peers.

In order to make it easy for people to access this service, we'd like
build failures to automatically print links to the corresponding page in
bbb_browser to the terminal. We want to use the remote execution APIs
message field for that.
@bazel-io bazel-io closed this in e213269 Jan 24, 2019
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this pull request Jan 31, 2019
…uild#6591

Bazel Buildbarn recently gained a web frontend called bbb_browser that
can be used to explore the CAS/AC. It allows users to get better insight
in how remote execution works under the hood. It also makes it possible
for users to more easily share information on build failures with their
peers.

In order to make it easy for people to access this service, we'd like
build failures to automatically print links to the corresponding page in
bbb_browser to the terminal. We want to use the remote execution APIs
message field for that.

Closes bazelbuild#7234.

PiperOrigin-RevId: 230695190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes team-Remote-Exec Issues and PRs for the Execution (Remote) team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants