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

sandboxfs fails to mount _tmp for tests #7470

Closed
kornholi opened this issue Feb 19, 2019 · 13 comments
Closed

sandboxfs fails to mount _tmp for tests #7470

kornholi opened this issue Feb 19, 2019 · 13 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug
Milestone

Comments

@kornholi
Copy link

With the following repro:

$ cat WORKSPACE
$ cat test.sh
$ chmod +x test.sh
$ cat BUILD
sh_test(
    name="sh_test",
    srcs=["test.sh"]
)

bazel test fails with sandboxfs enabled:

$ bazel test --experimental_use_sandboxfs --test_output=all --sandbox_debug :sh_test
INFO: Invocation ID: cb555d4f-dd5b-4cdd-b988-542b80b84676
INFO: Analysed target //:sh_test (0 packages loaded, 0 targets configured).
INFO: Found 1 test target...
INFO: Mounting sandboxfs instance on /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/sandboxfs
FAIL: //:sh_test (see /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/execroot/__main__/bazel-out/k8-fastbuild/testlogs/sh_test/test.log)
INFO: From Testing //:sh_test:
==================== Test output for //:sh_test:
src/main/tools/linux-sandbox.cc:154: linux-sandbox-pid1 has PID 26510
src/main/tools/linux-sandbox-pid1.cc:175: working dir: /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/sandboxfs/10
src/main/tools/linux-sandbox-pid1.cc:194: writable: /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/linux-sandbox/1/execroot/__main__
src/main/tools/linux-sandbox-pid1.cc:194: writable: /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/linux-sandbox/1/execroot/__main__/_tmp/8d9cc406864e2af179464ec538959378
src/main/tools/linux-sandbox-pid1.cc:198: "mount(/home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/linux-sandbox/1/execroot/__main__/_tmp/8d9cc406864e2af179464ec538959378, /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/linux-sandbox/1/execroot/__main__/_tmp/8d9cc406864e2af179464ec538959378, nullptr, MS_BIND | MS_REC, nullptr)": No such file or directory
src/main/tools/linux-sandbox.cc:204: child exited normally with exitcode 1
================================================================================
Target //:sh_test up-to-date:
  bazel-bin/sh_test
INFO: Build complete; unmounting sandboxfs...
INFO: Elapsed time: 0.167s, Critical Path: 0.06s
INFO: 1 process: 1 linux-sandbox.
INFO: Build completed, 1 test FAILED, 2 total actions
//:sh_test                                                               FAILED in 0.1s
  /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/execroot/__main__/bazel-out/k8-fastbuild/testlogs/sh_test/test.log

INFO: Build completed, 1 test FAILED, 2 total actions

The _tmp directory exists in execroot:

$ ls -la /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/execroot/__main__/_tmp/8d9cc406864e2af179464ec538959378
total 8
drwxrwxr-x 2 kornholi kornholi 4096 Feb 19 20:46 .
drwxrwxr-x 5 kornholi kornholi 4096 Feb 19 20:46 ..

And bazel run runs successfully (although that does not run sandboxed anymore?):

$ bazel run --experimental_use_sandboxfs --test_output=all --sandbox_debug :sh_test
INFO: Invocation ID: 724216b4-ddc9-4f45-95be-f422429d0f68
INFO: Analysed target //:sh_test (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
INFO: Mounting sandboxfs instance on /home/kornholi/.cache/bazel/_bazel_kornholi/99e6b8dc7d2e3c8f8ca2272e8162fc83/sandbox/sandboxfs
Target //:sh_test up-to-date:
  bazel-bin/sh_test
INFO: Build complete; unmounting sandboxfs...
INFO: Elapsed time: 0.100s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:sh_test
-----------------------------------------------------------------------------

This seems to only occur with bazel test, as building a pretty complex target caused no errors with sandboxfs.

@jmmv any ideas if this is a Bazel or a sandboxfs issue?

What operating system are you running Bazel on?

Ubuntu 18.04 + Bazel 0.22.0 + sandboxfs 0.1.0

@jmmv
Copy link
Contributor

jmmv commented Feb 19, 2019

I think this is a Bazel issue. Note that the failure paths do not have /sandboxfs/ in them so they are outside of the mount point. Will need to dig a bit to understand what's happening.

@jmmv jmmv added type: bug P2 We'll consider working on this in future. (Assignee optional) team-Local-Exec Issues and PRs for the Execution (Local) team labels Feb 19, 2019
@jmmv jmmv self-assigned this Feb 19, 2019
@jmmv jmmv added this to the sandboxfs milestone Mar 14, 2019
@Globegitter
Copy link

@jmmv Any ideas on this? We are running into symlink issues (see jestjs/jest#5356) with the testing framework jest (https://jestjs.io/) and while we have patches to fix this on our end and I am planning to submit a fix to jest directly I would also be curios to see if just running tests with sandboxfs fixes the issues (which I am expecting it would).

@rohansingh
Copy link

@Globegitter Slightly unrelated, but could you describe the patches you have to fix the issue for Jest? I'm having the same issue with it and my workaround (dereferencing all symlinks) is not at all performant.

@Globegitter
Copy link

@rohansingh you can see some discussion on this here: jasongwartz/bazel_rules_nodejs_contrib#4. If you find me on the bazelbuild Slack I can also send you our latest set of patches for 24.7.1 as well as some further ones we needed for coverage support.

@jmmv
Copy link
Contributor

jmmv commented May 13, 2020

Confirmed that this is still a problem with the newest sandboxfs release (0.2.0) and latest Bazel. I'm guessing... I never tried running tests on sandboxfs, so there is probably some stupid lingering bug in there...

@al-tu
Copy link

al-tu commented Sep 23, 2020

hello. any progress on this issue? It's actually a blocker, would have switched to a sandboxed strategy otherwise.
Using: sandboxfs ver 0.2.0, bazel ver 3.4.1, testing with gtest

@Mathiasdm
Copy link

Mathiasdm commented Sep 28, 2020

Note sure if it helps narrow this down, but: we run Bazel within a docker container with CentOS 7.
If our host machine is also CentOS 7, we don't see this issue. If our host machine is Arch, we do see this issue.

It might be related to the kernel version?
Edit: note that on CentOS 7, without sandboxfs, we use processwrapper-sandbox. On Arch, it looks like linux-sandbox is used.

@Mathiasdm
Copy link

The issue also occurs on CentOS 8 (and I assume on any Linux machine that uses linux-sandbox instead of processwrapper-sandbox), blocking our upgrade.

@tcm-marcel
Copy link

We run into the same issue described above (on Ubuntu) and figured out it only happens when using the linux-sandbox execution strategy.

Therefore, our workaround is to execute all test actions with the slightly less restrictive processwrapper-sandbox. This can be achieved by this .bazelrc entry:

test:linux --strategy TestRunner=processwrapper-sandbox

This has the advantage, that any compilation actions belonging to tests are still executed with linux-sandbox (if possible) and only the actual testing action uses the other execution strategy.

@pauldraper
Copy link
Contributor

I see the error associated with generate-xml.sh failed.

@larsrc-google
Copy link
Contributor

Reproduced this. While the __main__ directory is there inside the sandbox, __main__/_tmp is not. Also, setting --test_tmpdir makes the error go away.

@github-actions
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 13, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) stale Issues or PRs that are stale (no activity for 30 days) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug
Projects
None yet
Development

No branches or pull requests

9 participants