Repository navigation
Conversation
62a9cea to
8c2e097
Compare
|
@chenk008
job_config = ray.job_config.JobConfig(worker_container_image="ray:latest") Q: If ray start --head --port=6379 --system-config='{"worker_process_in_container_enabled":false}', do we still need to set |
@bklaubos No, we don't need to set |
There was a problem hiding this comment.
I'm not sure if it works when we enable multiple workers in one process.
There was a problem hiding this comment.
I'd like to not enable setting cpus and memories in this PR.
|
Also, can you add some tests? |
I have tried to start privileged container in BuildKite, but it failed. I am still working on it. |
There was a problem hiding this comment.
@simon-mo Can you take a look at the CI workflow?
21b5641 to
51a99ea
Compare
| - pip install docker | ||
| - python ./ci/travis/build-docker-images.py --py-versions PY36 --build-type BUILDKITE --only-build-nest-container | ||
| - mkdir /ray-mount/containers | ||
| - docker save -o /ray-mount/containers/images.tar rayproject/ray-nest-container:nightly-py36-cpu |
There was a problem hiding this comment.
please add some comments why are we doing this. i.e. what does each container do, why do we run the test in the container (i assume it needs access to podman?)
|
|
||
| export RAY_BACKEND_LOG_LEVEL=debug | ||
| "$HOME/anaconda3/bin/pip" install --no-cache-dir pytest | ||
| pytest /ray/python/ray/tests/test_actor_in_container.py -s |
There was a problem hiding this comment.
please use bazel to launch test instead of pytest directly
There was a problem hiding this comment.
this will enable better reporting. please also add - cleanup() { if [ "${BUILDKITE_PULL_REQUEST}" = "false" ]; then ./ci/travis/upload_build_info.sh; fi }; trap cleanup EXIT to the steps so we are uploading correct logs.
jovany-wang
left a comment
There was a problem hiding this comment.
C++ part looks good to me, and let's wait for @simon-mo to approve other parts.
| /// \return The non-volatile temporary directory for the current user (often /tmp). | ||
| std::string GetUserTempDir(); | ||
|
|
||
| /// \return The stderr reference file. return empty if stderr not redirect to file. |
There was a problem hiding this comment.
| /// \return The stderr reference file. return empty if stderr not redirect to file. | |
| /// \return The stderr reference file. Return empty if stderr is not redirected to file. |
| }; | ||
|
|
||
| TEST_F(ContainerWorkerPoolTest, RegisterDriver) { | ||
| // ContainerWorkerPoolTest constructor will invoke PYTHON RegisterDriver. |
There was a problem hiding this comment.
| // ContainerWorkerPoolTest constructor will invoke PYTHON RegisterDriver. | |
| // ContainerWorkerPoolTest constructor will invokes PYTHON RegisterDriver. |
| WorkerCacheKey env = {override_environment_variables, serialized_runtime_env}; | ||
| ResourceSet workerCacheKeyResource = worker_resource; | ||
| if (!worker_process_in_container_enabled_) { | ||
| workerCacheKeyResource = {}; |
There was a problem hiding this comment.
These lines could be simplified to:
ResourceSet workerCacheKeyResource = worker_process_in_container_enabled_ ? worker_resource : {};| // logger, and the worker process' stdout/stderr has been redirected to raylet.err by | ||
| // default. | ||
| std::string stderr_file = ray::GetStderrFile(); | ||
| if (!stderr_file.empty()) { |
There was a problem hiding this comment.
What if stderr_file string is empty?
| if (RAY_LOG_ENABLED(DEBUG)) { | ||
| argv.emplace_back("--log-level=debug"); | ||
| } else { | ||
| argv.emplace_back("--rm"); |
There was a problem hiding this comment.
What does --rm do? Could you add comments for it?
| } | ||
| // TODO set uid for container, for example: -u admin | ||
| argv.emplace_back("-d"); | ||
| argv.emplace_back("-v"); |
There was a problem hiding this comment.
Could you add more comments for these command line options? (eg, -d -v)
| tags = ["exclusive", "worker-nest-container"], | ||
| # Now we run this test in a container which has installed ray | ||
| deps = [], | ||
| ) No newline at end of file |
|
And also wait for @ericl or @pcmoritz to approve this feature flag. @ericl |
Hmm this is very unfortunate, we intended runtime env to be used for specifying docker image in a unified way. What if we made it a protobuf? Then, we also don't need the system flag since we can enable docker only if it's found in the runtime env proto. Cc @iycheng |
Similarly, this should just be preparing runtime envs, which could automatically include the docker image. |
ericl
left a comment
There was a problem hiding this comment.
API: change worker_container_image: X to runtime_env: docker: X
I have open a issue : #16333. We can discuss in this issue. |
It makes sense. I this this PR #15904 can help to pull container image. |
| @@ -0,0 +1,92 @@ | |||
| ARG BASE_IMAGE="ubuntu:groovy" | |||
There was a problem hiding this comment.
Is this only for testing?
| try_to_create_directory( | ||
| os.path.join(self._session_dir, "worker_container")) |
There was a problem hiding this comment.
do you mind putting them into runtime_resources? This is the place where all runtime env related things being put.
| if (const char *env_pid = std::getenv("RAYLET_PID")) { | ||
| pid_t pid = static_cast<pid_t>(std::atoi(env_pid)); | ||
| if (!IsProcessAlive(pid)) { | ||
| RAY_LOG(ERROR) << "Raylet failed. Shutting down. Pid: " << pid; | ||
| Shutdown(); | ||
| } | ||
| } else if (!IsParentProcessAlive()) { |
There was a problem hiding this comment.
Confused here about why we need it. Do you mind giving some comments about this?
| return child; | ||
| } | ||
|
|
||
| Process WorkerPool::StartContainerProcess( |
There was a problem hiding this comment.
we don't need this function to be put in CPP layer. Shim process should be good enough.
Right now it only take care of conda env, like install conda and activate and start default worker.
I think you can process it there in the same way, but make sure run it before the conda env get processed.
@architkulkarni could you help double-check it's working with shim process?
|
Right now, conda is installed in shim process and it's designed to be extended easily. We probably don't want another code path to take care of env installation. Could you try to put the logic into shim process? I have the feeling that the code will become clearer and easier to maintain. @architkulkarni could you also help check it can be done in shim process? |
Why are these changes needed?
We want to use container to resource limit, and use container image to support different dependencies.
This is the first PR to implements that feature. By using Podman, Worker process will started in container.
Now runtime_env is serialized in cpp code, we can't reuse runtime_env to specify the contain image.We add container image option fields into
job_config, and supports to specify the contain image.We add worker_resource into
WorkerCacheKey, because worker_resource is one of worker’ characteristic, different actors have different worker_resource should not reuse worker process especially in container mode.Start worker in container:
2 start job with container image
There are some features in next PR:
Related issue number
#14077
Checks
scripts/format.shto lint the changes in this PR.