Skip to content

Commit 59e051a

Browse files
authored
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.
1 parent 3397def commit 59e051a

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

supervisor/core.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,19 @@ async def setup(self) -> None:
196196
self.sys_resolution.add_unhealthy_reason(UnhealthyReason.SETUP)
197197
await async_capture_exception(err)
198198

199+
async def start(self) -> None:
200+
"""Start Supervisor orchestration."""
201+
await self.set_state(CoreState.STARTUP)
202+
199203
# Set OS Agent diagnostics if needed
200204
if (
201-
self.sys_config.diagnostics is not None
205+
self.sys_dbus.agent.is_connected
206+
and self.sys_config.diagnostics is not None
202207
and self.sys_dbus.agent.diagnostics != self.sys_config.diagnostics
203-
and not self.sys_dev
204208
and self.supported
205209
):
206-
try:
207-
await self.sys_dbus.agent.set_diagnostics(self.sys_config.diagnostics)
208-
except Exception as err: # pylint: disable=broad-except
209-
_LOGGER.warning(
210-
"Could not set diagnostics to %s due to %s",
211-
self.sys_config.diagnostics,
212-
err,
213-
)
214-
await async_capture_exception(err)
215-
216-
# Evaluate the system
217-
await self.sys_resolution.evaluate.evaluate_system()
218-
219-
async def start(self) -> None:
220-
"""Start Supervisor orchestration."""
221-
await self.set_state(CoreState.STARTUP)
210+
_LOGGER.debug("Set OS Agent diagnostics to %s", self.sys_config.diagnostics)
211+
await self.sys_dbus.agent.set_diagnostics(self.sys_config.diagnostics)
222212

223213
# Check if system is healthy
224214
if not self.supported:

supervisor/resolution/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def add_issue(
215215

216216
async def load(self):
217217
"""Load the resoulution manager."""
218-
# Initial healthcheck when the manager is loaded
218+
# Initial healthcheck check
219219
await self.healthcheck()
220220

221221
# Schedule the healthcheck

0 commit comments

Comments
 (0)