Skip to content

Commit 51eebe1

Browse files
prilrclaude
authored andcommitted
CLOS-4332: Exclude elevate repos from "unknown to Leapp" report
The setuptargetrepos actor produces SkippedRepositories for repoids that are enabled and used on the source system but have no entry in the combined repomap. CheckSkippedRepositories then renders them as the "Some enabled RPM repositories are unknown to Leapp" report. ELevate's own repository (cloudlinux-elevate, installed by the elevate-release package) is always one of those: it carries leapp, leapp-data-cloudlinux, and similar tooling that is intentionally left unupgraded, so flagging it as a coverage gap is a false positive. A previous fix (commit da609c6) added a "elevate" filter to skip these repoids, but it was lost during the v0.19.0 vendor-mechanism rebase (70f49e0), which restored the unfiltered upstream expression. Restore the filter as a dedicated helper and pin it with regression tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 59b7894 commit 51eebe1

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

repos/system_upgrade/common/actors/setuptargetrepos/libraries/setuptargetrepos.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ def _get_mapped_repoids(repomap, src_repoids):
7777
return mapped_repoids
7878

7979

80+
def _get_skipped_repoids(enabled_repoids, mapped_repoids, used_repoids):
81+
"""
82+
Return the set of source-system repoids whose packages may be left behind.
83+
84+
Excludes elevate repositories: their packages are leapp tooling itself,
85+
intentionally not carried into the target system, so reporting them as
86+
"unknown to Leapp" is a false positive.
87+
"""
88+
skipped = enabled_repoids & used_repoids - mapped_repoids
89+
return {repoid for repoid in skipped if "elevate" not in repoid}
90+
91+
8092
def _get_vendor_custom_repos(enabled_repos, mapping_list):
8193
# Look at what source repos from the vendor mapping were enabled.
8294
# If any of them are in beta, include vendor's custom repos in the list.
@@ -200,7 +212,9 @@ def process():
200212

201213
# produce message about skipped repositories
202214
enabled_repoids_with_mapping = _get_mapped_repoids(repomap, enabled_repoids)
203-
skipped_repoids = enabled_repoids & set(used_repoids_dict.keys()) - enabled_repoids_with_mapping
215+
skipped_repoids = _get_skipped_repoids(
216+
enabled_repoids, enabled_repoids_with_mapping, set(used_repoids_dict.keys())
217+
)
204218
if skipped_repoids:
205219
pkgs = set()
206220
for repo in skipped_repoids:

repos/system_upgrade/common/actors/setuptargetrepos/tests/test_setuptargetrepos.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
RepositoryData,
1717
RepositoryFile,
1818
RPM,
19-
TargetRepositories
19+
SkippedRepositories,
20+
TargetRepositories,
21+
UsedRepositories,
22+
UsedRepository
2023
)
2124

2225
RH_PACKAGER = 'Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>'
@@ -194,3 +197,63 @@ def test_repos_mapping(monkeypatch):
194197
expected_rhel_repoids = {'rhel-8-for-x86_64-baseos-htb-rpms', 'rhel-8-for-x86_64-appstream-htb-rpms',
195198
'rhel-8-for-x86_64-satellite-extras-rpms'}
196199
assert produced_rhel_repoids == expected_rhel_repoids
200+
201+
202+
def test_skipped_repos_excludes_elevate(monkeypatch):
203+
"""
204+
The "Some enabled RPM repositories are unknown to Leapp" report must not
205+
flag elevate repos: their packages are leapp tooling itself, intentionally
206+
not upgraded. A regression here drops the filter and re-introduces the
207+
false positive (CLOS-4332).
208+
"""
209+
repos_data = [
210+
RepositoryData(repoid='cloudlinux-elevate', name='CloudLinux ELevate', enabled=True),
211+
RepositoryData(repoid='unmapped-third-party', name='Unmapped Third Party', enabled=True),
212+
]
213+
facts = RepositoriesFacts(
214+
repositories=[RepositoryFile(file='/etc/yum.repos.d/test.repo', data=repos_data)]
215+
)
216+
used = UsedRepositories(repositories=[
217+
UsedRepository(repository='cloudlinux-elevate', packages=['leapp', 'python2-leapp']),
218+
UsedRepository(repository='unmapped-third-party', packages=['something']),
219+
])
220+
repomap = RepositoriesMapping(mapping=[], repositories=[])
221+
222+
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=[facts, used, repomap]))
223+
monkeypatch.setattr(api, 'produce', produce_mocked())
224+
225+
setuptargetrepos.process()
226+
227+
skipped = [m for m in api.produce.model_instances if isinstance(m, SkippedRepositories)]
228+
assert len(skipped) == 1
229+
assert skipped[0].repos == ['unmapped-third-party']
230+
# Packages from elevate repos must not leak into the report either.
231+
assert 'leapp' not in skipped[0].packages
232+
assert 'python2-leapp' not in skipped[0].packages
233+
234+
235+
def test_skipped_repos_empty_when_only_elevate(monkeypatch):
236+
"""
237+
If the only unmapped+used repos are elevate repos, no SkippedRepositories
238+
message should be produced - the report would be entirely false-positive.
239+
"""
240+
repos_data = [
241+
RepositoryData(repoid='cloudlinux-elevate', name='CloudLinux ELevate', enabled=True),
242+
RepositoryData(repoid='cloudlinux8-elevate', name='CloudLinux 8 ELevate', enabled=True),
243+
]
244+
facts = RepositoriesFacts(
245+
repositories=[RepositoryFile(file='/etc/yum.repos.d/test.repo', data=repos_data)]
246+
)
247+
used = UsedRepositories(repositories=[
248+
UsedRepository(repository='cloudlinux-elevate', packages=['leapp']),
249+
UsedRepository(repository='cloudlinux8-elevate', packages=['leapp-data-cloudlinux']),
250+
])
251+
repomap = RepositoriesMapping(mapping=[], repositories=[])
252+
253+
monkeypatch.setattr(api, 'current_actor', CurrentActorMocked(msgs=[facts, used, repomap]))
254+
monkeypatch.setattr(api, 'produce', produce_mocked())
255+
256+
setuptargetrepos.process()
257+
258+
skipped = [m for m in api.produce.model_instances if isinstance(m, SkippedRepositories)]
259+
assert skipped == []

0 commit comments

Comments
 (0)