Skip to content

Commit

Permalink
[RHELC-1497, RHELC-1499] Drop internet connection check and its depen…
Browse files Browse the repository at this point in the history
…dencies (oamg#1181)

* Drop internet connection check and its dependencies

In this commit, we are dropping the internet connection check and its
dependencies as well.

Some of them are not necessary, as we really want to use the system
repos backed up during the conversion, and not some hardcoded
repositories that we provide.

Historically, we used that for eus conversions, but right now it is not
necessary anymore.

The internet connection check brought a lot of difficulties in the past
and several bug reports. With this in mind, we decided to drop the
check, and assume the system will be configured in the correct way.

* Remove unused internet connection check tests

* Drop fixtures from pytest.ini

* Remove reposdir from is_loaded_kernel_latest action

At the point of execution, we don't have any repositories backed up, so
we don't need to try to use the reposdir.

* Check if reposdir is empty or does not exist

In case it is empty or does not exist, we should just not pass it to the
download_pkg function. This will prevent the download to fail because we
are using something that does not exist.

* Update convert2rhel/actions/system_checks/is_loaded_kernel_latest.py

* Remove hardcoded centos8 repos from "remove_repositories" fixture

The hardcoded repos are being removed in this PR

---------

Co-authored-by: Martin 'kokesak' Litwora <[email protected]>
  • Loading branch information
r0x0d and kokesak authored Apr 29, 2024
1 parent 8141cef commit 018c1f9
Show file tree
Hide file tree
Showing 33 changed files with 89 additions and 697 deletions.
7 changes: 2 additions & 5 deletions convert2rhel/actions/pre_ponr_changes/handle_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@

__metaclass__ = type

import hashlib
import logging
import os

from convert2rhel import actions, pkghandler, utils
from convert2rhel.backup import BACKUP_DIR, backup_control
from convert2rhel.backup import backup_control, get_backedup_system_repos
from convert2rhel.backup.packages import RestorablePackage
from convert2rhel.repo import DEFAULT_YUM_REPOFILE_DIR
from convert2rhel.systeminfo import system_info


Expand Down Expand Up @@ -119,7 +116,7 @@ def run(self):
# - the suddenly enabled RHEL repos cause a package backup failure
# Since the MD5 checksum of original path is used in backup path to avoid
# conflicts in backup folder, preparing the path is needed.
backedup_reposdir = os.path.join(BACKUP_DIR, hashlib.md5(DEFAULT_YUM_REPOFILE_DIR.encode()).hexdigest())
backedup_reposdir = get_backedup_system_repos()
backup_control.push(RestorablePackage(pkgs=pkghandler.get_pkg_nevras(all_pkgs), reposdir=backedup_reposdir))

logger.info("\nRemoving special packages from the system.")
Expand Down
11 changes: 0 additions & 11 deletions convert2rhel/actions/system_checks/convert2rhel_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,6 @@ def run(self):

super(Convert2rhelLatest, self).run()

if not system_info.has_internet_access:
description = "Did not perform the check because no internet connection has been detected."
logger.warning(description)
self.add_message(
level="WARNING",
id="CONVERT2RHEL_LATEST_CHECK_SKIP_NO_INTERNET",
title="Did not perform convert2rhel latest version check",
description=description,
)
return

repo_dir = tempfile.mkdtemp(prefix="convert2rhel_repo.", dir=utils.TMP_DIR)
repo_path = os.path.join(repo_dir, "convert2rhel.repo")
utils.store_content_to_file(filename=repo_path, content=CONVERT2RHEL_REPO_CONTENT)
Expand Down
30 changes: 4 additions & 26 deletions convert2rhel/actions/system_checks/is_loaded_kernel_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from convert2rhel import actions
from convert2rhel.pkghandler import compare_package_versions
from convert2rhel.repo import get_hardcoded_repofiles_dir
from convert2rhel.systeminfo import system_info
from convert2rhel.utils import run_subprocess

Expand All @@ -30,6 +29,7 @@

class IsLoadedKernelLatest(actions.Action):
id = "IS_LOADED_KERNEL_LATEST"

# disabling here as some of the return statements would be raised as exceptions in normal code
# but we don't do that in an Action class
def run(self): # pylint: disable= too-many-return-statements
Expand All @@ -52,23 +52,6 @@ def run(self): # pylint: disable= too-many-return-statements
"C2R\\t%{BUILDTIME}\\t%{VERSION}-%{RELEASE}\\t%{REPOID}",
]

reposdir = get_hardcoded_repofiles_dir()
if reposdir and not system_info.has_internet_access:
logger.warning("Did not perform the check as no internet connection has been detected.")
self.add_message(
level="WARNING",
id="IS_LOADED_KERNEL_LATEST_CHECK_SKIP",
title="Did not perform the is loaded kernel latest check",
description="Did not perform the check as no internet connection has been detected.",
)
return

# If the reposdir variable is not empty, meaning that it detected the
# hardcoded repofiles, we should use that
# instead of the system repositories located under /etc/yum.repos.d
if reposdir:
cmd.append("--setopt=reposdir=%s" % reposdir)

# For Oracle/CentOS Linux 8 the `kernel` is just a meta package, instead,
# we check for `kernel-core`. But 7 releases, the correct way to check is
# using `kernel`.
Expand Down Expand Up @@ -181,20 +164,15 @@ def run(self): # pylint: disable= too-many-return-statements
return

