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-1434] Use public CDN instead of paywalled CDN and FTP #1123

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bocekm
Copy link
Member

@bocekm bocekm commented Mar 1, 2024

The convert2rhel repos moved from https://cdn.redhat.com/ to https://cdn-public.redhat.com/.
The convert2rhel repofiles moved from https://ftp.redhat.com/ to https://cdn-public.redhat.com/.

The https://cdn-public.redhat.com/ does not use a self-signed SSL cert as the https://cdn.redhat.com/ does. So we can drop handling the redhat-uep.pem certificate.

Jira Issues: RHELC-1434

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

Depends on

@bocekm bocekm added the tests-run-tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`. label Mar 1, 2024
@bocekm bocekm requested a review from danmyway March 1, 2024 22:34
@has-bot
Copy link
Member

has-bot commented Mar 1, 2024

/packit test --labels tier0


Comment generated by an automation.

@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch from 370bfa5 to eb95f7d Compare March 1, 2024 22:59
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (3f6ce10) to head (00d0e4a).

Current head 00d0e4a differs from pull request most recent head 886e206

Please upload reports for the commit 886e206 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1123      +/-   ##
==========================================
- Coverage   95.74%   95.52%   -0.22%     
==========================================
  Files          55       54       -1     
  Lines        4752     4720      -32     
  Branches      834      832       -2     
==========================================
- Hits         4550     4509      -41     
- Misses        116      127      +11     
+ Partials       86       84       -2     
Flag Coverage Δ
centos-linux-7 90.67% <100.00%> (-0.26%) ⬇️
centos-linux-8 91.61% <100.00%> (-0.25%) ⬇️
centos-linux-9 91.67% <100.00%> (-0.25%) ⬇️

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.

@r0x0d r0x0d force-pushed the use-public-cdn-instead-of-ftp branch from eb95f7d to 429ff7b Compare March 4, 2024 12:16
.pre-commit-config.yaml Outdated Show resolved Hide resolved
convert2rhel/actions/system_checks/convert2rhel_latest.py Outdated Show resolved Hide resolved
@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch from 429ff7b to fb4bc8f Compare March 5, 2024 20:45
@bocekm bocekm marked this pull request as draft March 5, 2024 22:14
@bocekm
Copy link
Member Author

bocekm commented Mar 5, 2024

I've updated the PR to download the official convert2rhel repofile instead of generating it. I'll be adding unit tests later on.

@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch 2 times, most recently from 846ce59 to e00f418 Compare May 20, 2024 11:35
@bocekm bocekm marked this pull request as ready for review May 20, 2024 11:35
@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch 4 times, most recently from 3f783af to 115278f Compare May 20, 2024 22:00
@bocekm
Copy link
Member Author

bocekm commented May 20, 2024

The PR is ready for review and will be ready for testing after #1164 is merged (it introduces repo.download_repofile and repo.write_temporary_repofile).

@bookwar
Copy link
Contributor

bookwar commented May 21, 2024

/packit test --labels tier0

@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch 3 times, most recently from fe9f4ff to 9faaaf0 Compare May 21, 2024 13:24
Comment on lines -78 to -85
# Note: This is safe because we're creating in utils.TMP_DIR which is hardcoded to
# /var/lib/convert2rhel which does not have any world-writable directory components.
files.mkdir_p(repo_dir)

try:
raw_output_convert2rhel_versions, return_code = utils.run_subprocess(cmd, print_output=False)
finally:
shutil.rmtree(repo_dir)
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI for reviewers: No need to create and then remove a temporary directory here - its creation is handled by repo.write_temporary_repofile() and its deletion by utils.remove_tmp_dir().

Comment on lines 229 to 237
if system_info.version.major not in C2R_REPOFILE_URLS:
self.add_message(
level="WARNING",
id="CONVERT2RHEL_LATEST_CHECK_UNEXPECTED_SYS_VERSION",
title="Did not perform convert2rhel latest version check",
description="Checking whether the installed convert2rhel package is of the latest available version was"
" skipped due to an unexpected system version",
diagnosis="Expected system versions: %s. Detected major version: %s"
% (", ".join(str(x) for x in C2R_REPOFILE_URLS), system_info.version.major),
)
return None
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI for reviewers: This is likely too much of a defensive programming. I can't foresee a scenario in which a customer would hit this. If anyone thinks this should better be removed, I can certainly do that.

Copy link
Member

Choose a reason for hiding this comment

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

I think, we halt the execution way before reaching any of this in case of the user having a system version that does not correspond to this, right?

I don't mind having this defensive code, so I would leave it here

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if the system major version is anything other than 7 or 8, convert2rhel stops almost immediately for not having a distro config available.
When we start testing and shipping convert2rhel for RHEL 9, we will need to add a repofile to the C2R_REPOFILE_URLS mapping https://github.com/oamg/convert2rhel/pull/1123/files#diff-7e310f649f5ad232ee8a3ce27055e178d7303046cf546ef0dc6f4ea208db8589R32. So this report message will likely appear during development and will prompt us to add the RHEL 9 URL.
I'm going to keep the code then.

Comment on lines -8 to -28
@pytest.fixture(scope="function")
def convert2rhel_repo(shell):
assert shell("rpm -qi subscription-manager").returncode == 0
# The following repository requires the redhat-uep.pem certificate.
# convert2rhel will try accessing the repo and during the test we run the convert2rhel twice
# making sure that the rollback of the first run correctly reinstalled the certificate
# when installing subscription-manager-rhsm-certificates.
c2r_repo = "/etc/yum.repos.d/convert2rhel.repo"

assert (
shell(
f"curl -o {c2r_repo} https://cdn-public.redhat.com/content/public/repofiles/convert2rhel-for-rhel-8-x86_64.repo"
).returncode
== 0
)
assert os.path.exists(c2r_repo) is True

yield

assert shell(f"rm -f {c2r_repo}")
assert os.path.exists(c2r_repo) is False
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI for reviewers: This fixture was needed just for one of the cases tested by the below test_sub_man_rollback test. This case is no longer relevant because the convert2rhel repository no longer requires the /etc/rhsm/ca/redhat-uep.pem certificate to be in place.

@bocekm bocekm added the enhancement New feature or request label May 22, 2024
@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch 2 times, most recently from 487763d to 1284e29 Compare May 22, 2024 09:20
@bocekm
Copy link
Member Author

bocekm commented May 22, 2024

I'm working on the codecov failure/finding.

@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch from 1284e29 to 85e86d9 Compare May 22, 2024 14:29
@Venefilyn Venefilyn dismissed their stale review May 22, 2024 15:25

Review addressed

Copy link
Contributor

@pr-watson pr-watson left a comment

Choose a reason for hiding this comment

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

Looks good just added a comment to add a "." to the end of the description for CONVERT2RHEL_LATEST_CHECK_UNEXPECTED_SYS_VERSION. There's also no unit test for this Warning but I think it can be added later

convert2rhel/actions/system_checks/convert2rhel_latest.py Outdated Show resolved Hide resolved
convert2rhel/actions/system_checks/convert2rhel_latest.py Outdated Show resolved Hide resolved
@r0x0d
Copy link
Member

r0x0d commented May 22, 2024

/packit test --labels tier0

@r0x0d r0x0d force-pushed the use-public-cdn-instead-of-ftp branch from 85e86d9 to b4bb914 Compare May 22, 2024 17:51
@r0x0d
Copy link
Member

r0x0d commented May 22, 2024

/packit test --labels tier0

Comment on lines -69 to -70
"--disablerepo=*",
"--enablerepo=convert2rhel",
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI for reviewers: The temp directory used for the convert2rhel repofile is created only for the
repofile and nothing else. Because we tell repoquery to look only at that
directory we don't need to specify a repoid to use - repoquery will simply use
the repoid in the downloaded repofile.

@r0x0d
Copy link
Member

r0x0d commented May 23, 2024

/packit test --labels tier0

id_="CREATE_TMP_DIR_FOR_REPOFILES_FAILED",
title="Failed to create a temporary directory",
description="Failed to create a temporary directory for storing a repository file under %s.\n"
"Reason: %s" % (TMP_DIR, str(err)),
Copy link
Member

@hosekadam hosekadam May 23, 2024

Choose a reason for hiding this comment

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

Suggested change
"Reason: %s" % (TMP_DIR, str(err)),
diagnosis="Reason: %s" % (TMP_DIR, str(err)),

Shouldn't this be diagnosis? (and for the exception above too)

bocekm and others added 5 commits May 23, 2024 16:15
The convert2rhel repos moved from https://cdn.redhat.com/ to
https://cdn-public.redhat.com/.
The convert2rhel repofiles moved from https://ftp.redhat.com/ to
https://cdn-public.redhat.com/.

The https://cdn-public.redhat.com/ does not use a self-signed SSL cert
as the https://cdn.redhat.com/ does. So we can drop handling the
redhat-uep.pem certificate.
It's safer to use the official convert2rhel repofile that is to be used
by customers instead of generating it as that way any changes done it
don't need further convert2rhel code updates.
Co-authored-by: Preston Watson <prwatson@redhat.com>
The temp directory used for the convert2rhel repofile is created only for the
repofile and nothing else. Because we tell repoquery to look only at that
directory we don't need to specify a repoid to use - repoquery will simply use
the repoid in the downloaded repofile.
To better fit what the real meaning of the messages and the purpose of a
method.

More specifically:
- the write_temporary_repofile() function is not just for storing a
  convert2rhel repofil
- the _get_convert2rhel_repofile_path() method does more than just
  getting a path; its main purpose is downloading a repofile
@bocekm bocekm force-pushed the use-public-cdn-instead-of-ftp branch from 00d0e4a to 886e206 Compare May 23, 2024 14:15
@bocekm
Copy link
Member Author

bocekm commented May 23, 2024

Rebased to include a fix to a regression introduced in #1238.

@bocekm
Copy link
Member Author

bocekm commented May 23, 2024

/packit test --labels tier0

2 similar comments
@r0x0d
Copy link
Member

r0x0d commented May 23, 2024

/packit test --labels tier0

@r0x0d
Copy link
Member

r0x0d commented May 23, 2024

/packit test --labels tier0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tests-run-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.

None yet

7 participants