supervisor icon indicating copy to clipboard operation
supervisor copied to clipboard

Check frontend availability after Home Assistant Core updates

Open agners opened this issue 2 months ago • 2 comments

Proposed change

This PR enhances the Home Assistant Core update verification process to ensure the frontend is actually accessible and serving properly after updates, not just that the API endpoints respond.

Currently, after a core update, Supervisor only checks if the API endpoints (/api/core/state or /api/config) respond and whether the frontend component is loaded. This could miss cases where the API is responsive but the frontend fails to serve the web UI, leaving users with a seemingly successful update but an inaccessible interface.

This PR adds a check_frontend_available() method that fetches the root path (/) and verifies it returns HTML content with a 200 status code. This check runs after confirming the frontend component is loaded. If the frontend is inaccessible, the update automatically triggers a rollback to the previous version.

Additionally, this PR fixes blocking I/O operations in the rollback log file handling by using the async executor pattern.

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] 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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request: N/A
  • Link to cli pull request: N/A
  • Link to client library pull request: N/A

Checklist

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

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

agners avatar Nov 13 '25 08:11 agners

When trying to update to todays nightly build with a bad frontend manually like so:

ha core update --version 2025.12.0.dev202511130240

The Supervisor rolls back the Core to the previous version

2025-11-13 09:38:35.853 WARNING (MainThread) [supervisor.homeassistant.api] Frontend returned status 500
2025-11-13 09:38:35.853 ERROR (MainThread) [supervisor.homeassistant.core] Frontend component loaded but frontend is not accessible
2025-11-13 09:38:35.853 CRITICAL (MainThread) [supervisor.homeassistant.core] HomeAssistant update failed -> rollback!
2025-11-13 09:38:35.855 INFO (MainThread) [supervisor.resolution.module] Create new issue update_rollback - core / None

agners avatar Nov 13 '25 08:11 agners

What I did notice is that we delete the old image before rollback. This means we clean the image, then redownload it again.

This always used to be the case, and maybe we could even make the case that this makes sure the previous image is properly downloaded again. On the other hand, this redownload might fail. If Core worked before, the image on disk is most likely in a good state, so this only adds the risk that rollback fails :thinking: I'll create a separate PR for this.

2025-11-13 09:38:32.372 INFO (MainThread) [supervisor.homeassistant.core] Successfully started Home Assistant 2025.12.0.dev202511130240
...
2025-11-13 09:38:32.396 INFO (MainThread) [supervisor.docker.manager] Cleanup images: ['ghcr.io/home-assistant/qemux86-64-homeassistant:2025.12.0.dev202511120239']
...
2025-11-13 09:38:35.853 WARNING (MainThread) [supervisor.homeassistant.api] Frontend returned status 500
2025-11-13 09:38:35.853 ERROR (MainThread) [supervisor.homeassistant.core] Frontend component loaded but frontend is not accessible
2025-11-13 09:38:35.853 CRITICAL (MainThread) [supervisor.homeassistant.core] HomeAssistant update failed -> rollback!
...
2025-11-13 09:38:35.856 INFO (MainThread) [supervisor.homeassistant.core] Updating Home Assistant to version 2025.12.0.dev202511120239

agners avatar Nov 13 '25 08:11 agners