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

Container snapshots/restore feature and other critical bug fixes #6441

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

Conversation

kripper
Copy link

@kripper kripper commented Jan 23, 2025

PR Summary

This PR introduces several important fixes and features to enhance the overall functionality of the system.

Key Changes:

New Feature: Container Snapshot and Restore

This feature introduces the ability to snapshot and restore container storage. It mounts Docker's storage directory (/var/lib/docker) on a virtual Btrfs volume using a loop device within the OpenHands (OH) environment. This approach has been tested on Windows using VS Code and Dev Containers, with OH running in a Docker container and creating sandboxes in nested containers.

Motivation:

The primary goal of this feature is to enable reverting changes made by OH across the entire system. This allows users to effectively undo any system modifications introduced during interactions within OH, promoting a safer and more predictable development and testing environment.

Important Notes:

Current Status:

  • No additional features will be added at this moment.
  • Frontend developers are welcome to implement a button to allow users to revert snapshots (one per user message).

Usage Instructions:

To enable the snapshot and restore functionality, add the following configuration to your sandbox settings:

[sandbox]
docker_snapshots = true

If disabled, the Docker configuration will revert upon restarting OH.

Snapshot Creation:

  • Every time a user sends a message, a new snapshot of the container storage will be created.
  • The logs will display the command required to restore each snapshot.

Testing

  • The file openhands/storage/docker_snapshots.py contains a test case (unit-tests in comments) to debug and understand how it works.

Feel free to reach out if there are any issues or further questions.

@rbren rbren changed the title Fixes and Enhancement for v0.22 Fix for reattaching to Docker when using host network Jan 24, 2025
- Added sandbox.docker_snapshots config (bool)
- Mounts a btrfs loop device for docker storage
- Can be enabled/disabled (revert docker config change)
@kripper kripper changed the title Fix for reattaching to Docker when using host network Container snapshots and restore and other fixes. Jan 25, 2025
@kripper kripper changed the title Container snapshots and restore and other fixes. Container snapshots and restore and other critical bug fixes Jan 25, 2025
@kripper kripper changed the title Container snapshots and restore and other critical bug fixes Container snapshots/restore feature and other critical bug fixes Jan 25, 2025
@enyst
Copy link
Collaborator

enyst commented Jan 25, 2025

This is a great feature, thank you for working on it!

It might be good to try to keep the bug fixes separate from new feature(s). One smaller fixes PR and one large feature PR would mean that the fixes PR is faster to review and merge. If you need the fixes too, you can create/rebase the feature branch on top on the fixes branch. It shouldn't cause much trouble when merged, then.

Up to you, it just would be better IMHO. Because I think you are correct that the fixes are needed (independently), so it would be nice if we can take them in before the snapshots feature is ready.

@kripper
Copy link
Author

kripper commented Jan 25, 2025

It might be good to try to keep the bug fixes separate from new feature(s).

Here I isolated the critical bug fixes:
#6460

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