RHEL7: "leapp preupgrade" fails with message "Unable to use yum successfully"

Solution Verified - Updated

Environment

  • Red Hat Satellite 6
  • Red Hat Enterprise Linux 7
    • leapp

Issue

  • When executing "leapp preupgrade" or "leapp upgrade", the following message is displayed:

    [ERROR] Actor: target_userspace_creator
    Message: Unable to use yum successfully
    Summary:
        Details: Command ['systemd-nspawn', '--register=no', '--quiet', '-D', '/var/lib/leapp/scratch/mounts/root_/system_overlay', '--bind=/etc/hosts:/etc/hosts', '--setenv=..., 'yum', 'clean', 'all'] failed with exit code 1.
        Stderr: Host and machine ids are equal (XXX): refusing to link journals
                 There are no enabled repos.
                 Run "yum repolist all" to see the repos you have.
                 To enable Red Hat Subscription Management repositories:
                     subscription-manager repos --enable <repo>
                 To enable custom repositories:
                     yum-config-manager --enable <repo>
    

Resolution

IMPORTANT NOTE
In case these resolution steps suggested not works, please consider also this alternative kcs Running leapp upgrade on Content Hosts registered with Red Hat Satellite 6 fails with Message: Unable to use yum successfully , and before to proceed with resolution steps, please refer to the RHEL 7 to RHEL 8 LEAP Upgrade Failing When Using Satellite and make sure that all the checkpoints are validated.

There are at least 2 different situations where this can happen:
1. When the system is registered through Satellite
2. When the system is directly connected to Red Hat CDN

To discover if the system is registered to a Satellite server, check the content of /etc/rhsm/rhsm.conf:

# grep ^hostname /etc/rhsm/rhsm.conf
hostname = subscription.rhsm.redhat.com

In the example above, the system is directly connected to Red Hat CDN.

Case where the system is registered to a Satellite server

This usually happens when the Satellite server repositories for RHEL 8 are not synchronized.

  1. Check if the expected RHEL 8 repositories are now synchronized properly in the Red Hat Satellite server

    For Red Hat Satellite 6.9 or below, execute the following command:

     # find -L /var/lib/pulp/published/yum/https/repos/ -type d -name repodata -exec /bin/sh -c "ls -1 '{}'/repomd.xml || echo '***** {} *****'" \; 2>&1 | grep rhel8
    

    For Red Hat Satellite 6.10 and above, execute the following set of commands to obtain a similar output:

        # path_of_repos=$(echo "COPY (select base_path from core_distribution where pulp_type = 'rpm.rpm') \
          TO STDOUT;" | su - postgres -c "psql pulpcore")
    
        # for repo in $path_of_repos
          do
          echo "COPY(select core_d.base_path,cpa.relative_path,ca.file from core_distribution as core_d RIGHT JOIN \
          core_publication as cp ON core_d.publication_id=cp.pulp_id LEFT JOIN core_publishedartifact as cpa ON \
          cp.pulp_id=cpa.publication_id LEFT JOIN core_contentartifact as core_ca ON \
          core_ca.pulp_id=cpa.content_artifact_id LEFT JOIN core_artifact as ca ON ca.pulp_id=core_ca.artifact_id \
          where core_d.base_path = '$repo' and cpa.relative_path = 'repodata/repomd.xml' \
          order by core_d.base_path) TO STDOUT WITH CSV" | su - postgres -c "psql pulpcore"
          done > /tmp/repodata_to_artifact.txt
    
        # for map in $(cat /tmp/repodata_to_artifact.txt)
          do
          REPO_PATH=$(echo $map | awk -F',' '{print $1"/"$2}')
          FILE="/var/lib/pulp/media/$(echo $map | cut -d, -f3)"
          STAT=$(test -e $FILE && echo "PRESENT" || echo "ABSENT")
          echo "$REPO_PATH,$STAT"
          done | column -s, -t | grep rhel8
    
  2. If the expected versions of RHEL 8 repositories are not synchronized or not present in the required content-view, Investigate the same from the Satellite server:

    Follow the documentation Red Hat Satellite > 6.9 > Content Management Guide > Chapter 5 and Chapter 8..

  3. Verify that the expected RHEL 8 repositories are now synchronized properly in the Red Hat Satellite server.

    For Red Hat Satellite 6.9 or below, execute the following command:

     # find -L /var/lib/pulp/published/yum/https/repos/ -type d -name repodata -exec /bin/sh -c "ls -1 '{}'/repomd.xml || echo '***** {} *****'" \; 2>&1 | grep rhel8
     
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8/x86_64/appstream/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8/x86_64/baseos/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8/x86_64/supplementary/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8/x86_64/sap-solutions/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8/x86_64/highavailability/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8.2/x86_64/appstream/os/repodata/repomd.xml
    /var/lib/pulp/published/yum/https/repos/YPTO/Library/content/dist/rhel8/8.2/x86_64/baseos/os/repodata/repomd.xml
    

    For Red Hat Satellite 6.10 and above, execute the following set of commands to obtain a similar output:

        # path_of_repos=$(echo "COPY (select base_path from core_distribution where pulp_type = 'rpm.rpm') \
          TO STDOUT;" | su - postgres -c "psql pulpcore")
    
        # for repo in $path_of_repos
          do
          echo "COPY(select core_d.base_path,cpa.relative_path,ca.file from core_distribution as core_d RIGHT JOIN \
          core_publication as cp ON core_d.publication_id=cp.pulp_id LEFT JOIN core_publishedartifact as cpa ON \
          cp.pulp_id=cpa.publication_id LEFT JOIN core_contentartifact as core_ca ON \
          core_ca.pulp_id=cpa.content_artifact_id LEFT JOIN core_artifact as ca ON ca.pulp_id=core_ca.artifact_id \
          where core_d.base_path = '$repo' and cpa.relative_path = 'repodata/repomd.xml' \
          order by core_d.base_path) TO STDOUT WITH CSV" | su - postgres -c "psql pulpcore"
          done > /tmp/repodata_to_artifact.txt
    
        # for map in $(cat /tmp/repodata_to_artifact.txt)
          do
          REPO_PATH=$(echo $map | awk -F',' '{print $1"/"$2}')
          FILE="/var/lib/pulp/media/$(echo $map | cut -d, -f3)"
          STAT=$(test -e $FILE && echo "PRESENT" || echo "ABSENT")
          echo "$REPO_PATH,$STAT"
          done | column -s, -t | grep rhel8
          
          RedHat/Library/content/dist/rhel8/8.6/x86_64/baseos/os/repodata/repomd.xml                     PRESENT
          RedHat/Library/content/dist/rhel8/8.6/x86_64/appstream/os/repodata/repomd.xml                  PRESENT
    
    
  4. Enable the required repositories on the affected client system:

    # subscription-manager repos --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rhel-7-server-optional-rpms --enable rhel-7-server-supplementary-rpms
    
  5. Ensure that the client has does not have any repository overrides disabling the target release's repositories.

    # jq '.[] | select(.contentLabel |contains("rhel-8")) ' /var/lib/rhsm/cache/content_overrides.json
    {
      "updated": "2022-06-09T13:31:00+0000",
      "contentLabel": "rhel-8-for-x86_64-appstream-rpms",
      "name": "enabled",
      "value": "1",
      "created": "2022-06-09T13:31:00+0000"
    }
    {
      "updated": "2022-06-09T13:35:20+0000",
      "contentLabel": "rhel-8-for-x86_64-baseos-rpms",
      "name": "enabled",
      "value": "1",
      "created": "2022-06-09T13:35:20+0000"
    }
    

    If you see "value": "0", go to the Web UI > Hosts > Content Hosts > hostname > Repository Sets > and set AppStream, and Baseos, to enabled.

  6. Execute leapp preupgrade on the system again

Case where the system is directly connected to the Red Hat CDN

This is seen on systems registered to the CDN when no repositories are enabled. This causes yum clean all to fail with exit code 1.

Message: Unable to use yum successfully
Summary:
    Details: Command ['yum', 'clean', 'all'] failed with exit code 1.
    Stderr: There are no enabled repos.
             Run "yum repolist all" to see the repos you have.
             To enable Red Hat Subscription Management repositories:
                 subscription-manager repos --enable <repo>
             To enable custom repositories:
                 yum-config-manager --enable <repo>
  1. Check that some RHEL 8 repositories are present in the cache of subscription-manager

    # grep "rhel-8" /var/lib/rhsm/cache/*
    /var/lib/rhsm/cache/content_overrides.json:[{..., "contentLabel": "rhel-8-for-x86_64-appstream-rpms", "name": "enabled", "value": "0", "created": "2020-07-14T04:46:24+0000"}, {"updated": "2020-07-14T04:46:24+0000", "contentLabel": "rhel-8-for-x86_64-appstream-rpms", ...}]
    /var/lib/rhsm/cache/written_overrides.json:{.... "rhel-8-for-x86_64-baseos-rpms": {"enabled": "0", "enabled_metadata": "0"}, ..., "rhel-8-for-x86_64-appstream-rpms": {"enabled": "0", "enabled_metadata": "0"}}
    

    In the example above, rhel-8 repositories are present, which shall not be the case on a RHEL 7 system.

    If there are no rhel-8 repositories listed, contact your Red Hat Support representative and mention this Solution.

  2. Un-register the system completely

    # subscription-manager remove --all
    # subscription-manager unregister
    # subscription-manager clean
    

    Additionally, remove the certificate file if present:

    # rm /etc/pki/product-default/479.pem
    

    If the command returns in error, just ignore the error and continue.

  3. Register the system again

    # subscription-manager register --username <your CDN identifier>
    # subscription-manager attach
    
  4. Enable the required repositories

    # subscription-manager repos --enable rhel-7-server-rpms --enable rhel-7-server-extras-rpms --enable rhel-7-server-optional-rpms --enable rhel-7-server-supplementary-rpms
    
  5. Verify that no RHEL 8 repository is known to subscription-manager

    # grep "rhel-8" /var/lib/rhsm/cache/*
    #
    

    In the example above, there is no RHEL 8 repository listed anymore, which is expected.

    If there are still rhel-8 repositories listed, contact your Red Hat Support representative and mention this Solution.

  6. Execute leapp preupgrade on the system again.

For more KB articles/solutions related to Red Hat Satellite 6.x LEAPP Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x LEAPP Issues

Root Cause

The issue usually happens when the Satellite server is not synchronized for RHEL 8 repositories.
Alternatively, there seems to be some case where RHEL 7 systems directly attached to Red Hat CDN have RHEL 8 repositories already attached.

Diagnostic Steps

Refer to the procedure in the Resolution section.

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.