diff --git a/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py b/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/libraries/missinggpgkey.py index 4b93e741b7..32e4527b66 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 StopActorExecution, StopActorExecutionError 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 diff --git a/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/tests/component_test_missinggpgkey.py b/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/tests/component_test_missinggpgkey.py index 6d3fa0b24a..2cb142a03b 100644 --- a/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/tests/component_test_missinggpgkey.py +++ b/repos/system_upgrade/common/actors/missinggpgkeysinhibitor/tests/component_test_missinggpgkey.py @@ -2,7 +2,7 @@ from six.moves.urllib.error import URLError from leapp import reporting -from leapp.exceptions import StopActorExecutionError +from leapp.exceptions import StopActorExecution, StopActorExecutionError from leapp.libraries.actor.missinggpgkey import process from leapp.libraries.common.gpg import get_pubkeys_from_rpms from leapp.libraries.common.testutils import create_report_mocked, CurrentActorMocked, logger_mocked, produce_mocked @@ -191,12 +191,13 @@ def test_perform_missing_facts(monkeypatch, msgs): monkeypatch.setattr(api, 'current_logger', logger_mocked()) # TODO: the gpg call should be mocked - with pytest.raises(StopActorExecutionError): + with pytest.raises(StopActorExecution): process() # nothing produced assert api.produce.called == 0 # not skipped by --nogpgcheck - assert not api.current_logger.warnmsg + assert len(api.current_logger.warnmsg) == 1 + assert "Missing TargetUserSpaceInfo data" in api.current_logger.warnmsg[0] @suppress_deprecation(TMPTargetRepositoriesFacts) @@ -280,7 +281,7 @@ def test_perform_missing_some_repo_facts(monkeypatch): monkeypatch.setattr(reporting, 'create_report', create_report_mocked()) monkeypatch.setattr('leapp.libraries.common.gpg._gpg_show_keys', _gpg_show_keys_mocked) - with pytest.raises(StopActorExecutionError): + with pytest.raises(StopActorExecution): process() assert api.produce.called == 0 assert reporting.create_report.called == 0