Bug 1821726 - convert2rhel failed when converts from CentOS 7.7 (1908) to RHEL 7.7 with "error: Failed dependencies:"
Summary: convert2rhel failed when converts from CentOS 7.7 (1908) to RHEL 7.7 with "er...
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: convert2rhel
Version: epel7
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Michal Bocek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1818077 1818088
TreeView+ depends on / blocked
 
Reported: 2020-04-07 13:17 UTC by XinhuaLi
Modified: 2021-03-16 16:15 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-03-16 16:15:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
error logs (26.30 KB, text/plain)
2020-04-10 05:27 UTC, XinhuaLi
no flags Details

Description XinhuaLi 2020-04-07 13:17:53 UTC
Description of problem:

convert2rhel failed when try to convert from CentOS 7.7 (1908) to RHEL 7.7 with "error: Failed dependencies: system-release is needed by kernel-3.10.0-1062.el7.x86_64"


Version-Release number of the following components:
  CentOS Linux release 7.7.1908 (Core)
  Red Hat Enterprise Linux 7.7
  convert2rhel.noarch 0:0.9-1.el7 
  
  
How reproducible:
Steps to Reproduce:
1. Install CentOS Linux release 7.7.1908 (Core) with "Server with GUI" 
2. Install convert2rhel 
   # rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
3. Use RHEL 7.7 ISO as local YUM repository 
4. execute command 
   #convert2rhel --disable-submgr --disablerepo "*" --enablerepo convert2rhel77 --debug

Actual results:
   [04/07/2020 14:18:03] CRITICAL - Unable to replace kernel package: warning: /tmp/convert2rhel/kernel-3.10.0-1062.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
error: Failed dependencies:
	system-release is needed by kernel-3.10.0-1062.el7.x86_64

[04/07/2020 14:18:03] DEBUG - Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/convert2rhel/main.py", line 86, in main
    post_ponr_conversion()
  File "/usr/lib/python2.7/site-packages/convert2rhel/main.py", line 189, in post_ponr_conversion
    pkghandler.preserve_only_rhel_kernel()
  File "/usr/lib/python2.7/site-packages/convert2rhel/pkghandler.py", line 353, in preserve_only_rhel_kernel
    needs_update = install_rhel_kernel()
  File "/usr/lib/python2.7/site-packages/convert2rhel/pkghandler.py", line 389, in install_rhel_kernel
    handle_no_newer_rhel_kernel_available()
  File "/usr/lib/python2.7/site-packages/convert2rhel/pkghandler.py", line 411, in handle_no_newer_rhel_kernel_available
    replace_non_rhel_installed_kernel(installed[0])
  File "/usr/lib/python2.7/site-packages/convert2rhel/pkghandler.py", line 465, in replace_non_rhel_installed_kernel
    loggerinst.critical("Unable to replace kernel package: %s" % output)
  File "/usr/lib/python2.7/site-packages/convert2rhel/logger.py", line 100, in critical
    sys.exit(1)
SystemExit: 1

Expected results:
   convert from CentOS 7.7 to RHEL 7.7 correctly 


Additional info:
Assuming:
  It would be related to "install_release_pkg()" which provided by "redhatrelease.py". It seems that "pkg_path" which returned by "os.path.join" is "/usr/share/convert2rhel/redhat-release/Server/"; actually, it does not exists.

----------------
def install_release_pkg():
    """Install RHEL release package, e.g. redhat-release-server."""
    loggerinst = logging.getLogger(__name__)
    loggerinst.info("Installing %s package" % get_release_pkg_name())

    system_release_file.remove()
    pkg_path = os.path.join(utils.data_dir, "redhat-release",
                            tool_opts.variant, "redhat-release-*")

    success = utils.install_pkgs(glob.glob(pkg_path))
-----------------

You can please check the detail via the logs attached

