mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 09:06:29 +00:00
Optimize resolution checks / add endpoint to trigger it manual (#2622)
This commit is contained in:
parent
ae3274e559
commit
115af4cadf
@ -238,6 +238,7 @@ class RestAPI(CoreSysAttributes):
|
||||
"/resolution/issue/{issue}",
|
||||
api_resolution.dismiss_issue,
|
||||
),
|
||||
web.post("/resolution/healthcheck", api_resolution.healthcheck),
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Handle REST API for resoulution."""
|
||||
from typing import Any, Dict
|
||||
import asyncio
|
||||
from typing import Any, Awaitable, Dict
|
||||
|
||||
from aiohttp import web
|
||||
import attr
|
||||
@ -56,3 +57,8 @@ class APIResoulution(CoreSysAttributes):
|
||||
self.sys_resolution.dismiss_issue(issue)
|
||||
except ResolutionNotFound:
|
||||
raise APIError("The supplied UUID is not a valid issue") from None
|
||||
|
||||
@api_process
|
||||
def healthcheck(self, request: web.Request) -> Awaitable[None]:
|
||||
"""Run backend healthcheck."""
|
||||
return asyncio.shield(self.sys_resolution.healthcheck())
|
||||
|
@ -244,7 +244,6 @@ class Core(CoreSysAttributes):
|
||||
self.sys_create_task(self.sys_host.reload())
|
||||
self.sys_create_task(self.sys_updater.reload())
|
||||
self.sys_create_task(self.sys_resolution.healthcheck())
|
||||
self.sys_create_task(self.sys_resolution.fixup.run_autofix())
|
||||
|
||||
self.state = CoreState.RUNNING
|
||||
self.sys_homeassistant.websocket.supervisor_update_event("supervisor", {})
|
||||
|
@ -1,8 +1,9 @@
|
||||
"""Supervisor resolution center."""
|
||||
from datetime import time
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from supervisor.const import CoreState
|
||||
|
||||
from ..coresys import CoreSys, CoreSysAttributes
|
||||
from ..exceptions import ResolutionError, ResolutionNotFound
|
||||
from .check import ResolutionCheck
|
||||
@ -141,12 +142,15 @@ class ResolutionManager(CoreSysAttributes):
|
||||
|
||||
# Schedule the healthcheck
|
||||
self.sys_scheduler.register_task(self.healthcheck, SCHEDULED_HEALTHCHECK)
|
||||
self.sys_scheduler.register_task(self.fixup.run_autofix, time(hour=2))
|
||||
|
||||
async def healthcheck(self):
|
||||
"""Scheduled task to check for known issues."""
|
||||
await self.check.check_system()
|
||||
|
||||
# Run autofix if possible
|
||||
if self.sys_core.state == CoreState.RUNNING:
|
||||
await self.fixup.run_autofix()
|
||||
|
||||
# Create notification for any known issues
|
||||
await self.notify.issue_notifications()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user