Make disk_lifetime issue into a repair (#150140)

This commit is contained in:
Mike Degatano
2025-08-12 02:39:37 -04:00
committed by GitHub
parent 68fbcc8665
commit a06df2a680
3 changed files with 52 additions and 0 deletions

View File

@@ -103,6 +103,7 @@ ISSUE_KEYS_FOR_REPAIRS = {
ISSUE_KEY_SYSTEM_DOCKER_CONFIG,
ISSUE_KEY_ADDON_DETACHED_ADDON_MISSING,
ISSUE_KEY_ADDON_DETACHED_ADDON_REMOVED,
"issue_system_disk_lifetime",
}
_LOGGER = logging.getLogger(__name__)

View File

@@ -115,6 +115,10 @@
}
}
},
"issue_system_disk_lifetime": {
"title": "Disk lifetime exceeding 90%",
"description": "The data disk has exceeded 90% of its expected lifespan. The disk may soon malfunction which can lead to data loss. You should replace it soon and migrate your data."
},
"unhealthy": {
"title": "Unhealthy system - {reason}",
"description": "System is currently unhealthy due to {reason}. For troubleshooting information, select Learn more."

View File

@@ -850,3 +850,50 @@ async def test_supervisor_issues_detached_addon_missing(
"addon_url": "/hassio/addon/test",
},
)
@pytest.mark.usefixtures("all_setup_requests")
async def test_supervisor_issues_disk_lifetime(
hass: HomeAssistant,
supervisor_client: AsyncMock,
hass_ws_client: WebSocketGenerator,
) -> None:
"""Test supervisor issue for disk lifetime nearly exceeded."""
mock_resolution_info(supervisor_client)
result = await async_setup_component(hass, "hassio", {})
assert result
client = await hass_ws_client(hass)
await client.send_json(
{
"id": 1,
"type": "supervisor/event",
"data": {
"event": "issue_changed",
"data": {
"uuid": (issue_uuid := uuid4().hex),
"type": "disk_lifetime",
"context": "system",
"reference": None,
},
},
}
)
msg = await client.receive_json()
assert msg["success"]
await hass.async_block_till_done()
await client.send_json({"id": 2, "type": "repairs/list_issues"})
msg = await client.receive_json()
assert msg["success"]
assert len(msg["result"]["issues"]) == 1
assert_issue_repair_in_list(
msg["result"]["issues"],
uuid=issue_uuid,
context="system",
type_="disk_lifetime",
fixable=False,
placeholders=None,
)