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

GPG check: do not raise an error when TargetUserSpaceInfo is missing #1269

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down