Comment 1 XinhuaLi 2020-04-08 16:00:10 UTC
As for this code section , we should download "system-release" (redhat-release-server) also , and then install it first before installing Kernel.
======================================================================
def replace_non_rhel_installed_kernel(version):
...
    pkg = "kernel-%s" % version

    ret_code = utils.download_pkg(
        pkg=pkg, dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,
        enablerepo=tool_opts.enablerepo)
    if ret_code != 0:
        loggerinst.critical("Unable to download %s from RHEL repository" % pkg)
        return

    loggerinst.info("Replacing %s %s with RHEL kernel with the same NEVRA ... " % (system_info.name, pkg))
    output, ret_code = utils.run_subprocess(
        'rpm -i --force --replacepkgs %s*' % os.path.join(utils.tmp_dir, pkg),
        print_output=False)
======================================================

Because from CentOS 6 and CentOS 7 , Kernel has different requirements. So for the same function "replace_non_rhel_installed_kernel", it can work well in CentOS6 , but it cannot work in CentOS7. 

For CentOS6.10 
======================================================
rpmlib(VersionedDependencies) <= 3.0.3-1
fileutils  
module-init-tools  
initscripts >= 8.11.1-1
kernel-firmware >= 2.6.32-754.el6
grubby >= 7.0.4-1
dracut-kernel >= 004-408.el6
/sbin/new-kernel-pkg  
/sbin/new-kernel-pkg  
/bin/sh  
/bin/sh  
/bin/sh  
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1
==============================================

For CentOS 7.7- Kernel package requires "system-release"
==============================================
fileutils
module-init-tools >= 3.16-2
initscripts >= 8.11.1-1
grubby >= 8.28-2
dracut >= 033-502
linux-firmware >= 20190429-72
/usr/sbin/new-kernel-pkg
system-release
/usr/sbin/new-kernel-pkg
/bin/sh
/bin/sh
/bin/sh
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1
fileutils
module-init-tools >= 3.16-2
initscripts >= 8.11.1-1
grubby >= 8.28-2
dracut >= 033-502
linux-firmware >= 20190429-72
/usr/sbin/new-kernel-pkg
system-release
/usr/sbin/new-kernel-pkg
/bin/sh
/bin/sh
/bin/sh
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1
fileutils
module-init-tools >= 3.16-2
initscripts >= 8.11.1-1
grubby >= 8.28-2
dracut >= 033-502
linux-firmware >= 20190429-72
/usr/sbin/new-kernel-pkg
system-release
/usr/sbin/new-kernel-pkg
/bin/sh
/bin/sh
/bin/sh
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadIsXz) <= 5.2-1
==============================================

As a quick workaround, i updated the function "replace_non_rhel_installed_kernel"as below; and the convert2rhel from CentOS7.7 to RHEL7.7 works well now. BTW, i am using CentOS7.7 "minimal" install as debug host.
=============================================
    pkg = "kernel-%s" % version
    pkg1 = "redhat-release-server.x86_64"
    ret_code = utils.download_pkg(
        pkg=pkg, dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,
        enablerepo=tool_opts.enablerepo)

    utils.download_pkg(
        pkg=pkg1, dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,
        enablerepo=tool_opts.enablerepo)
    if ret_code != 0:
        loggerinst.critical("Unable to download %s from RHEL repository" % pkg)
        return
    print("====================================================")
    print(utils.tmp_dir)
    print(pkg)
    print(pkg1)
    print("====================================================")
    loggerinst.info("Replacing %s %s with RHEL kernel with the same NEVRA ... " % (system_info.name, pkg))
    output, ret_code = utils.run_subprocess(
        'rpm -i --force --replacepkgs %s*' % os.path.join(utils.tmp_dir, "redhat-release-server*"),
        print_output=False)
    output, ret_code = utils.run_subprocess(
        'rpm -i --force --replacepkgs %s*' % os.path.join(utils.tmp_dir, pkg),
        print_output=False)
=============================================

