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

enhance Bazel easyblock to avoid writing to $HOME in sanity check #2756

Merged
merged 2 commits into from
Jun 28, 2022

Conversation

Flamefire
Copy link
Contributor

@Flamefire Flamefire commented Jun 28, 2022

(created using eb --new-pr)

Detected by a readonly file $HOME/.cache/bazel in Bazel 1+ ECs:

Sanity check failed: sanity check command bazel --help exited with code 36 (output: FATAL: mkdir('/home/s3248973/.cache/bazel/_bazel_s3248973')

The approach here uses a kind of "cached" property to avoid changing more code than required and always have access to self.output_user_root even in sanity checks with --module-only or --sanity-check-only

ocaisa
ocaisa previously approved these changes Jun 28, 2022
Copy link
Member

@ocaisa ocaisa left a comment

Choose a reason for hiding this comment

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

LGTM

@ocaisa
Copy link
Member

ocaisa commented Jun 28, 2022

Test report by @ocaisa

Overview of tested easyconfigs (in order)

  • SUCCESS Bazel-4.2.2-GCCcore-11.2.0.eb
  • SUCCESS Bazel-3.7.2-GCCcore-11.2.0.eb

Build succeeded for 2 out of 2 (2 easyconfigs in total)
login1 - Linux Rocky Linux 8.5, x86_64, Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz, Python 3.6.8
See https://gist.github.com/31fe56b22a446f38a8d4242ea55c8991 for a full test report.

@ocaisa
Copy link
Member

ocaisa commented Jun 28, 2022

Test report by @ocaisa

Overview of tested easyconfigs (in order)

  • **FAIL (unhandled exception: [Errno 2] No such file or directory: '/home/ocaisa/.local/easybuild/build/Bazel/4.2.2/GCCcore-11.2.0/tmpcsprvui4-bazel-root')Traceback (most recent call last):
    File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 130, in output_user_root
    return self._output_user_root
    AttributeError: 'EB_Bazel' object has no attribute '_output_user_root'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/main.py", line 128, in build_and_install_software
(ec_res['success'], app_log, err) = build_and_install_one(ec, init_env)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 4058, in build_and_install_one
result = app.run_all_steps(run_test_cases=run_test_cases)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 3941, in run_all_steps
self.run_step(step_name, step_methods)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 3776, in run_step
step_method(self)()
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 222, in sanity_check_step
custom_commands.append("bazel --output_user_root=%s --help" % self.output_user_root)
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 132, in output_user_root
self._make_output_user_root()
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 125, in _make_output_user_root
self._output_user_root = tempfile.mkdtemp(suffix='-bazel-root', dir=self.builddir)
File "/usr/lib64/python3.6/tempfile.py", line 370, in mkdtemp
_os.mkdir(file, 0o700)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ocaisa/.local/easybuild/build/Bazel/4.2.2/GCCcore-11.2.0/tmpcsprvui4-bazel-root'
** Bazel-4.2.2-GCCcore-11.2.0.eb

  • **FAIL (unhandled exception: [Errno 2] No such file or directory: '/home/ocaisa/.local/easybuild/build/Bazel/3.7.2/GCCcore-11.2.0/tmpx64c2hm6-bazel-root')Traceback (most recent call last):
    File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 130, in output_user_root
    return self._output_user_root
    AttributeError: 'EB_Bazel' object has no attribute '_output_user_root'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/main.py", line 128, in build_and_install_software
(ec_res['success'], app_log, err) = build_and_install_one(ec, init_env)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 4058, in build_and_install_one
result = app.run_all_steps(run_test_cases=run_test_cases)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 3941, in run_all_steps
self.run_step(step_name, step_methods)
File "/home/ocaisa/EasyBuild_Git/easybuild-framework/easybuild/framework/easyblock.py", line 3776, in run_step
step_method(self)()
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 222, in sanity_check_step
custom_commands.append("bazel --output_user_root=%s --help" % self.output_user_root)
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 132, in output_user_root
self._make_output_user_root()
File "/tmp/eb-mzn1s1l4/included-easyblocks-z1rroarm/easybuild/easyblocks/bazel.py", line 125, in _make_output_user_root
self._output_user_root = tempfile.mkdtemp(suffix='-bazel-root', dir=self.builddir)
File "/usr/lib64/python3.6/tempfile.py", line 370, in mkdtemp
_os.mkdir(file, 0o700)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ocaisa/.local/easybuild/build/Bazel/3.7.2/GCCcore-11.2.0/tmpx64c2hm6-bazel-root'
** Bazel-3.7.2-GCCcore-11.2.0.eb

Build succeeded for 0 out of 2 (2 easyconfigs in total)
login1 - Linux Rocky Linux 8.5, x86_64, Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz, Python 3.6.8
See https://gist.github.com/29d146c926c9be7e8e497e411b0c387d for a full test report.

@ocaisa
Copy link
Member

ocaisa commented Jun 28, 2022

@Flamefire Still needs some love to work with --sanity-check, there is no build directory created when only doing a sanity check.
Actual problem is below, but I still wonder if we should be creating the build directory just for this. If I don't have write permissions in the default space then I need to set a specific buildpath just to do a sanity check.

@Flamefire
Copy link
Contributor Author

If I don't have write permissions in the default space then I need to set a specific buildpath just to do a sanity check.

I don't really see a way to avoid this...

I'm also surprised your mkdtemp fails. Maybe we need to manually create the builddir first. But first we should settle on if we should and where that could also be: The dir used in the sanity check could be somewhere else, e.g. in the EB temp dir.

@ocaisa
Copy link
Member

ocaisa commented Jun 28, 2022

Test report by @ocaisa (sanity check run)

Overview of tested easyconfigs (in order)

  • SUCCESS Bazel-4.2.2-GCCcore-11.2.0.eb
  • SUCCESS Bazel-3.7.2-GCCcore-11.2.0.eb

Build succeeded for 2 out of 2 (2 easyconfigs in total)
login1 - Linux Rocky Linux 8.5, x86_64, Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz, Python 3.6.8
See https://gist.github.com/0783de00daa975f31c186648349c08b5 for a full test report.

Copy link
Member

@ocaisa ocaisa left a comment

Choose a reason for hiding this comment

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

LGTM

@ocaisa
Copy link
Member

ocaisa commented Jun 28, 2022

Test report by @ocaisa

Overview of tested easyconfigs (in order)

  • SUCCESS Bazel-4.2.2-GCCcore-11.2.0.eb
  • SUCCESS Bazel-3.7.2-GCCcore-11.2.0.eb

Build succeeded for 2 out of 2 (2 easyconfigs in total)
login1 - Linux Rocky Linux 8.5, x86_64, Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz, Python 3.6.8
See https://gist.github.com/f301fe8c14b5750913c76c763b6a5475 for a full test report.

@ocaisa ocaisa merged commit 3344094 into easybuilders:develop Jun 28, 2022
@Flamefire Flamefire deleted the 20220628120333_new_pr_bazel branch June 28, 2022 14:05
@boegel boegel changed the title Bazel: Avoid writing to $HOME in sanity check enhance Bazel easyblock to avoid writing to $HOME in sanity check Jul 6, 2022
@boegel boegel added the bug fix label Jul 6, 2022
@boegel boegel added this to the next release (4.5.6?) milestone Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants