Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load resolution evaluation, check and fixups early #5696

Merged
merged 3 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions supervisor/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def initialize_coresys() -> CoreSys:
# Initialize core objects
coresys.docker = await DockerAPI(coresys).load_config()
coresys.resolution = await ResolutionManager(coresys).load_config()
await coresys.resolution.load_modules()
coresys.jobs = await JobManager(coresys).load_config()
coresys.core = Core(coresys)
coresys.plugins = await PluginManager(coresys).load_config()
Expand Down
6 changes: 3 additions & 3 deletions supervisor/resolution/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def all_checks(self) -> list[CheckBase]:
"""Return all list of all checks."""
return list(self._checks.values())

async def load(self) -> None:
async def load_modules(self) -> None:
"""Load all checks."""

def _load() -> dict[str, CheckBase]:
def _load_modules() -> dict[str, CheckBase]:
"""Load and setup checks in executor."""
package = f"{__package__}.checks"
checks: dict[str, CheckBase] = {}
Expand All @@ -45,7 +45,7 @@ def _load() -> dict[str, CheckBase]:
checks[check.slug] = check
return checks

self._checks = await self.sys_run_in_executor(_load)
self._checks = await self.sys_run_in_executor(_load_modules)

def get(self, slug: str) -> CheckBase:
"""Return check based on slug."""
Expand Down
6 changes: 3 additions & 3 deletions supervisor/resolution/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def all_evaluations(self) -> list[EvaluateBase]:
"""Return all list of all checks."""
return list(self._evalutions.values())

async def load(self) -> None:
async def load_modules(self) -> None:
"""Load all evaluations."""

def _load() -> dict[str, EvaluateBase]:
def _load_modules() -> dict[str, EvaluateBase]:
"""Load and setup evaluations in executor."""
package = f"{__package__}.evaluations"
evaluations: dict[str, EvaluateBase] = {}
Expand All @@ -46,7 +46,7 @@ def _load() -> dict[str, EvaluateBase]:
evaluations[evaluation.slug] = evaluation
return evaluations

self._evalutions = await self.sys_run_in_executor(_load)
self._evalutions = await self.sys_run_in_executor(_load_modules)

def get(self, slug: str) -> EvaluateBase:
"""Return check based on slug."""
Expand Down
6 changes: 3 additions & 3 deletions supervisor/resolution/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def __init__(self, coresys: CoreSys) -> None:
self.coresys = coresys
self._fixups: dict[str, FixupBase] = {}

async def load(self) -> None:
async def load_modules(self) -> None:
"""Load all fixups."""

def _load() -> dict[str, FixupBase]:
def _load_modules() -> dict[str, FixupBase]:
"""Load and setup fixups in executor."""
package = f"{__package__}.fixups"
fixups: dict[str, FixupBase] = {}
Expand All @@ -35,7 +35,7 @@ def _load() -> dict[str, FixupBase]:
fixups[fixup.slug] = fixup
return fixups

self._fixups = await self.sys_run_in_executor(_load)
self._fixups = await self.sys_run_in_executor(_load_modules)

@property
def all_fixes(self) -> list[FixupBase]:
Expand Down
10 changes: 6 additions & 4 deletions supervisor/resolution/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def __init__(self, coresys: CoreSys):
self._unsupported: list[UnsupportedReason] = []
self._unhealthy: list[UnhealthyReason] = []

async def load_modules(self):
"""Load resolution evaluation, check and fixup modules."""
await self._evaluate.load_modules()
await self._check.load_modules()
await self._fixup.load_modules()

@property
def data(self) -> dict[str, Any]:
"""Return data."""
Expand Down Expand Up @@ -195,10 +201,6 @@ def add_issue(

async def load(self):
"""Load the resoulution manager."""
await self.check.load()
await self.fixup.load()
await self.evaluate.load()

# Initial healthcheck when the manager is loaded
await self.healthcheck()

Expand Down
3 changes: 0 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,6 @@ async def coresys(
coresys_obj._store.save_data = AsyncMock()
coresys_obj._mounts.save_data = AsyncMock()

# Load resolution center
await coresys_obj.resolution.load()

# Mock test client
coresys_obj._supervisor.instance._meta = {
"Config": {"Labels": {"io.hass.arch": "amd64"}}
Expand Down
2 changes: 1 addition & 1 deletion tests/resolution/check/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,6 @@ async def test_get_checks(coresys: CoreSys):

async def test_dynamic_check_loader(coresys: CoreSys):
"""Test dynamic check loader, this ensures that all checks have defined a setup function."""
await coresys.resolution.check.load()
await coresys.resolution.check.load_modules()
for check in get_valid_modules("checks"):
assert check in coresys.resolution.check._checks