Skip to content

Commit

Permalink
pes_events_scanner: Ignore Leapp related PES events
Browse files Browse the repository at this point in the history
When PES events are added for all the Leapp related packages, we need to
make sure to ignore them in `pes_events_scanner` to make sure they are
*not* taken into account during the RPM upgrade transaction as we don't
want to upgrade them or want to handle their upgrade in a different way.

Jira: OAMG-5645
  • Loading branch information
matejmatuska authored and fernflower committed Jan 11, 2024
1 parent c627a0b commit e4ff608
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ 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'
]
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 +509,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,64 @@ 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-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

0 comments on commit e4ff608

Please sign in to comment.