Skip to content

Commit

Permalink
Print embedded label / version when starting Bazel.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 697623665
Change-Id: I5553240373da5cccb405aba7524b3930fcd961c2
  • Loading branch information
meisterT authored and copybara-github committed Nov 18, 2024
1 parent 938a010 commit 56329b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/main/cpp/blaze.cc
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ static void StartServerAndConnect(
const blaze_util::Path &server_dir, const WorkspaceLayout &workspace_layout,
const string &workspace, const OptionProcessor &option_processor,
const StartupOptions &startup_options, LoggingInfo *logging_info,
BlazeServer *server) {
BlazeServer *server, const string &build_label) {
// Delete the old command_port file if it already exists. Otherwise we might
// run into the race condition that we read the old command_port file before
// the new server has written the new file and we try to connect to the old
Expand Down Expand Up @@ -855,7 +855,8 @@ static void StartServerAndConnect(
startup_options.io_nice_level);

BAZEL_LOG(USER) << "Starting local " << startup_options.product_name
<< " server and connecting to it...";
<< " server (" << build_label << ")"
<< " and connecting to it...";
BlazeServerStartup *server_startup;
const int server_pid = ExecuteDaemon(
server_exe, server_exe_args, PrepareEnvironmentForJvm(),
Expand Down Expand Up @@ -1051,12 +1052,13 @@ static ATTRIBUTE_NORETURN void RunClientServerMode(
const string &workspace, const OptionProcessor &option_processor,
const StartupOptions &startup_options, LoggingInfo *logging_info,
const DurationMillis extract_data_duration,
const DurationMillis command_wait_duration_ms, BlazeServer *server) {
const DurationMillis command_wait_duration_ms, BlazeServer *server,
const string &build_label) {
while (true) {
if (!server->Connected()) {
StartServerAndConnect(server_exe, server_exe_args, server_dir,
workspace_layout, workspace, option_processor,
startup_options, logging_info, server);
startup_options, logging_info, server, build_label);
}

// Check for the case when the workspace directory deleted and then gets
Expand Down Expand Up @@ -1462,10 +1464,12 @@ static void RunLauncher(const string &self_path,
option_processor, startup_options, logging_info,
extract_data_duration, command_wait_duration_ms, blaze_server);
} else {
string build_label;
ExtractBuildLabel(self_path, &build_label);
RunClientServerMode(server_exe, server_exe_args, server_dir,
workspace_layout, workspace, option_processor,
startup_options, logging_info, extract_data_duration,
command_wait_duration_ms, blaze_server);
command_wait_duration_ms, blaze_server, build_label);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/shell/integration/bazel_command_log_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function strip_lines_from_bazel_cc() {
-e "/^INFO: Reading 'startup' options from /d" \
-e '/^\$TEST_TMPDIR defined: output root default is/d' \
-e '/^OpenJDK 64-Bit Server VM warning: ignoring option UseSeparateVSpacesInYoungGen; support was removed in 8.0/d' \
-e '/^Starting local B[azel]* server and connecting to it\.\.\.\.*$/d' \
-e '/^Starting local B[azel]* server (.*) and connecting to it\.\.\.\.*$/d' \
-e '/^\.\.\. still trying to connect to local B[azel]* server ([1-9][0-9]*) after [1-9][0-9]* seconds \.\.\.\.*$/d' \
-e '/^Killed non-responsive server process/d' \
-e '/server needs to be killed, because the startup options are different/d' \
Expand Down
12 changes: 6 additions & 6 deletions src/test/shell/integration/client_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ function test_shutdown() {
local server_pid2=$(bazel info server_pid 2>$TEST_log)
assert_not_equals "$server_pid1" "$server_pid2"
expect_not_log "WARNING.* Running B\\(azel\\|laze\\) server needs to be killed"
expect_log "Starting local B\\(azel\\|laze\\) server and connecting to it"
expect_log "Starting local B\\(azel\\|laze\\) server (.*) and connecting to it"
}

function test_shutdown_different_options() {
bazel --host_jvm_args=-Di.am.a=teapot info >& $TEST_log || fail "Expected success"
bazel shutdown >& $TEST_log || fail "Expected success"
expect_log "WARNING.* Running B\\(azel\\|laze\\) server needs to be killed"
expect_not_log "Starting local B\\(azel\\|laze\\) server and connecting to it"
expect_not_log "Starting local B\\(azel\\|laze\\) server (.*) and connecting to it"
}

function test_server_restart_due_to_startup_options_with_client_debug_information() {
Expand Down Expand Up @@ -246,7 +246,7 @@ function test_local_startup_timeout() {
sleep 1
done

expect_log "Starting local.*server and connecting to it"
expect_log "Starting local.*server (.*) and connecting to it"
expect_log "FATAL: couldn't connect to server"
}

Expand All @@ -269,7 +269,7 @@ function test_max_idle_secs() {
done

bazel "${options[@]}" info >"$TEST_log" 2>&1 || fail "bazel info failed"
expect_log "Starting local.*server and connecting to it"
expect_log "Starting local.*server (.*) and connecting to it"
# Ensure the restart was not triggered by different startup options.
expect_not_log "WARNING: Running B\\(azel\\|laze\\) server needs to be killed"
}
Expand Down Expand Up @@ -391,7 +391,7 @@ function test_proxy_settings() {
"${TEST_TMPDIR}/server_env"
done
else
echo "Cannot not test server process environment on this platform"
echo "cannot test server process environment on this platform"
fi
}

Expand Down Expand Up @@ -442,7 +442,7 @@ function test_client_is_quiet_by_default() {
lines=$(cat $TEST_log | wc -l)
[[ $lines -ge 2 && $lines -le 3 ]] || fail "Log has incorrect number of lines"
expect_log "^\$TEST_TMPDIR defined: output root default"
expect_log "^Starting local $capitalized_product_name server and connecting to it...$"
expect_log "^Starting local $capitalized_product_name server (.*) and connecting to it...$"
cp stdout $TEST_log || fail "cp failed"

strip_lines_from_bazel_cc
Expand Down

1 comment on commit 56329b9

@meisterT
Copy link
Member Author

Choose a reason for hiding this comment

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

@bazel-io flag

Please sign in to comment.