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

pes_events_scanner: Ignore Leapp related PES events #1153

Merged
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 @@ -5,6 +5,7 @@
from leapp.exceptions import StopActorExecutionError
from leapp.libraries.actor import peseventsscanner_repomap
from leapp.libraries.actor.pes_event_parsing import Action, get_pes_events, Package
from leapp.libraries.common import rpms
from leapp.libraries.common.config import version
from leapp.libraries.stdlib import api
from leapp.libraries.stdlib.config import is_verbose
Expand Down Expand Up @@ -480,6 +481,19 @@ def apply_transaction_configuration(source_pkgs):
return source_pkgs_with_conf_applied


def remove_leapp_related_events(events):
# NOTE(ivasilev) Need to revisit this once rhel9->rhel10 upgrades become a thing
leapp_pkgs = rpms.get_leapp_dep_packages(
major_version=['7', '8']) + rpms.get_leapp_packages(major_version=['7', '8'])
pirat89 marked this conversation as resolved.
Show resolved Hide resolved
res = []
for event in events:
if not any(pkg.name in leapp_pkgs for pkg in event.in_pkgs):
res.append(event)
else:
api.current_logger().debug('Filtered out leapp related event, event id: {}'.format(event.id))
return res


def process():
# Retrieve data - installed_pkgs, transaction configuration, pes events
events = get_pes_events('/etc/leapp/files', 'pes-events.json')
Expand All @@ -494,6 +508,7 @@ def process():
# packages of the target system, so we can distinguish what needs to be repomapped
repoids_of_source_pkgs = {pkg.repository for pkg in source_pkgs}

events = remove_leapp_related_events(events)
events = remove_undesired_events(events, releases)

# Apply events - compute what packages should the target system have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,67 @@ def test_pkgs_are_demodularized_when_crossing_major_version(monkeypatch):
}
assert demodularized_pkgs == {Package('demodularized', 'repo', ('module-demodularized', 'stream'))}
assert target_pkgs == expected_target_pkgs


def test_remove_leapp_related_events(monkeypatch):
# NOTE(ivasilev) That's required to use leapp library functions that rely on calls to
# get_source/target_system_version functions
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(arch='x86_64', src_ver='7.9', dst_ver='8.8'))
# these are just hypothetical and not necessarily correct
package_set_two_leapp = {Package('leapp-upgrade-el7toel8', 'repoid-rhel7', None),
Package('leapp-upgrade-el7toel8-deps', 'repoid-rhel7', None)}
package_set_one_leapp = {Package('leapp-upgrade-el7toel8', 'repoid-rhel7', None),
Package('other', 'repoid-rhel7', None)}
in_events = [
Event(1, Action.PRESENT, {Package('leapp', 'repoid-rhel7', None)},
{Package('leapp', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),

Event(1, Action.RENAMED, {Package('leapp-deps', 'repoid-rhel7', None)},
{Package('leapp-deps', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),
Event(1, Action.RENAMED, {Package('leapp-upgrade-el7toel8', 'repoid-rhel7', None)},
{Package('leapp-upgrade-el8toel9', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),
Event(2, Action.RENAMED, {Package('leapp-upgrade-el7toel8-deps', 'repoid-rhel7', None)},
{Package('leapp-upgrade-el8toel9-deps', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),
Event(2, Action.PRESENT, {Package('snactor', 'repoid-rhel7', None)},
{Package('snactor', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),
Event(2, Action.REPLACED, {Package('python2-leapp', 'repoid-rhel7', None)},
{Package('python3-leapp', 'repoid-rhel8', None)},
(7, 0), (8, 0), []),

Event(1, Action.DEPRECATED, {Package('leapp-upgrade-el8toel9', 'repoid-rhel8', None)},
{Package('leapp-upgrade-el8toel9', 'repoid-rhel9', None)}, (8, 0), (9, 0), []),
Event(2, Action.REMOVED, {Package('leapp-upgrade-el8toel9-deps', 'repoid-rhel8', None)},
{}, (8, 0), (9, 0), []),
Event(1, Action.RENAMED, {Package('leapp-deps', 'repoid-rhel8', None)},
{Package('leapp-deps', 'repoid-rhel9', None)}, (8, 0), (9, 0), []),
Event(2, Action.PRESENT, {Package('snactor', 'repoid-rhel8', None)},
{Package('snactor', 'repoid-rhel9', None)}, (8, 0), (9, 0), []),
Event(2, Action.REMOVED, {Package('python3-leapp', 'repoid-rhel8', None)},
{Package('snactor', 'repoid-rhel9', None)}, (8, 0), (9, 0), []),

Event(2, Action.PRESENT, {Package('other-pkg', 'repoid-rhel8', None)},
{Package('other-pkg', 'repoid-rhel9', None)}, (7, 0), (8, 0), []),
Event(2, Action.PRESENT, {Package('other-pkg-with-leapp-in-the-name', 'repoid-rhel7', None)},
{Package('other-pkg-with-leapp-in-the-name', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),

# multiple leapp packages in in_pkgs
Event(1, Action.MERGED, package_set_two_leapp, {Package('leapp-upgrade-el7toel8', 'repoid-rhel8', None)},
(7, 0), (8, 0), []),

# multiple leapp packages in out_pkgs
Event(1, Action.SPLIT, {Package('leapp-upgrade-el7toel8', 'repoid-rhel7', None)},
package_set_two_leapp, (7, 0), (8, 0), []),

# leapp and other pkg in in_pkgs
Event(1, Action.MERGED, package_set_one_leapp, {Package('leapp', 'repoid-rhel8', None)},
(7, 0), (8, 0), []),
]
expected_out_events = [
Event(2, Action.PRESENT, {Package('other-pkg', 'repoid-rhel8', None)},
{Package('other-pkg', 'repoid-rhel9', None)}, (7, 0), (8, 0), []),
Event(2, Action.PRESENT, {Package('other-pkg-with-leapp-in-the-name', 'repoid-rhel7', None)},
{Package('other-pkg-with-leapp-in-the-name', 'repoid-rhel8', None)}, (7, 0), (8, 0), []),
]

out_events = pes_events_scanner.remove_leapp_related_events(in_events)
assert out_events == expected_out_events
Loading