Uploaded image for project: 'RHEL Conversions'
  1. RHEL Conversions
  2. RHELC-134

Clean yum cache of disabled repos

XMLWordPrintable

    • False
    • False
    • Hide

      None

      Show
      None
    • 2
    • 2023-Q2

      We're calling `yum makecache` in `check_custom_repos_are_valid()` to check whether a repository is accessible (no typo in the repoid, repo metadata available under the baseurl, etc.). We should separate this cache making to a separate function, similarly to cache cleaning for which we have `clean_yum_metadata()`.

      Related code:

      Acceptance criteria:

      • Move yum make-cache call from the check_custom_repos_are_valid to a separate function, for example to the repo.py module (move there the clean_yum_metadata() from the pkghandler.py module as well)
      • Call this new yum make-cache functions before system checks, but after the cache cleaning

      Upon further analysis of this task, we've realized that the `yum makecache` command under the `check_custom_repos_are_valid()` function is actually correct. That's the intent of calling the command - to see if the repos passed through the --enablerepo convert2rhel option are accessible.

      There's one related issue though - that we don't necessarily clean the cache of the repo passed through the --enablerepo convert2rhel option. Because by default the `yum clean` command cleans the cache just for enabled repos.

      Consider this scenario:

      • I'm and admin preparing a CentOS Linux 7 system for a conversion to RHEL 7
      • I have prepared a mirror of a RHEL 7 repo on an FTP server available on an internal company network
      • I create an /etc/yum.repos.d/rhel7-on-our-ftp.repo file where I define a rhel-7-server-rpms repoid pointing to the RHEL 7 repo on the on-premise FTP server
      • I make the repo disabled by default (enabled=0)
      • I check whether the repo definition is ok by running '# yum info kernel --setopt=reposdir=/home/admin/conversion/ --enablerepo=rhel-7-server-rpms' and it works ok. That command generates a yum cache for this repo.
      • Couple of hours later I run convert2rhel, not knowing the FTP server is down
      • convert2rhel executes 'yum clean metadata' but that cleans cache of the enabled repos on the system only and the rhel-7-server-rpms is not enabled
      • convert2rhel runs the custom repo validity check in which it executes
        yum makecache -v --setopt={*}.skip_if_unavailable=False --disablerepo="{\*}" --enablerepo=rhel-7-server-rpms

        and it returns 0 because it uses the cache generated hours ago

      The above scenario show where the clean_yum_metadata() function is deficient - it does not clean cache of all the repos the convert2rhel works with.

      Acceptance criteria:

      • Clean yum cache (just metadata is sufficient) of all repos defined on the system, i.e. not only the enabled ones but also the disabled ones
        • This will make sure that convert2rhel works with fresh metadata even in the scenario depicted above

              prwatson@redhat.com Preston Watson
              mbocek@redhat.com Michal Bocek
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: