diff --git a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py index f8d8dcfce1..f6b69670e5 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_events_scanner.py @@ -480,6 +480,20 @@ def apply_transaction_configuration(source_pkgs): return source_pkgs_with_conf_applied +def remove_leapp_related_events(events): + leapp_pkgs = [ + 'leapp', 'leapp-deps', 'leapp-upgrade-el7toel8', 'leapp-upgrade-el8toel9', + 'leapp-upgrade-el7toel8-deps', 'leapp-upgrade-el8toel9-deps', 'python2-leapp', + 'python3-leapp', 'snactor', 'cockpit-leapp' + ] + 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') @@ -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 diff --git a/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py b/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py index 8122e54159..9b395f1626 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/tests/test_pes_event_scanner.py @@ -402,3 +402,68 @@ 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(): + # these are just hypothetical and not necessarily correct + package_set_two_leapp = {Package('leapp-upgrade-el7toel8', 'repoid-rhel8', None), + Package('leapp-upgrade-el7toel8-deps', 'repoid-rhel7', None)} + package_set_one_leapp = {Package('leapp-upgrade-el7toel8', 'repoid-rhel8', None), + Package('leapp-upgrade-el7toel8-deps', '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('cockpit-leapp', 'repoid-rhel7', None)}, + {Package('cockpit-leapp', '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(2, Action.PRESENT, {Package('cockpit-leapp', 'repoid-rhel8', None)}, + {Package('cockpit-leapp', 'repoid-rhel9', None)}, (7, 0), (8, 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