RHEL7: "leapp preupgrade" fails with message "Failed to synchronize cache for repo"

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 7.9
    • leapp
    • proxy

Issue

  • leapp preupgrade fails with below error when system is registered to Red Hat customer portal using RHSM:

    Unable to install RHEL 8 userspace packages.
    'dnf', 'install', '-y', '--nogpgcheck', '--setopt=module_platform_id=platform:el8', '--setopt=keepcache=1', '--releasever', u'8.4', '--installroot', '/el8target', '--disablerepo', '*', '--enablerepo', u'rhel-8-for-x86_64-baseos-rpms', '--enablerepo', u'rhel-8-for-x86_64-appstream-rpms', 'dnf'] failed with exit code 1.
            Failed to synchronize cache for repo 'rhel-8-for-x86_64-appstream-rpms', ignoring this repo.
            Failed to synchronize cache for repo 'rhel-8-for-x86_64-baseos-rpms', ignoring this repo.
            Error: Unable to find a match: dnf
    

Resolution

  • If the system is registered to Satellite then refer

  • Check if the system is behind proxy. If yes then add proxy details in /etc/rhsm/rhsm.conf file.

    # an http proxy server to use
    proxy_hostname =
    
    # port for http proxy server
    proxy_port =
    
  • The following fields are also required when using an authenticated proxy:

    # user name for authenticating to an http proxy, if needed
    proxy_user =
    
    # password for basic http proxy auth, if needed
    proxy_password =
    
  • unset proxy environment variables :

    # unset http_proxy
    # unset https_proxy
    

Root Cause

  • proxy is configured via http_proxy/https_proxy environment variables due to which leapp is unable to connect to RHEL 8 repositories for the upgrade. leapp refers /etc/rhsm/rhsm.conf file for the proxy configuration.

Diagnostic Steps

  • Check /var/log/rhsm/rhsm.log

    # cat  /var/log/rhsm/rhsm.log 
    
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.