mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-16 05:36:29 +00:00
Reduce floot on startup (#3500)
* Reduce floot on startup * Stop loading * Update supervisor/resolution/checks/core_trust.py Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * Update supervisor/resolution/checks/plugin_trust.py Co-authored-by: Joakim Sørensen <joasoe@gmail.com> * Update supervisor/resolution/checks/core_trust.py Co-authored-by: Joakim Sørensen <joasoe@gmail.com> Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
This commit is contained in:
parent
4339cae241
commit
1b8558ced3
@ -4,7 +4,7 @@ from typing import Optional
|
||||
|
||||
from ...const import CoreState
|
||||
from ...coresys import CoreSys
|
||||
from ...exceptions import CodeNotaryError, CodeNotaryUntrusted
|
||||
from ...exceptions import CodeNotaryBackendError, CodeNotaryError, CodeNotaryUntrusted
|
||||
from ..const import ContextType, IssueType, UnhealthyReason
|
||||
from .base import CheckBase
|
||||
|
||||
@ -32,6 +32,8 @@ class CheckCoreTrust(CheckBase):
|
||||
except CodeNotaryUntrusted:
|
||||
self.sys_resolution.unhealthy = UnhealthyReason.UNTRUSTED
|
||||
self.sys_resolution.create_issue(IssueType.TRUST, ContextType.CORE)
|
||||
except CodeNotaryBackendError:
|
||||
_LOGGER.warning("CAS backend issue, skipping check")
|
||||
except CodeNotaryError:
|
||||
pass
|
||||
|
||||
@ -56,4 +58,4 @@ class CheckCoreTrust(CheckBase):
|
||||
@property
|
||||
def states(self) -> list[CoreState]:
|
||||
"""Return a list of valid states when this check can run."""
|
||||
return [CoreState.RUNNING, CoreState.STARTUP]
|
||||
return [CoreState.RUNNING]
|
||||
|
@ -4,7 +4,7 @@ from typing import Optional
|
||||
|
||||
from ...const import CoreState
|
||||
from ...coresys import CoreSys
|
||||
from ...exceptions import CodeNotaryError, CodeNotaryUntrusted
|
||||
from ...exceptions import CodeNotaryBackendError, CodeNotaryError, CodeNotaryUntrusted
|
||||
from ..const import ContextType, IssueType, UnhealthyReason
|
||||
from .base import CheckBase
|
||||
|
||||
@ -35,6 +35,9 @@ class CheckPluginTrust(CheckBase):
|
||||
self.sys_resolution.create_issue(
|
||||
IssueType.TRUST, ContextType.PLUGIN, reference=plugin.slug
|
||||
)
|
||||
except CodeNotaryBackendError:
|
||||
_LOGGER.warning("CAS backend issue, skipping check")
|
||||
return
|
||||
except CodeNotaryError:
|
||||
pass
|
||||
|
||||
@ -62,4 +65,4 @@ class CheckPluginTrust(CheckBase):
|
||||
@property
|
||||
def states(self) -> list[CoreState]:
|
||||
"""Return a list of valid states when this check can run."""
|
||||
return [CoreState.RUNNING, CoreState.STARTUP]
|
||||
return [CoreState.RUNNING]
|
||||
|
@ -1,11 +1,13 @@
|
||||
"""Small wrapper for CodeNotary."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
from typing import Final, Union
|
||||
from typing import Final
|
||||
|
||||
import async_timeout
|
||||
from dirhash import dirhash
|
||||
@ -25,7 +27,7 @@ _ATTR_ERROR: Final = "error"
|
||||
_ATTR_STATUS: Final = "status"
|
||||
|
||||
|
||||
def calc_checksum(data: Union[str, bytes]) -> str:
|
||||
def calc_checksum(data: str | bytes) -> str:
|
||||
"""Generate checksum for CodeNotary."""
|
||||
if isinstance(data, str):
|
||||
return hashlib.sha256(data.encode()).hexdigest()
|
||||
@ -59,15 +61,15 @@ async def cas_validate(
|
||||
env=clean_env(),
|
||||
)
|
||||
|
||||
async with async_timeout.timeout(30):
|
||||
async with async_timeout.timeout(15):
|
||||
data, error = await proc.communicate()
|
||||
except OSError as err:
|
||||
raise CodeNotaryError(
|
||||
f"CodeNotary fatal error: {err!s}", _LOGGER.critical
|
||||
) from err
|
||||
except asyncio.TimeoutError:
|
||||
raise CodeNotaryError(
|
||||
"Timeout while processing CodeNotary", _LOGGER.error
|
||||
raise CodeNotaryBackendError(
|
||||
"Timeout while processing CodeNotary", _LOGGER.warning
|
||||
) from None
|
||||
|
||||
# Check if Notarized
|
||||
|
Loading…
x
Reference in New Issue
Block a user