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

feat: Extend EventStreamRuntime to support attaching to running containers #4588

Closed
wants to merge 3 commits into from

Conversation

qiangli
Copy link
Contributor

@qiangli qiangli commented Oct 28, 2024

End-user friendly description of the problem this fixes or functionality that this introduces

Modify the existing EventStreamRuntime to support attaching to existing running docker containers.
Provide working example files and instructions for building and running custom docker sandbox using the new EventStreamRuntime feature.

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Give a summary of what the PR does, explaining any non-trivial design decisions

This PR introduces two new optional sandbox configuration attributes with minimal modification to the existing code base for building and running custom sandboxes.

  • container_name: The name of the container.
  • docker_endpoint: The context endpoint for the sandbox Docker daemon.

These two new attributes are used to attach to the running container and the existing remote_runtime_api_url attribute is used to communicate with the running container.

The new feature could empower developers to build sandbox with any features that Docker supports without constraints and it would better fit developers' daily workflows.

EventStreamRuntime will now support local and remote docker sandbox over socket/tcp (this is an out of the box feature of docker). see https://docs.docker.com/engine/manage-resources/contexts/


Link of any specific issues this addresses

@rbren
Copy link
Collaborator

rbren commented Oct 28, 2024

@qiangli I'm unclear about how this is different from the EventStreamRuntime, which runs inside of docker, using the same server. Can you explain what the goal is here, and why the current solutions don't meet your needs?

Copy link
Collaborator

@rbren rbren left a comment

Choose a reason for hiding this comment

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

see comment above

@mamoodi
Copy link
Collaborator

mamoodi commented Nov 14, 2024

Going to close this for now since it's been a while since it was opened up and no response to the comment. Please feel free to open up a PR if there is a valid answer to the comment and worth pursuing!

@mamoodi mamoodi closed this Nov 14, 2024
@qiangli
Copy link
Contributor Author

qiangli commented Nov 14, 2024

My apology. I did not see your comments until now.

I have been trying to integrate openhands into my daily workflow as a developer and my requirement is simple: the ability to add volumes, envs, privileged/cap_add as a minimum for the sandbox separate from the main openhands processes/config. Ideally, all the docker options are supported once and for all: https://docs.docker.com/reference/cli/docker/container/create/

My earlier PR #4368 and this one tried to provide a solution.

This PR duplicated the code from EventStreamRuntime but with one big difference - this new docker runtime does not create/start the sandbox container - which is completely left to the developer so the developer has 100% control over the creation/starting/stopping of the sandbox locally on the same host as openhands or different hosts remotely.

In the end, hopefully with this change, I could setup and run openhands and have it point to a instance on my local dev machine or a remote test/stage environment. btw, it is very unlikely I could convince the team to install openhands and docker on the remote machines - not at least on every one of them.

@mamoodi mamoodi reopened this Nov 14, 2024
@mamoodi
Copy link
Collaborator

mamoodi commented Nov 14, 2024

Reopening. @rbren please see new comment

@rbren
Copy link
Collaborator

rbren commented Nov 18, 2024

Ahh what if we simply add these options to the existing EventStreamRuntime? that will be much easier to maintain

Provided working example files for building and running custom sandbox
using the DockerRuntime.
Add volume for .venv for dev build
@qiangli qiangli changed the title feat: Add docker_runtime based on EventStream feat: Extend EventStreamRuntime to support attaching to running containers Nov 20, 2024
@qiangli qiangli requested a review from rbren November 20, 2024 17:16
Comment on lines 194 to 195
# if docker context endpoint is set, custom sandbox is assumed.
if self.config.sandbox.docker_endpoint:
Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems like an unnecessary assumption--isn't it possible someone would want to set the docker endpoint without this behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not as is currently implemented. This is a new configuration attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A good point that docker_endpoint can be used and managed by openhands in future for remote instances.
Instroducing a new config attribute attach_to_existing to make it explicit.

Copy link
Collaborator

@rbren rbren left a comment

Choose a reason for hiding this comment

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

I think the goal here is:

"I want to start a single docker container, and have ALL my openhands sessions use that running container"

This is maybe a little dangerous, and potentially problematic with future work, where we'll allow users to have multiple concurrent OH sessions. In that case, you'd have 10 agents all clobbering the same workspace

Based on your last comment I thought the goal was more to have certain kinds of privileges on the containers OH creates. Could we add that as configuration (e.g. attaching volumes or running as privileged) to the EventStreamRuntime?

@qiangli
Copy link
Contributor Author

qiangli commented Nov 22, 2024

"I want to start a single docker container, and have ALL my openhands sessions use that running container"

It is 1:1. We could make it by session, i.e. each session pointing to different existing running containers. Unless I'm missing something, the current implementation of workspace/mount path in the config.toml is also assuming 1:1?

@qiangli qiangli requested a review from rbren November 22, 2024 01:42
@qiangli
Copy link
Contributor Author

qiangli commented Nov 25, 2024

will open a separate PR or maybe reinstate #4368

@qiangli qiangli closed this Nov 25, 2024
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.

3 participants