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:
Stefan Agner 2025-09-05 10:16:06 +02:00 committed by GitHub
parent 3397def8b9
commit 59e051ad93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 21 deletions

View File

@ -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!")

View File

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