============== logs ============================
[04/08/2020 23:56:12] TASK - [Convert: List remaining non-Red Hat packages] *********************
Listing packages not signed by Red Hat
The following packages were left unchanged.
Package                                        Vendor          Repository
-------                                        ------          ----------
yum-plugin-fastestmirror-1.1.31-52.el7.noarch  CentOS          anaconda
epel-release-7-12.noarch                       Fedora Project  N/A
convert2rhel-0.9-1.el7.noarch                  Fedora Project  epel


[04/08/2020 23:56:12] TASK - [Final: Non-interactive mode] **************************************
For the non-interactive use of the tool, run the following command:
convert2rhel --disable-submgr  --disablerepo=*  --enablerepo=rhel-7-server-rpms  -v Server -y


WARNING - In order to boot the RHEL kernel, restart of the system is needed.
=============================================

Comment 2 XinhuaLi 2020-04-10 05:27:49 UTC
Created attachment 1677714 [details]
error logs

Comment 3 XinhuaLi 2020-04-12 14:53:24 UTC
To fix the dependency issues during converting from CentOS7.7-RHEL7.7, I am using this patch as my quick workaround, just for your reference.
-----------------------------
  --- convert2rhel-0.9-rhel7/convert2rhel/pkghandler.py	2019-12-14 06:00:58.000000000 +0800
+++ convert2rhel-0.9-rhel7_Sam/convert2rhel/pkghandler.py	2020-04-12 22:48:17.377902488 +0800
@@ -311,8 +311,7 @@ def remove_blacklisted_pkgs():
     loggerinst.info("\n")
     print_pkg_info(installed_blacklisted_pkgs)
     utils.ask_to_continue()
-    utils.remove_pkgs([get_pkg_nvra(pkg)
-                      for pkg in installed_blacklisted_pkgs])
+    utils.remove_pkgs([get_pkg_nvra(pkg) for pkg in installed_blacklisted_pkgs])
     return
 
 
@@ -449,7 +448,25 @@ def replace_non_rhel_installed_kernel(ve
     utils.ask_to_continue()
 
     pkg = "kernel-%s" % version
+    ret_code = utils.run_subprocess('yum remove -y kmod-kvdo',print_output=False)
+    ret_code = utils.run_subprocess('yum remove -y libreport',print_output=False)
+    #ret_code = utils.run_subprocess('yum remove -y abrt',print_output=False)
+    for pkgname in set(system_info.pkg_blacklist):
+        pkgname.replace("centos", "redhat")
+        print(pkgname.replace("centos","rhel"))
+        utils.download_pkg( pkg=pkgname.replace("centos", "redhat"), dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,enablerepo=tool_opts.enablerepo)
+        ret_code = utils.run_subprocess('rpm -i --force --replacepkgs %s*' % os.path.join(utils.tmp_dir, 
+pkgname.replace("centos", "redhat")),print_output=False)
+
+    for pkgname1 in set(system_info.pkg_blacklist):
+        pkgname1.replace("centos", "rhel")
+        print(pkgname1)
+        print(pkgname1.replace("centos","rhel"))
+        utils.download_pkg( pkg=pkgname1.replace("centos","rhel"), dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,enablerepo=tool_opts.enablerepo)
+        ret_code = utils.run_subprocess('rpm -i --force --replacepkgs %s*' % os.path.join(utils.tmp_dir, 
+pkgname1.replace("centos", "redhat")),print_output=False)
 
+    #sys.exit()   
     ret_code = utils.download_pkg(
         pkg=pkg, dest=utils.tmp_dir, disablerepo=tool_opts.disablerepo,
         enablerepo=tool_opts.enablerepo)
-----------------------------

Regards,
Sam

Comment 4 Michal Bocek 2020-05-05 18:17:51 UTC
Hi Sam, thanks for the report. I'll try that and I'll let you know.

Comment 5 Michal Bocek 2020-08-17 11:43:52 UTC
We're working on a fix in upstream: https://github.com/oamg/convert2rhel/pull/70

Comment 6 Michal Bocek 2021-03-16 16:15:08 UTC
Resolved by https://github.com/oamg/convert2rhel/pull/182.


Note You need to log in before you can comment on or make changes to this bug.