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

Configuring the TEST_TMPDIR global variable changes the max_idle_secs bazel server parameter #11062

Closed
P1ng-W1n opened this issue Apr 3, 2020 · 5 comments
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@P1ng-W1n
Copy link

P1ng-W1n commented Apr 3, 2020

Description of the problem / feature request:

According to the https://docs.bazel.build/versions/master/output_directories.html#current-layout, the TEST_TMPDIR global variable can be used to override the default outputRoot directory.
However, it seems that setting that variable also has an unintended side affect, as it changes the max_idle_secs bazel server parameter as well
Is that the expected behavior? If so, is it documented anywhere?

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Start an empty container (docker run --rm -it ubuntu:bionic bash)
  2. Download latest bazel binary (wget https://github.com/bazelbuild/bazel/releases/download/2.2.0/bazel-2.2.0-linux-x86_64)
  3. Create a new empty folder and go into there (mkdir /tmp/test ; cd /tmp/test)
  4. Create an empty workspace file in there (touch /tmp/test/WORKSPACE)
  5. Execute the 'bazel version' command
  6. Check the 'ps -ef |grep bazel' output. //The bazel server should have the default --max_idle_secs=10800 configured
  7. Kill the running bazel server
  8. Export the TEST_TMPDIR variable (export TEST_TMPDIR=/tmp/)
  9. Repeat step Steps towards getting Bazel compiling on Darwin #5 and Add genzip proto #6. // You shall see that the --max_idle_secs has changed to 15

What operating system are you running Bazel on?

Linux (can be reproduced under Ubuntu and Fedora as well(

What's the output of bazel info release?

release 2.2.0

Have you found anything relevant by searching the web?

Seems that this behavior has been introduced as part of the d5f0ecb commit.

Any other information, logs, or outputs that you want to share?

https://pastebin.com/BzQ1WjFk

@dslomov dslomov added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged labels Apr 3, 2020
@avisegradi
Copy link

avisegradi commented Apr 3, 2020

In case it helps, the override comes from this file: src/main/cpp/blaze_startup_options_common.cc

The timeout was introduced in this commit (Update from Google.): d08b27f

And increased to 15 secs here (Increase the server timeout for tests so that we don't get spurious failures on busy machines.): 28764a3

And made more apparent here: d5f0ecb

@benjaminp
Copy link
Collaborator

I don't think any behavior based on TEST_TMPDIR is meant to be public. It's meant to change Bazel's behavior when it itself is under test.

@P1ng-W1n
Copy link
Author

P1ng-W1n commented Apr 6, 2020

I do get that this was the original intention, but while TEST_TMPDIR is somehow documented publicly, this behavior is not:
https://docs.bazel.build/versions/master/output_directories.html#current-layout
https://docs.bazel.build/versions/master/test-encyclopedia.html

To make this more interesting, the printout itself can also be incorrect (if max_idle_secs is defined), as it doesn't consider the actual value used by the server:

root@e3771f06e60a:/tmp/test# TEST_TMPDIR=/tmp/ /tmp/bazel-2.2.0-linux-x86_64 --max_idle_secs=0 version
$TEST_TMPDIR defined: output root default is '/tmp/' and max_idle_secs default is '15'.
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Build label: 2.2.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Mar 3 09:26:12 2020 (1583227572)
Build timestamp: 1583227572
Build timestamp as int: 1583227572

root@e3771f06e60a:/tmp/test# ps -ef |grep bazel
root      2609     1 99 08:25 ?        00:00:06 bazel(test) -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/_bazel_root/d1309ac1e2719cdf777c0d6e936fc92b --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED -Xverify:none -Djava.util.logging.config.file=/tmp/_bazel_root/d1309ac1e2719cdf777c0d6e936fc92b/javalog.properties -Dcom.google.devtools.build.lib.util.LogHandlerQuerier.class=com.google.devtools.build.lib.util.SimpleLogHandler$HandlerQuerier -XX:-MaxFDLimit -Djava.library.path=/tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1/embedded_tools/jdk/lib/jli:/tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1/embedded_tools/jdk/lib:/tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1/embedded_tools/jdk/lib/server:/tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1/ -Dfile.encoding=ISO-8859-1 -jar /tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1/A-server.jar --max_idle_secs=0 --shutdown_on_low_sys_mem=0 --connect_timeout_secs=30 --output_user_root=/tmp/_bazel_root --install_base=/tmp/_bazel_root/install/a968348e0a72afc534c7baff88ca46f1 --install_md5=a968348e0a72afc534c7baff88ca46f1 --output_base=/tmp/_bazel_root/d1309ac1e2719cdf777c0d6e936fc92b --workspace_directory=/tmp/test --default_system_javabase= --deep_execroot --expand_configs_in_place --idle_server_tasks --noexperimental_oom_more_eagerly --experimental_oom_more_eagerly_threshold=100 --write_command_log --nowatchfs --nofatal_event_bus_exceptions --client_debug=false --product_name=Bazel --noincompatible_enable_execution_transition --option_sources=max_Uidle_Usecs:
root      2642     1  0 08:25 pts/0    00:00:00 grep --color=auto bazel

@philwo
Copy link
Member

philwo commented Dec 8, 2020

The environment variable is documented as an internal-use only behavior: "If the environment variable $TEST_TMPDIR is set, as in a test of bazel itself, then that value overrides the default."

It's not meant to be set by users. The test encyclopedia talks about the world as seen from the viewpoint of a test, not about how you can tweak it - for example, even if you set TEST_TMPDIR to some value, Bazel will override this anyway when it runs tests.

If you want to change the TEST_TMPDIR that Bazel uses, you have to use the --test_tmpdir= flag: https://docs.bazel.build/versions/master/command-line-reference.html#flag--test_tmpdir

@ling2yt
Copy link

ling2yt commented Apr 18, 2022

The environment variable is documented as an internal-use only behavior: "If the environment variable $TEST_TMPDIR is set, as in a test of bazel itself, then that value overrides the default."

It's not meant to be set by users. The test encyclopedia talks about the world as seen from the viewpoint of a test, not about how you can tweak it - for example, even if you set TEST_TMPDIR to some value, Bazel will override this anyway when it runs tests.

If you want to change the TEST_TMPDIR that Bazel uses, you have to use the --test_tmpdir= flag: https://docs.bazel.build/versions/master/command-line-reference.html#flag--test_tmpdir

hi, I run into the same issue too. But I set this environment to specify the cache path, seems --test_tmpdir is not designed for this? Is it any other paraments can be used? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
Development

No branches or pull requests

6 participants