Skip to content

Only remove the venv_root directory if it has contents #518

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kriscfoster
Copy link

When a k8s pod is configured with readOnlyRootFilesystem, we hit the following error:

Unable to create base venv directory
Read-only file system.

We then mounted a volume under the path where the venv directory was being created. We then hit:

Unable to remove venv_root directory
Read-only file system.

I think this should solve the issue. Basically, only try to delete the existing venv directory if it is non-empty. In our case, it is empty (when we are mounting an empty directory as a volume).

However, I'm not totally sure how I can actually test this in our environment without a release. I tried adding a patch for py/tools/py/src/venv.rs but that didn't work because I guess this actually gets bundled as a binary as part of the release. Do you have any hints for us to test this change?


Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes/no
  • Breaking change (forces users to change their own code or config): yes/no
  • Suggested release notes appear below: yes/no

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; please provide instructions so we can reproduce:

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link

aspect-workflows bot commented Jan 27, 2025

Test

9 test targets passed

Targets
//examples/multi_version:py_version_default_test [k8-fastbuild]                         1s
//examples/multi_version:py_version_test [k8-fastbuild-ST-494921797612]                 3s
//examples/pytest:nested/pytest [k8-fastbuild]                                          2s
//examples/pytest:pytest_test [k8-fastbuild]                                            2s
//examples/virtual_deps:pytest_test [k8-fastbuild]                                      2s
//py/tests/external-deps:test_can_import_runfiles_helper [k8-fastbuild]                 720ms
//py/tests/internal-deps:assert [k8-fastbuild]                                          566ms
//py/tests/py-test:test_env_vars [k8-fastbuild]                                         575ms
//py/tests/repo_relative_imports/test:test [k8-fastbuild]                               568ms

Total test execution time was 14s. 19 tests (67.9%) were fully cached saving 35s.

@kriscfoster
Copy link
Author

My knowledge of rust is limited so looks like there's some issue. I'll work on fixing it in this PR tomorrow.

@alexeagle
Copy link
Member

If you switch to pulling rules_py from a SHA rather than a release, you'll get the "pre-release" which exposes the rust sources to your build and you can test this from HEAD.

Or of course you can reproduce your problem within the examples folder here, which always uses a pre-release

@thesayyn
Copy link
Member

thesayyn commented Feb 6, 2025

I am curious about your end goal, ultimately we want to generate the venv runtime so it works with readonly filesystems.

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

Successfully merging this pull request may close these issues.

4 participants