mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-12-10 00:39:22 -06:00
Avoid duplicate evaluate_system() calls during resolution manager setup (#6133)
* Avoid duplicate evaluate_system() calls during resolution manager setup During resolution manager initialization, both the initial healthcheck call and the subsequent setup() call would trigger evaluate_system(), causing redundant system evaluation. All following calls in healthcheck() are already suppressed during the setup stage, we can optimize this by calling check_system() directly during load() instead of the full healthcheck(). This reduces unnecessary processing during supervisor startup while maintaining the same functional behavior. * Call full healthcheck on setup and move diagnostics to core start The OS Agent diagnostics if statement accesses OS Agent through D-Bus already. This makes the exception handling inside the if statement not really useful. Move OS Agent diagnostics setting to core start so we can leverage the existing global Exception handling in start() instead of having to add another try/except block in setup(). It also covers the if statement itself.
This commit is contained in:
parent
3397def8b9
commit
59e051ad93
@ -196,30 +196,20 @@ class Core(CoreSysAttributes):
|
||||
self.sys_resolution.add_unhealthy_reason(UnhealthyReason.SETUP)
|
||||
await async_capture_exception(err)
|
||||
|
||||
# Set OS Agent diagnostics if needed
|
||||
if (
|
||||
self.sys_config.diagnostics is not None
|
||||
and self.sys_dbus.agent.diagnostics != self.sys_config.diagnostics
|
||||
and not self.sys_dev
|
||||
and self.supported
|
||||
):
|
||||
try:
|
||||
await self.sys_dbus.agent.set_diagnostics(self.sys_config.diagnostics)
|
||||
except Exception as err: # pylint: disable=broad-except
|
||||
_LOGGER.warning(
|
||||
"Could not set diagnostics to %s due to %s",
|
||||
self.sys_config.diagnostics,
|
||||
err,
|
||||
)
|
||||
await async_capture_exception(err)
|
||||
|
||||
# Evaluate the system
|
||||
await self.sys_resolution.evaluate.evaluate_system()
|
||||
|
||||
async def start(self) -> None:
|
||||
"""Start Supervisor orchestration."""
|
||||
await self.set_state(CoreState.STARTUP)
|
||||
|
||||
# Set OS Agent diagnostics if needed
|
||||
if (
|
||||
self.sys_dbus.agent.is_connected
|
||||
and self.sys_config.diagnostics is not None
|
||||
and self.sys_dbus.agent.diagnostics != self.sys_config.diagnostics
|
||||
and self.supported
|
||||
):
|
||||
_LOGGER.debug("Set OS Agent diagnostics to %s", self.sys_config.diagnostics)
|
||||
await self.sys_dbus.agent.set_diagnostics(self.sys_config.diagnostics)
|
||||
|
||||
# Check if system is healthy
|
||||
if not self.supported:
|
||||
_LOGGER.warning("System running in a unsupported environment!")
|
||||
|
||||
@ -215,7 +215,7 @@ class ResolutionManager(FileConfiguration, CoreSysAttributes):
|
||||
|
||||
async def load(self):
|
||||
"""Load the resoulution manager."""
|
||||
# Initial healthcheck when the manager is loaded
|
||||
# Initial healthcheck check
|
||||
await self.healthcheck()
|
||||
|
||||
# Schedule the healthcheck
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user