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

Add pause_closed_runtimes config to pause instead of stop runtimes #6885

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Feb 21, 2025

This PR adds a new configuration variable pause_closed_runtimes (default: true) that works in conjunction with keep_runtime_alive. When both are true, the runtime will be paused instead of stopped when closing.

Changes:

  • Added pause_closed_runtimes config variable in sandbox_config.py
  • Modified close() method in remote_runtime.py to call /pause endpoint when both configs are true
  • Default value set to true for better resource management

To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:74859b1-nikolaik   --name openhands-app-74859b1   docker.all-hands.dev/all-hands-ai/openhands:74859b1

@rbren rbren marked this pull request as ready for review February 24, 2025 22:08
Comment on lines +384 to 396
if self.config.sandbox.pause_closed_runtimes:
try:
if not self._runtime_closed:
with self._send_runtime_api_request(
'POST',
f'{self.config.sandbox.remote_runtime_api_url}/pause',
json={'runtime_id': self.runtime_id},
):
self.log('debug', 'Runtime paused.')
except Exception as e:
self.log('error', f'Unable to pause runtime: {str(e)}')
raise e
super().close()
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems super().close() is still called after pausing the runtime? I'm not too familiar with this

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