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

Handle URL params for AptRepoFiles #3454

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

quba42
Copy link
Contributor

@quba42 quba42 commented Sep 11, 2024

This change allows 'AptRepoFiles' to handle URL parameters for "Components" and "Suites" giving it more flexibility rather than always using a fixed default value. If the URL supplied by Candlepin does not have any such URL parameters, then everything defaults back to the way it was before.

This change is needed to enable the following Katello feature: Katello/katello#11058

That being said, this change is fully backwards compatible and defines an interface that the Katello side PR will need to respect. The Katello PR is dependent on this PR, not the other way around.

This PR replaces the previous draft PR here: #3223

My apologies for the switch, the idea is to have both this and the Katello PR in the same hand, so I can better pursue the completion of both related PRs.

Copy link
Contributor

@ptoscano ptoscano left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, although I'm a bit puzzled why the existing PR was closed (especially since the source branches of the old PR and this one are in ATIX fork...); anyway, this applies what I said back in the old PR: I'm switching it to draft, until the changes in katello are actually merged.

@@ -461,19 +461,28 @@ def sections(self):

def fix_content(self, content):
# Luckily apt ignores all Fields it does not recognize
baseurl = content["baseurl"]
parsed_url = urlparse(unquote(content["baseurl"]))
Copy link
Contributor

Choose a reason for hiding this comment

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

is unquote() still needed? see the discussion on this in #3223

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least the Candlepin version available for Katello 4.13 (the latest supported release), currently Candlepin 4.4.14 is still affected. I have spent some time looking, but was not able to find any new information when or if Candlepin intends to go back to the old behavior. Given nothing has happened over several months, I can only assume it is not a major priority. The good news is that using unquote will work equally well for quoted and unquoted URLs. As a result I lean towards leaving it in, at least until there is any new information from Candlepin.

Copy link
Contributor Author

@quba42 quba42 Oct 15, 2024

Choose a reason for hiding this comment

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

It looks like that while some encoding issues in Candlepin were fixed, this does not appear to have changed that the baseurl used as part of these changes has its path part encoded. Not sure if this is intentional or another bug on Candlepin's part. The current state of these changes will work either way.

@@ -461,19 +461,28 @@ def sections(self):

def fix_content(self, content):
# Luckily apt ignores all Fields it does not recognize
baseurl = content["baseurl"]
parsed_url = urlparse(unquote(content["baseurl"]))
baseurl = parsed_url._replace(query="").geturl()
url_res = re.match(r"^https?://(?P<location>.*)$", baseurl)
Copy link
Contributor

Choose a reason for hiding this comment

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

TBH: if now baseurl is parsed as URL, then it'd be a good idea to replace this regexp to extract hostname/path/etc with the same urllib.parse APIs -- for example replacing the scheme to get the katello URL

no need to do it in the existing comment; either as additional commit on top of this, or as future PR/improvement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some trial and error I did add this change to the existing commit. Please let me know if I should separate it out again.

src/subscription_manager/repofile.py Outdated Show resolved Hide resolved
src/subscription_manager/repofile.py Outdated Show resolved Hide resolved
@ptoscano ptoscano marked this pull request as draft September 12, 2024 10:26
@quba42
Copy link
Contributor Author

quba42 commented Sep 12, 2024

I'm a bit puzzled why the existing PR was closed (especially since the source branches of the old PR and this one are in ATIX fork...);

The last time I adopted a previously opened PR, without opening a new PR, this created small frictions in communication (because it was less clear who was talking to whom). There were small annoyances like lack of ability to "resolve threads". So we decided to try re-opening this time around. Probably does not make a major difference. 😉

@quba42 quba42 force-pushed the handle_apt_repo_url_params branch 3 times, most recently from 6cf5ca0 to bb752ff Compare October 18, 2024 10:07
@quba42 quba42 marked this pull request as ready for review October 18, 2024 10:10
This change allows 'AptRepoFiles' to handle URL parameters
for "Components" and "Suites" giving it more flexibility
rather than always using a fixed default value.
@quba42
Copy link
Contributor Author

quba42 commented Oct 18, 2024

@ptoscano I have tried to answer your questions and implement the suggestions. Since the accompanying Katello change is now merged, I have undrafted the PR.

@quba42 quba42 requested a review from ptoscano October 18, 2024 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants