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

[RHELC-1225] Fix an exception when listing third-party packages with Epoch 2 #984

Merged
merged 3 commits into from
Nov 17, 2023

Conversation

jochapma
Copy link
Contributor

A bug processing output from the repoquery command caused packages with an Epoch equal to 2 to raise an exception in the third-party package listing task. This change fixes the processing.

Jira Issues: RHELC-1225

Checklist

  • PR has been tested manually in a VM (either author or reviewer)
  • Jira issue has been made public if possible
  • [RHELC-] is part of the PR title
  • GitHub label has been added to help with Release notes
  • PR title explains the change from the user's point of view
  • Code and tests are documented properly
  • The commits are squashed to as few commits as possible (without losing data)
  • When merged: Jira issue has been updated to Release Pending if relevant

@jochapma jochapma added kind/bug-fix A bug has been fixed tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`. labels Nov 15, 2023
@has-bot
Copy link
Member

has-bot commented Nov 15, 2023

/packit test --labels tier0


@oamg/conversions-qe please review results and provide ack.

@Venefilyn
Copy link
Member

Unit tests are failing but code if works seems good

Copy link

codecov bot commented Nov 17, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8a7b98c) 94.32% compared to head (35ca1e3) 94.32%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #984   +/-   ##
=======================================
  Coverage   94.32%   94.32%           
=======================================
  Files          47       47           
  Lines        4354     4355    +1     
  Branches      772      772           
=======================================
+ Hits         4107     4108    +1     
  Misses        172      172           
  Partials       75       75           
Flag Coverage Δ
centos-linux-7 89.27% <100.00%> (+<0.01%) ⬆️
centos-linux-8 90.33% <100.00%> (+<0.01%) ⬆️
centos-linux-9 90.39% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -706,8 +706,9 @@ def _get_package_repositories(pkgs):
repositories_mapping[package] = "N/A"
else:
for line in output:
if "C2R" in line:
split_output = line.lstrip("C2R ").split("&")
line = line.lstrip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we'll encounter this in the wild tbh, it's just something within our own tests, but doesn't hurt so let's leave it be for now

@Venefilyn
Copy link
Member

Simple and effective

>>> pkg = "C2R 2:eog-44.1-1.fc38.x86_64&updates"
>>> pkg.lstrip("C2R ").split("&")
[':eog-44.1-1.fc38.x86_64', 'updates']
>>> pkg[4:].split("&")
['2:eog-44.1-1.fc38.x86_64', 'updates']

@Venefilyn Venefilyn merged commit 1fc2966 into oamg:main Nov 17, 2023
17 of 49 checks passed
hosekadam pushed a commit to hosekadam/convert2rhel that referenced this pull request Nov 24, 2023
…Epoch 2 (oamg#984)

* Fix a bug processing repoquery output with an epoch 2 package.

* Strip any initial whitespace from repoquery output.

* Add unit test for Epoch 2 packages.
@pr-watson pr-watson mentioned this pull request Dec 8, 2023
@bocekm
Copy link
Member

bocekm commented Dec 12, 2023

@jochapma, out of curiosity, why was the code failing with the epoch being specifically 2? Wouldn't other epoch cause the issue as well?

@jochapma
Copy link
Contributor Author

@bocekm, we meant to strip off "C2R" from the left side of the string. Unfortunately, we were using lstrip(), which strips off all instances of any character in the string, so it removed C, 2, and R. So epoch 2 specifically got stripped off.

@bocekm
Copy link
Member

bocekm commented Dec 12, 2023

Ugh, that was a nasty bug indeed, I would have not thought that lstrip() has this behavior. Thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix A bug has been fixed tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants