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

[Feature] Ray container must be the first application container #1379

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

kevin85421
Copy link
Member

@kevin85421 kevin85421 commented Aug 31, 2023

Why are these changes needed?

Unlike init containers, which start one by one in a sequence, all application containers in the same Pod can start simultaneously. Therefore, it is fine to enforce the Ray container to be the first application container.

Backward compatibility (v0.6.0):

[Case 1]:

  • Add an Nginx sidecar container as the first application container, and the Ray container as the second.
  • Gist

The head Pod crashes repeatedly because KubeRay identifies the first app container (i.e., Nginx container) as the Ray container and injects ray start ... command into the Nginx container.

[Case 2]:

  • Add an Nginx sidecar container as the first application container, and the Ray container as the second.
  • Add an env with name ray and value "true" in both head and workers.
    env:
    - name: ray
      value: "true"
  • Gist

The function getRayContainerIndex identifies the Ray container as the second app container. While the head Pod starts successfully, the worker's init container hangs indefinitely. This happens because FindRayContainerIndex always recognizes the first app container as the Ray container, and this function helps generate the spec for the head service. As a result, the head service exposes the Nginx port instead of the ports defined in the Ray container. Hence, the worker Pods cannot connect with the Ray head Pod successfully.

In conclusion, KubeRay has never supported a Ray container with an index other than 0.

Related issue number

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@kevin85421 kevin85421 marked this pull request as ready for review August 31, 2023 08:12
Copy link
Contributor

@architkulkarni architkulkarni left a comment

Choose a reason for hiding this comment

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

I'm a little confused by the PR description. Can you summarize the changes in the PR? It looks like:

  • Before, the Ray container could be any container and the code tries to handle that (but it handles it poorly).

  • After this PR, it's still possible that the ray container could be any container, but now the code explicitly assumes it's the first container.

Does this PR just make it fail faster if the Ray container is not the first container? What's the error message?

@kevin85421
Copy link
Member Author

Without this PR, users can only set the Ray container as the first app container in a Pod because of bugs. This PR defines that the Ray container must be the first app container explicitly. This can avoid a lot of complexity in the implementations.

@architkulkarni
Copy link
Contributor

That part makes sense, so in my understanding, if the user set the Ray container to be the second container, then before this PR, it would fail in some confusing and subtle way. How does it fail after this PR? What's the error message?

@kevin85421
Copy link
Member Author

How does it fail after this PR? What's the error message?

Currently, we don't print any related error message from KubeRay side because we lack a method to verify if the image is a Ray image. However, it is pretty easy for users to use kubectl logs ... to check the head/worker Pods, and they will see the error messages that complain there is no binary ray in the image.

Copy link
Contributor

@architkulkarni architkulkarni left a comment

Choose a reason for hiding this comment

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

Thanks for the clarification! Ideally we should document this requirement (that ray be the first container) if it isn't already documented.

@kevin85421
Copy link
Member Author

The RayService test also fails in the master branch, so it is not related to this PR. I will address the failure in a separate PR.

@kevin85421 kevin85421 merged commit ad06bbd into ray-project:master Aug 31, 2023
20 of 21 checks passed
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
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.

None yet

2 participants