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

local actions, tmpdir: implement --local_tmp_root flag #4621

Closed
laszlocsomor opened this issue Feb 12, 2018 · 10 comments
Closed

local actions, tmpdir: implement --local_tmp_root flag #4621

laszlocsomor opened this issue Feb 12, 2018 · 10 comments
Assignees

Comments

@laszlocsomor
Copy link
Contributor

Description of the problem / feature request:

Add a --local_tmp_root flag to Bazel that lets the user specify a temp directory for locally executed actions. This compliments the feature implemented for #3215 where Bazel picks up the client environment's TMPDIR envvar.

Feature requests: what underlying problem are you trying to solve with this feature?

Allow users to put this flag in project-specific bazelrc files, so users won't have to update their bashrc/bash_profile.

The former approach's benefits are that the information is local to a code base, and it has local effect (as opposed to the bashrc approach).

See also #3215 (comment)

What operating system are you running Bazel on?

All supported ones.

@ittaiz
Copy link
Member

ittaiz commented Feb 12, 2018 via email

@ittaiz
Copy link
Member

ittaiz commented Feb 16, 2018

@laszlocsomor I just tried running a test using bazel built from HEAD (I verified the change is in) when I ran it with --local_tmp_root=/tmp --strategy=TestRunner=standalone and I still get:

java.lang.RuntimeException: java.io.IOException: java.lang.RuntimeException: mysql start failed with error: [ERROR] The socket file path is too long (> 103): /private/var/tmp/_bazel_ittaiz/1c8ed8d84f6cb79483aa3cc4da758c86/execroot/foo/_tmp/d26550dc5bfd5572403cbf71f40d4422/2819823247725996448.sock

Am I doing something wrong?
If I add in the relevant BUILD file:

    jvm_flags = [
        "-Djava.io.tmpdir=/tmp",
    ],

The test passes

@laszlocsomor
Copy link
Contributor Author

@ittaiz : You're right. I'm looking into this issue. Sorry this this feature is still broken.

@laszlocsomor laszlocsomor reopened this Feb 16, 2018
@laszlocsomor
Copy link
Contributor Author

laszlocsomor commented Feb 16, 2018

Found the culprit:

val = val.replace(TEST_TMP_DIR, tmpDirPath);

This sets $TEST_TMPDIR's value to be under a subdirectory of the test temp root, not under the local temp root. See below for more info.

Observations:

  • I just found out that there's already a --test_tmpdir flag. However while --local_tmp_root affects all local actions, --test_tmpdir only affects local tests.
  • Sadly, both flags are named misleadingly. (We can still easily change that for --local_tmp_root though.)
    • The new --local_tmp_root defines a directory (not a root), that all actions should use as $TMPDIR.
    • The existing --test_tmpdir defines a root (not a directory), that Bazel creates a unique subdirectory in for each test, and sets that as $TEST_TMPDIR. The java_binary/java_test runner stub then picks this up and sets -Djava.io.tmpdir to its value:

TODO for me:

  • update the TestPolicy to also consider --local_tmp_root (though IMO --test_tmpdir should have priority over it for tests)
  • rename --local_tmp_root to --local_tmpdir
  • opt: add a --test_tmproot flag, make it an alias of --test_tmpdir
  • opt: make --test_tmpdir deprecated (may require internal depot cleanup)

@laszlocsomor
Copy link
Contributor Author

@ittaiz : For now, maybe --test_tmpdir=/tmp would suffice? The effective temp directory will be something like /tmp/_tmp/3e07cf3aab431e611679f7f0415dffba, which is 42 characters long.

@laszlocsomor
Copy link
Contributor Author

Also, let me roll back 04757db for now so I'm (a) not under time pressure to fix it, and (b) can discuss with the team whether adding another flag for local temp directory control, when we already have --test_tmpdir, is actually a good idea. (I wasn't aware of this flag until now.)

@ittaiz
Copy link
Member

ittaiz commented Feb 20, 2018

@laszlocsomor sorry for the late reply but wanted to test test_tmpdir on multiple scenarios and it's indeed very helpful. Thanks!

@ittaiz
Copy link
Member

ittaiz commented Feb 20, 2018

btw, my 2c is that if we have test_tmpdir it's indeed really unclear if we need another flag. I'd wait for more use-cases.
I would however consider renaming it since it's misleading as you pointed out...

@laszlocsomor
Copy link
Contributor Author

@ittaiz No worries, and cool, that's good to hear! And yes, agreed on the naming and unclear necessity too.

@laszlocsomor
Copy link
Contributor Author

I'm closing this because we already have --test_tmpdir and that seems to work. @ittaiz please let me know if that's not the case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants