From c98a597a477e862c95ffb2ce346ed6a81751173b Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Thu, 4 Jul 2024 10:52:43 +0200 Subject: [PATCH] GPG check: do not raise an error when TargetUserSpaceInfo is missing Previously, if the upgrade has been inhibited during TargetTransactionFactsCollectionPhase usually because we could not create (for whatever reason) the target userspace container, the actor checking rpm gpg keys failed with the `Could not check for valid GPG keys` error. This has confused many users as they couldn't know that this is impacted by the problem described in an inhibitor that is below this error. As it's for sure that the upgrade cannot continue when the target user space container has not been created (the TargetUserSpaceInfo msg is missing), we consider it safe to stop the gpg check here silently just with a warning msg instead of raising the error - as this check is important only in case we could actually upgrade. All other possible raised errors are presereved. jira: https://issues.redhat.com/browse/RHEL-30573 --- .../libraries/missinggpgkey.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py b/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py index 4b93e741b7..b07ad1f2b4 100644 --- a/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py +++ b/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py @@ -7,7 +7,7 @@ from six.moves import urllib from leapp import reporting -from leapp.exceptions import StopActorExecutionError +from leapp.exceptions import StopActorExecutionError, StopActorExecution from leapp.libraries.common.config.version import get_target_major_version from leapp.libraries.common.gpg import get_gpg_fp_from_file, get_path_to_gpg_certs, is_nogpgcheck_set from leapp.libraries.stdlib import api @@ -61,6 +61,15 @@ def _get_abs_file_path(target_userspace, file_url): def _consume_data(): + try: + target_userspace = next(api.consume(TargetUserSpaceInfo)) + except StopIteration: + api.current_logger().warning( + 'Missing TargetUserSpaceInfo data. The upgrade cannot continue' + 'without this data, so skipping any other actions.' + ) + raise StopActorExecution() + try: used_target_repos = next(api.consume(UsedTargetRepositories)).repos except StopIteration: @@ -83,12 +92,6 @@ def _consume_data(): raise StopActorExecutionError( 'Could not check for valid GPG keys', details={'details': 'No TrustedGpgKeys facts'} ) - try: - target_userspace = next(api.consume(TargetUserSpaceInfo)) - except StopIteration: - raise StopActorExecutionError( - 'Could not check for valid GPG keys', details={'details': 'No TargetUserSpaceInfo facts'} - ) return used_target_repos, target_repos, trusted_gpg_keys, target_userspace