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

Proposal(lang-python): Use fuse-overlayfs instead of pyenv-hooks for persistence. #1071

Open
axonasif opened this issue Apr 9, 2023 · 1 comment

Comments

@axonasif
Copy link
Member

axonasif commented Apr 9, 2023

Using pyenv-hook for setting up python/pip persistence over pyenv bought in unwanted issues and increased a maintenance burden, something that I had not anticipated (#868).

Before going ahead with pyenv-hooks I had tried native kernel overlayfs but that didn't work1. Recently, I looked for alternative methods in an effort to simplify the pyenv setup, it seems that a fuse implementation of overlayfs works.

By using fuse-overlayfs, we can get rid of all the custom logic that was implemented via pyenv-hook bash scripts.

with pyenv-hooks with fuse-overlayfs
pyenv-hooks(1) fuse-overlayfs(2)

Implications:

  • Requires the host workspace to have privileged access to /dev/fuse, if not found it will simply skip mounting on $HOME/.pyenv and things will keep working normally except they will lack persistence between prebuilds/reboots.
  • Unsure if it got any drawbacks.

Questions

  • Does it work inside gp validate environment?
    • Yes.
  • When is it mounted?
    • It is mounted when $GITPOD_REPO_ROOT exists. Means it will be mounted before supervisor tasks are executed in a prebuild-workspace or user-workspace. Uses an atomic lock to avoid race conditions and makes all the terminals await for the completion.

Proposed implementation

You can check the following commit for an example implementation: axonasif@d9ec66a

A docker image with the above change is available as: axonasif/workspace-python:debug2

fuse-overlayfs for solving Ruby issues

It could help with Ruby and nix as well with one simple command.

Some recent examples Screenshot 2023-04-09 at 9 32 01 PM ---- Screenshot 2023-04-09 at 9 33 55 PM

Footnotes

  1. https://gitpod.slack.com/archives/C02F19UUW6S/p1653321259722329 (internal)

@axonasif
Copy link
Member Author

axonasif commented Apr 15, 2023

Here's another proposed solution based on the discussion I had with @akosyakov on here.

Uses python -m venv <dir> (for python 3.3+) or virtualenv command to create an env inside /workspace on runtime and activate the env.

At first I was trying to use pyenv-virtualenv plugin of pyenv, but it creates the envs inside $HOME/.pyenv/versions/<dir>. However the plugin is essentially a wrapper around python -m venv/virtualenv, so we can use them to create envs directly inside /workspace without the pyenv plugin.

Commit: axonasif@480fadd

Experimental image: axonasif/workspace-python:debug7

Try on a repo: https://github.com/axonasif/test/tree/python_fix_test_venv

Implications

  • Python libraries installed from a custom dockerfile will not be available during runtime, this includes our own lang-python/Dockerfile
    Update: Workaround: axonasif@eba48e6
  • Unsure if it got any drawbacks.

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
@axonasif and others