Skip to content

Add endpoint to reset Docker storage - #7166

Merged
agners merged 3 commits into
mainfrom
docker-storage-reset
Aug 27, 2026
Merged

Add endpoint to reset Docker storage#7166
agners merged 3 commits into
mainfrom
docker-storage-reset

Conversation

@sairon

@sairon sairon commented Aug 25, 2026

Copy link
Copy Markdown
Member

Proposed change

Corrupted Docker image layers cannot be always fixed by removing and re-pulling a single image, because layers are shared between images. The only (easy) way to recover is wiping all of Docker's storage which is currently cumbersome and requires OS shell access.

Home Assistant OS added a service that performs the Docker storage wipe on boot when a flag file exists in home-assistant/operating-system#4982, and home-assistant/os-agent#283 adds OS Agent DBus interface for creating that file.

This adds a new API method POST /docker/reset-storage which calls OS Agent's ScheduleDockerStorageReset and creates a reboot_required issue, following the same pattern used for the Docker storage driver migration.

This is expected to ship in HAOS 18.3, so the endpoint checks for that and returns 404 on older OS versions. Technically, it might be nicer to gate on OS Agent version, but from user perspective it's better to report the required OS version.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (which adds functionality to the supervisor)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Ruff (ruff format supervisor tests)
  • Tests have been added to verify that the new code works.

If API endpoints or add-on configuration are added/changed:

@sairon
sairon requested a review from agners August 25, 2026 15:23
@sairon sairon added the new-feature A new feature label Aug 25, 2026
Corrupted Docker image layers cannot be always fixed by removing and
re-pulling a single image, because layers are shared between images. The
only (easy) way to recover is wiping all of Docker's storage which is
currently cumbersome and requires OS shell access.

Home Assistant OS added a service that performs the Docker storage wipe
on boot when a flag file exists in home-assistant/operating-system#4982,
and home-assistant/os-agent#283 adds OS Agent DBus interface for
creating that file.

This adds a new API method POST /docker/reset-storage which calls OS
Agent's ScheduleDockerStorageReset and creates a reboot_required issue,
following the same pattern used for the Docker storage driver migration.

This is expected to ship in HAOS 18.3, so the endpoint checks for that
and returns 404 on older OS versions. Technically, it might be nicer to
gate on OS Agent version, but from user perspective it's better to
report the required OS version.

Refs #6555

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a HAOS-gated API endpoint to schedule a complete Docker storage reset on reboot.

Changes:

  • Adds the /docker/reset-storage endpoint and D-Bus integration.
  • Creates a reboot-required issue after successful scheduling.
  • Covers success, compatibility, connection, and failure scenarios.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
supervisor/api/__init__.py Registers the new endpoint.
supervisor/api/docker.py Implements scheduling, validation, and error handling.
supervisor/dbus/agent/system.py Exposes the OS Agent D-Bus call.
tests/api/test_docker.py Tests endpoint behavior and failures.
tests/dbus/agent/test_system.py Tests the D-Bus client method.
tests/dbus_service_mocks/agent_system.py Mocks the new OS Agent method.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@agners agners left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than the version thing, LGTM!

Comment thread supervisor/api/docker.py Outdated
web.get("/docker/registries", api_docker.registries),
web.post("/docker/registries", api_docker.create_registry),
web.delete("/docker/registries/{hostname}", api_docker.remove_registry),
web.post("/docker/reset-storage", api_docker.reset_storage),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/docker is allowed by Supervisor API manager role. Is that ok for this API as well? 🤔 I guess /docker/migrate-storage-driver is very similar and already enabled for the manager role 🤔 . For me manager is fine, just wanted to bring it up so this is a conscious decision.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair point. But if we want to restrict that, let's also restrict other "dangerous" endpoints in a follow-up.

@home-assistant
home-assistant Bot marked this pull request as draft August 26, 2026 09:53
@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@sairon
sairon marked this pull request as ready for review August 27, 2026 09:54
@sairon
sairon requested a review from agners August 27, 2026 09:54

@agners agners left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@agners
agners merged commit 68ed3b5 into main Aug 27, 2026
21 checks passed
@agners
agners deleted the docker-storage-reset branch August 27, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement command to reset Docker storage

3 participants