if match != 0:
repos_message = (
"in the enabled system repositories"
if not reposdir
else "in repositories defined in the %s folder" % reposdir
)
self.set_result(
level="OVERRIDABLE",
id="INVALID_KERNEL_VERSION",
title="Invalid kernel version detected",
description="The loaded kernel version mismatch the latest one available %s" % repos_message,
description="The loaded kernel version mismatch the latest one available in system repositories",
diagnosis=(
"The version of the loaded kernel is different from the latest version %s.\n"
"The version of the loaded kernel is different from the latest version in system repositories. \n"
" Latest kernel version available in %s: %s\n"
" Loaded kernel version: %s" % (repos_message, repoid, latest_kernel, loaded_kernel)
" Loaded kernel version: %s" % (repoid, latest_kernel, loaded_kernel)
),
remediations=(
"To proceed with the conversion, update the kernel version by executing the following step:\n\n"
Expand Down
20 changes: 3 additions & 17 deletions convert2rhel/actions/system_checks/package_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import os

from convert2rhel import actions, pkgmanager, utils
from convert2rhel.backup import get_backedup_system_repos
from convert2rhel.pkghandler import get_total_packages_to_update
from convert2rhel.repo import get_hardcoded_repofiles_dir
from convert2rhel.systeminfo import system_info


Expand Down Expand Up @@ -52,17 +52,7 @@ def run(self):
)
return

reposdir = get_hardcoded_repofiles_dir()

if reposdir and not system_info.has_internet_access:
logger.warning("Did not perform the check as no internet connection has been detected.")
self.add_message(
level="WARNING",
id="PACKAGE_UPDATES_CHECK_SKIP_NO_INTERNET",
title="Did not perform the package updates check",
description="Did not perform the check as no internet connection has been detected.",
)
return
reposdir = get_backedup_system_repos()

try:
packages_to_update = sorted(get_total_packages_to_update(reposdir=reposdir))
Expand Down Expand Up @@ -91,11 +81,7 @@ def run(self):
return

if len(packages_to_update) > 0:
repos_message = (
"on the enabled system repositories"
if not reposdir
else "on repositories defined in the %s folder" % reposdir
)
repos_message = "on repositories defined in the %s folder" % reposdir
package_not_up_to_date_skip = os.environ.get("CONVERT2RHEL_OUTDATED_PACKAGE_CHECK_SKIP", None)
package_not_up_to_date_error_message = (
"The system has %s package(s) not updated based %s.\n"
Expand Down
11 changes: 11 additions & 0 deletions convert2rhel/backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
__metaclass__ = type

import abc
import hashlib
import logging
import os

import six

from convert2rhel.repo import DEFAULT_YUM_REPOFILE_DIR
from convert2rhel.utils import TMP_DIR


Expand All @@ -32,6 +34,15 @@
loggerinst = logging.getLogger(__name__)


def get_backedup_system_repos():
"""Get the backedup system repos path inside our backup structure.
:returns str: A formatted backedup path for system repositories
"""
backedup_reposdir = os.path.join(BACKUP_DIR, hashlib.md5(DEFAULT_YUM_REPOFILE_DIR.encode()).hexdigest())
return backedup_reposdir


class BackupController:
"""
Controls backup and restore for all restorable types.
Expand Down
45 changes: 25 additions & 20 deletions convert2rhel/backup/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

# Fine to import call_yum_cmd for now, but we really should figure out a way to
# split this out.
from convert2rhel.repo import get_hardcoded_repofiles_dir
from convert2rhel.systeminfo import system_info
from convert2rhel.utils import files

Expand Down Expand Up @@ -130,28 +129,34 @@ def enable(self):
if self.enabled:
return

if not os.path.isdir(BACKUP_DIR):
loggerinst.warning("Can't access %s" % BACKUP_DIR)
return

loggerinst.info("Backing up the packages: %s." % ",".join(self.pkgs))
if os.path.isdir(BACKUP_DIR):
if system_info.eus_system and system_info.id == "centos":
self.reposdir = get_hardcoded_repofiles_dir()

if self.reposdir:
loggerinst.debug("Using repository files stored in %s." % self.reposdir)

for pkg in self.pkgs:
self._backedup_pkgs_paths.append(
utils.download_pkg(
pkg=pkg,
dest=BACKUP_DIR,
set_releasever=self.set_releasever,
custom_releasever=self.custom_releasever,
varsdir=self.varsdir,
reposdir=self.reposdir,
)
loggerinst.debug("Using repository files stored in %s." % self.reposdir)

if self.reposdir:
# If nothing is inside the directory, or it does not exist, let's
# just not use it to download the packages.
if len(os.listdir(self.reposdir)) == 0 or not os.path.exists(self.reposdir):
loggerinst.info("The repository directory %s seems to be empty or non-existent.")
self.reposdir = None

for pkg in self.pkgs:
self._backedup_pkgs_paths.append(
utils.download_pkg(
pkg=pkg,
dest=BACKUP_DIR,
set_releasever=self.set_releasever,
custom_releasever=self.custom_releasever,
varsdir=self.varsdir,
reposdir=self.reposdir,
)
else:
loggerinst.warning("Can't access %s" % BACKUP_DIR)
)

# TODO(r0x0d): Maybe we want to set the enabled value only when we
# backup something?
# Set the enabled value
super(RestorablePackage, self).enable()

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions convert2rhel/data/8/x86_64/repos/centos-8.5/CentOS-Linux-Plus.repo

This file was deleted.

This file was deleted.

Loading

0 comments on commit 018c1f9

Please sign in to comment.