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

[Core] runtime_env remote URI authentication issue #28253

Closed
Martin4R opened this issue Sep 1, 2022 · 3 comments
Closed

[Core] runtime_env remote URI authentication issue #28253

Martin4R opened this issue Sep 1, 2022 · 3 comments
Assignees
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core triage Needs triage (eg: priority, bug/not-bug, and owning component)

Comments

@Martin4R
Copy link

Martin4R commented Sep 1, 2022

What happened + What you expected to happen

I tried to use remote URLs in working_dir and py_module params of runtime-environments to download zip files from a private GitLab package registry. I did this with the fruit-example of Ray Serve with KubeRay.

The way mentioned in the documentation is to use HTTP-Basic authentication directly in the URL (see https://docs.ray.io/en/latest/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments).

The described approach from the docs does not work for me and also has some side effects:

  • credentials are then visible in the K8s config, which one can read with read-access (also in kubectl describe RayService)
  • credentials get printed in Kuberay K8s-operator log file
  • username:password gets included in the folder-name in the file-system: /tmp/ray/session_latest/runtime-resources/working_dir_files/https_ray-cluster:realpwdwouldbehere@gitlab_com_api_v4_projects_42_packages_generic_fruit_example_b5b4a19a_fruit_example
  • the download of the zip file works, but then python complains that module ‘fruit’ cannot be found. This is because the folder-name of before mentioned folder gets included in the environment variable PYTHONPATH, which uses “:” as separator (and username:password also contains a colon as separator). Therefore the folder-name is split in 2 parts and Python searches in the wrong place for the module.

To work around the issues, I used a .netrc file instead for authentication.

Versions / Dependencies

  • Ray 2.0.0
  • Kuberay 0.3.0
  • Python 3.7

Reproduction script

I used the example of a Kuberay RayService from here: https://docs.ray.io/en/latest/serve/production-guide/kubernetes.html
I used this example RayService CR with an HTTP-Basic protected zip-file for the working_dir param.

Issue Severity

Medium: It is a significant difficulty but I can work around it.

@Martin4R Martin4R added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Sep 1, 2022
@richardliaw richardliaw added the core Issues that should be addressed in Ray Core label Oct 29, 2022
@shrekris-anyscale
Copy link
Contributor

The importing issue should be resolved by #28250. The netrc workaround is likely best for production use-cases, so the username and password aren't exposed. We should follow up with documentation explaining how to use netrc with runtime_envs.

@Xalag
Copy link

Xalag commented Nov 7, 2022

One option for Kuberay:
Create a secret which has ".netrc" as a key and the contents of the .netrc-file as the value.
Then use it as a mounted volume and set the environment variable NETRC to the destination:

containers:
            - name: ray-head
              image: rayproject/ray:2.0.0-py39
              volumeMounts:
                - mountPath: "/home/ray/netrcvolume/"
                  name: netrc-kuberay
                  readOnly: true
              env:
                - name: NETRC
                  value: "/home/ray/netrcvolume/.netrc"
volumes:
            - name: netrc-kuberay
              secret:
                secretName: secret-netrc-kuberay

@simon-mo
Copy link
Contributor

simon-mo commented Nov 7, 2022

Closing as this has been answered by @shrekris-anyscale and thanks @Xalag for providing the code same in KubeRay

@simon-mo simon-mo closed this as completed Nov 7, 2022
architkulkarni pushed a commit that referenced this issue May 24, 2023
…Is (#35578)

Users can provide dependencies via a remote URI in their runtime_env. To access private dependencies, users must include authentication information with their request. Commonly, this is done by including credentials in the URI itself. However, this pattern can be insecure since Ray may log the URI or use it to name temporary directories. Instead, users should supply their credentials using a .netrc file.

This change adds documentation explaining how to use a .netrc file on VMs or KubeRay. Thanks to @Xalag and @Martin4R for the discussion in #28253. Some of the examples have been adapted from that issue.

netrc documentation link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/runtime_env_auth.html
runtime_env URL templates link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments
Related issue number
See #28253
shrekris-anyscale added a commit to shrekris-anyscale/ray that referenced this issue May 25, 2023
…Is (ray-project#35578)

Users can provide dependencies via a remote URI in their runtime_env. To access private dependencies, users must include authentication information with their request. Commonly, this is done by including credentials in the URI itself. However, this pattern can be insecure since Ray may log the URI or use it to name temporary directories. Instead, users should supply their credentials using a .netrc file.

This change adds documentation explaining how to use a .netrc file on VMs or KubeRay. Thanks to @Xalag and @Martin4R for the discussion in ray-project#28253. Some of the examples have been adapted from that issue.

netrc documentation link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/runtime_env_auth.html
runtime_env URL templates link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments
Related issue number
See ray-project#28253
ArturNiederfahrenhorst pushed a commit that referenced this issue May 26, 2023
…Is (#35578) (#35784)

Users can provide dependencies via a remote URI in their runtime_env. To access private dependencies, users must include authentication information with their request. Commonly, this is done by including credentials in the URI itself. However, this pattern can be insecure since Ray may log the URI or use it to name temporary directories. Instead, users should supply their credentials using a .netrc file.

This change adds documentation explaining how to use a .netrc file on VMs or KubeRay. Thanks to @Xalag and @Martin4R for the discussion in #28253. Some of the examples have been adapted from that issue.

netrc documentation link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/runtime_env_auth.html
runtime_env URL templates link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments
Related issue number
See #28253
scv119 pushed a commit to scv119/ray that referenced this issue Jun 16, 2023
…Is (ray-project#35578)

Users can provide dependencies via a remote URI in their runtime_env. To access private dependencies, users must include authentication information with their request. Commonly, this is done by including credentials in the URI itself. However, this pattern can be insecure since Ray may log the URI or use it to name temporary directories. Instead, users should supply their credentials using a .netrc file.

This change adds documentation explaining how to use a .netrc file on VMs or KubeRay. Thanks to @Xalag and @Martin4R for the discussion in ray-project#28253. Some of the examples have been adapted from that issue.

netrc documentation link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/runtime_env_auth.html
runtime_env URL templates link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments
Related issue number
See ray-project#28253
arvind-chandra pushed a commit to lmco/ray that referenced this issue Aug 31, 2023
…Is (ray-project#35578)

Users can provide dependencies via a remote URI in their runtime_env. To access private dependencies, users must include authentication information with their request. Commonly, this is done by including credentials in the URI itself. However, this pattern can be insecure since Ray may log the URI or use it to name temporary directories. Instead, users should supply their credentials using a .netrc file.

This change adds documentation explaining how to use a .netrc file on VMs or KubeRay. Thanks to @Xalag and @Martin4R for the discussion in ray-project#28253. Some of the examples have been adapted from that issue.

netrc documentation link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/runtime_env_auth.html
runtime_env URL templates link: https://anyscale-ray--35578.com.readthedocs.build/en/35578/ray-core/handling-dependencies.html#option-2-manually-create-url-slower-to-implement-but-recommended-for-production-environments
Related issue number
See ray-project#28253

Signed-off-by: e428265 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't core Issues that should be addressed in Ray Core triage Needs triage (eg: priority, bug/not-bug, and owning component)
Projects
None yet
Development

No branches or pull requests

5 participants