Skip to content

Conversation

@agners
Copy link
Member

@agners agners commented Nov 13, 2025

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)
  • 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

  • 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:

@agners agners added the new-feature A new feature label Nov 13, 2025
@agners
Copy link
Member Author

agners commented Nov 13, 2025

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
Copy link
Member Author

agners commented Nov 13, 2025

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 🤔 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

Add verification that the frontend is actually accessible at "/" after core
updates to ensure the web interface is serving properly, not just that the
API endpoints respond.

Previously, the update verification only checked API endpoints and whether
the frontend component was loaded. This could miss cases where the API is
responsive but the frontend fails to serve the UI.

Changes:
- Add check_frontend_available() method to HomeAssistantAPI that fetches
  the root path and verifies it returns HTML content
- Integrate frontend check into core update verification flow after
  confirming the frontend component is loaded
- Trigger automatic rollback if frontend is inaccessible after update
- Fix blocking I/O calls in rollback log file handling to use async
  executor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@agners agners force-pushed the check-frontend-after-core-update branch from 40d2f18 to 96e6c0b Compare November 13, 2025 08:51
@agners agners requested review from Copilot and mdegat01 and removed request for Copilot November 13, 2025 14:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances Home Assistant Core update verification by adding a frontend accessibility check after updates. Currently, the update process only verifies that API endpoints respond and the frontend component is loaded, which could miss cases where the API is responsive but the web UI fails to serve. The new check_frontend_available() method fetches the root path and verifies it returns HTML content with a 200 status code, automatically triggering a rollback if the frontend is inaccessible.

Key Changes:

  • New check_frontend_available() method in the HomeAssistantAPI class that validates frontend HTML responses
  • Integration of frontend check into the update verification flow after confirming the frontend component is loaded
  • Conversion of blocking I/O operations (file existence check and copy) to async using the executor pattern

Reviewed Changes

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

File Description
supervisor/homeassistant/api.py Adds new check_frontend_available() method to verify frontend accessibility by checking for HTML response from root path
supervisor/homeassistant/core.py Integrates frontend check into update verification logic and fixes blocking I/O for log file operations using async executor
tests/homeassistant/test_api.py Comprehensive unit tests for the new frontend availability check covering success, failure, and edge cases
tests/api/test_homeassistant.py Integration tests verifying the full update flow with frontend checks and rollback behavior

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

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.

2 participants