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

Allow running storage-proxy as root #2270

Open
achimnol opened this issue Jun 11, 2024 · 0 comments
Open

Allow running storage-proxy as root #2270

achimnol opened this issue Jun 11, 2024 · 0 comments
Assignees
Labels
comp:storage-proxy Related to Storage proxy component type:feature Add new features urgency:4 As soon as feasible, implementation is essential.
Milestone

Comments

@achimnol
Copy link
Member

achimnol commented Jun 11, 2024

Since we allow sudo for specific customer sites, often users create files and directories in vfolder mounts as root. Though this is NOT a recommended behavior or intended usage as we provide sudo to customize the image filesystem, not vfolder mounts, still it will be useful to run storage-proxy as root to clean up vfolders containing potentially root-created files due to various reasons.

Currently, if we configure uid and gid fields in storage-proxy.toml and execute the storage proxy as root, it will self-downgrade its privilege to the given uid/gid after binding the service sockets upon startup.

Let's add a new boolean flag option run-as-root, so that the storage-proxy processes keep running as root while changing the ownership of any created files and directories inside vfolder mounts to the configured uid and gid.

Places to ensure the file ownership for API-created files and directories:

  • ai.backend.common
    • files.AsyncFileWriter: add an optional kwarg to override the created file's ownership
  • ai.backend.storage
    • api.client
      • prepare_tus_session_headers(): when creating .upload folder to store tus upload session data
      • tus_upload_part(): pass uid/gid to AsyncFileWriter, set uid/gid of any mkdir calls
    • vfs.BaseVolume
      • create_vfolder()
      • clone_vfolder(): set the target vfolder's ownership only, not the copied contents
      • mkdir()
      • add_file(): refactor to use AsyncFileWriter?
      • prepare_upload()
  • Check if other places require update as well.

Note

If you change run-as-root setting of an existing storage-proxy, quota scopes created afterwards may be owned by root while existing ones is owned by a user account.

@achimnol achimnol added type:feature Add new features comp:storage-proxy Related to Storage proxy component urgency:4 As soon as feasible, implementation is essential. labels Jun 11, 2024
@achimnol achimnol added this to the 24.09 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:storage-proxy Related to Storage proxy component type:feature Add new features urgency:4 As soon as feasible, implementation is essential.
Projects
None yet
Development

No branches or pull requests

2 participants