From dbe0dc4d08794deac758dfb7ec066a11669697aa Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 3 Jun 2025 05:24:41 -0400 Subject: [PATCH] update_manager: add report_anomalies option Anomalies do not prevent updates, they are intended to alert users of potential issues detected within an extension for update. Anomalies are always logged, however it is not necessary for them to be reported to frontends. This option gives users the ability to silence anomalies on a per extension basis. Signed-off-by: Eric Callahan --- moonraker/components/update_manager/app_deploy.py | 1 + moonraker/components/update_manager/common.py | 2 +- moonraker/components/update_manager/git_deploy.py | 7 ++++--- moonraker/components/update_manager/net_deploy.py | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/moonraker/components/update_manager/app_deploy.py b/moonraker/components/update_manager/app_deploy.py index 663917d..765f491 100644 --- a/moonraker/components/update_manager/app_deploy.py +++ b/moonraker/components/update_manager/app_deploy.py @@ -55,6 +55,7 @@ class AppDeploy(BaseDeploy): f"option 'channel'. Type '{self.type}' supports the following " f"channels: {str_channels}. Falling back to channel '{self.channel}'" ) + self.report_anomalies = config.getboolean("report_anomalies", True) self._is_valid: bool = False self.virtualenv: Optional[pathlib.Path] = None self.py_exec: Optional[pathlib.Path] = None diff --git a/moonraker/components/update_manager/common.py b/moonraker/components/update_manager/common.py index 64f60eb..32c1cf8 100644 --- a/moonraker/components/update_manager/common.py +++ b/moonraker/components/update_manager/common.py @@ -42,7 +42,7 @@ BASE_CONFIG: Dict[str, Dict[str, str]] = { } } -OPTION_OVERRIDES = ("channel", "pinned_commit", "refresh_interval") +OPTION_OVERRIDES = ("channel", "pinned_commit", "refresh_interval", "report_anomalies") class AppType(ExtendedEnum): NONE = 1 diff --git a/moonraker/components/update_manager/git_deploy.py b/moonraker/components/update_manager/git_deploy.py index 1ef71f7..47bffde 100644 --- a/moonraker/components/update_manager/git_deploy.py +++ b/moonraker/components/update_manager/git_deploy.py @@ -151,7 +151,7 @@ class GitDeploy(AppDeploy): def get_update_status(self) -> Dict[str, Any]: status = super().get_update_status() - status.update(self.repo.get_repo_status()) + status.update(self.repo.get_repo_status(self.report_anomalies)) status["name"] = self.name return status @@ -1019,8 +1019,9 @@ class GitRepo: # Return tagged commits as SHA keys mapped to tag values return tagged_commits - def get_repo_status(self) -> Dict[str, Any]: + def get_repo_status(self, rpt_anomalies: bool) -> Dict[str, Any]: no_untrk_src = len(self.untracked_files) == 0 + anomalies = self.repo_anomalies if rpt_anomalies else [] return { 'detected_type': "git_repo", 'remote_alias': self.git_remote, @@ -1043,7 +1044,7 @@ class GitRepo: 'pristine': no_untrk_src and not self.current_version.dirty, 'corrupt': self.repo_corrupt, 'warnings': self.repo_warnings, - 'anomalies': self.repo_anomalies + 'anomalies': anomalies } def get_version(self, upstream: bool = False) -> GitVersion: diff --git a/moonraker/components/update_manager/net_deploy.py b/moonraker/components/update_manager/net_deploy.py index 7247af3..2ebef1d 100644 --- a/moonraker/components/update_manager/net_deploy.py +++ b/moonraker/components/update_manager/net_deploy.py @@ -487,6 +487,7 @@ class NetDeploy(AppDeploy): def get_update_status(self) -> Dict[str, Any]: status = super().get_update_status() + anomalies = self.anomalies if self.report_anomalies else [] status.update({ 'name': self.name, 'repo_name': self.project_name, @@ -496,6 +497,6 @@ class NetDeploy(AppDeploy): 'rollback_version': self.rollback_version, 'last_error': self.last_error, 'warnings': self.warnings, - 'anomalies': self.anomalies + 'anomalies': anomalies }) return status