Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-39095

Leapp module.py library does not read the DNF config

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • leapp-repository-0.22.0-5.el8_10
    • None
    • Moderate
    • Patch
    • rhel-upgrades
    • 20
    • 0
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • None
    • All
    • None

      What were you trying to do that didn't work?

      Our customer used the new feature (RHEL-3274RHEL-3297) that includes /etc/leapp/files/dnf.conf into the target userspace container to in-place upgrade from 7 to 8 and it worked. To have DNF working, they need to force the 'proxy_auth_method' to 'basic'.

      While in-place upgrading from 8 to 9, it didn't work due to a proxy authentication error:

      2024-05-29 03:23:04.648 DEBUG    PID: 143492 dnf: error: Curl error (56): Failure when receiving data from the peer for https://<HOSTNAME>/content/dist/rhel8/8.10/x86_64/baseos/os/repodata/repomd.xml [Received HTTP code 407 from proxy after CONNECT] 

      It fails very early with a traceback at the rpm_scanner step that uses libdnf directly. I understand the DNF configuration is not read:

      > /etc/leapp/repos.d/system_upgrade/common/libraries/module.py(45)_create_or_get_dnf_base()
      -> base = dnf.Base(conf=conf)
      (Pdb) n
      > /etc/leapp/repos.d/system_upgrade/common/libraries/module.py(46)_create_or_get_dnf_base()
      -> base.init_plugins()
      (Pdb) conf.proxy_auth_method
      'any'
      (Pdb) base.conf.read()
      2024-05-28 09:50:24.649 DEBUG    PID: 14167 dnf: Unknown configuration option: http_caching = packages in /etc/dnf/dnf.conf
      (Pdb) conf.proxy_auth_method
      'basic' 

      IMPORTANT: this can be considered as a 2nd problem here: the curl error from the libdnf that is printed to the console is not included in the leapp logs, making the diagnostic more difficult.

      Workaround

      # sed -i '41 i \ \ \ \ \ \ \ \ base.conf.read()' /usr/share/leapp-repository/repositories/system_upgrade/common/libraries/module.py 

      Patch

      --- /usr/share/leapp-repository/repositories/system_upgrade/common/libraries/module.py.orig    2024-05-29 03:55:53.038194552 -0400
      +++ /usr/share/leapp-repository/repositories/system_upgrade/common/libraries/module.py    2024-05-29 03:56:03.716278340 -0400
      @@ -38,6 +38,7 @@
               conf.substitutions.update_from_etc('/')
       
               base = dnf.Base(conf=conf)
      +        base.conf.read()
               base.init_plugins()
               base.read_all_repos()
               # configure plugins after the repositories are loaded
      

      Please provide the package NVR for which bug is seen:

      leapp-upgrade-el8toel9-0.20.0-2.el8

      How reproducible:

      Always

      Steps to reproduce

      1. Setup a proxy that required a proxy authentication. The one of the customer speaks NTLM first (when the method is set to 'any') but only BASIC auth credentials are defined on the proxy side.
      2. Define the proxy with its username, password and auth_method in /etc/dnf/dnf.conf
      3. Run leapp preupgrade and observe the traceback at the rpm_scanner step. The traceback follows the curl error with the HTTP 407 return code.

      Expected results

      The code using the libdnf has to read the dnf.conf in order to use some custom directives to make the connection to CDN working, otherwise they cannot use a proxy.

      Actual results

      2024-05-29 03:23:03.772 DEBUG    PID: 143492 leapp.workflow.FactsCollection.rpm_scanner: External command has finished: ['/bin/rpm', '-qa', '--queryformat', '%{NAME}|%{VERSION}|%{RELEASE}|%|EPOCH?{%{EPOCH}}:{0}||%|PACKAGER?{%{PACKAGER}}:{(none)}||%|ARCH?{%{ARCH}}:{}||%|DSAHEADER?{%{DSAHEADER:pgpsig}}:{%|RSAHEADER?{%{RSAHEADER:pgpsig}}:{(none)}|}|\\n']
      2024-05-29 03:23:03.775 DEBUG    PID: 143492 dnf: User-Agent: constructed: 'libdnf (Red Hat Enterprise Linux 8.9; generic; Linux.x86_64)'
       :
      2024-05-29 03:23:04.641 DEBUG    PID: 143492 dnf: repo: downloading from remote: baseos
      2024-05-29 03:23:04.648 DEBUG    PID: 143492 dnf: error: Curl error (56): Failure when receiving data from the peer for https://<HOSTNAME>/content/dist/rhel8/8.10/x86_64/baseos/os/repodata/repomd.xml [Received HTTP code 407 from proxy after CONNECT] (https://<HOSTNAME>/content/dist/rhel8/8.10/x86_64/baseos/os/repodata/repomd.xml).
       :
      2024-05-29 03:23:04.669 WARNING  PID: 143492 dnf: Errors during downloading metadata for repository 'baseos':
        - Curl error (56): Failure when receiving data from the peer for https://<HOSTNAME>/content/dist/rhel8/8.10/x86_64/baseos/os/repodata/repomd.xml [Received HTTP code 407 from proxy after CONNECT]
      Process Process-215:
      Traceback (most recent call last):
        File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load
          ret = self._repo.load()
        File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
          return _repo.Repo_load(self)
      libdnf._error.Error: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
       :
      During handling of the above exception, another exception occurred:
       :
      Traceback (most recent call last):
        File "/usr/lib64/python3.6/multiprocessing/process.py", line 258, in _bootstrap
          self.run()
        File "/usr/lib64/python3.6/multiprocessing/process.py", line 93, in run
          self._target(*self._args, **self._kwargs)
        File "/usr/lib/python3.6/site-packages/leapp/repository/actor_definition.py", line 74, in _do_run
          actor_instance.run(*args, **kwargs)
        File "/usr/lib/python3.6/site-packages/leapp/actors/__init__.py", line 289, in run
          self.process(*args)
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/actor.py", line 20, in process
          rpmscanner.process()
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 111, in process
          rpm_streams = map_modular_rpms_to_modules()
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 87, in map_modular_rpms_to_modules
          modules = module_lib.get_modules()
        File "/etc/leapp/repos.d/system_upgrade/common/libraries/module.py", line 58, in get_modules
          base = _create_or_get_dnf_base(base)
        File "/etc/leapp/repos.d/system_upgrade/common/libraries/module.py", line 48, in _create_or_get_dnf_base
          base.fill_sack()
        File "/usr/lib/python3.6/site-packages/dnf/base.py", line 405, in fill_sack
          self._add_repo_to_sack(r)
        File "/usr/lib/python3.6/site-packages/dnf/base.py", line 140, in _add_repo_to_sack
          repo.load()
        File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 580, in load
          raise dnf.exceptions.RepoError(str(e))
      dnf.exceptions.RepoError: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
      2024-05-29 03:23:04.685 ERROR    PID: 142530 leapp.workflow.FactsCollection: Actor rpm_scanner has crashed: Traceback (most recent call last):
        File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load
          ret = self._repo.load()
        File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
          return _repo.Repo_load(self)
      libdnf._error.Error: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
       :
      During handling of the above exception, another exception occurred:
       :
      Traceback (most recent call last):
        File "/usr/lib/python3.6/site-packages/leapp/repository/actor_definition.py", line 74, in _do_run
          actor_instance.run(*args, **kwargs)
        File "/usr/lib/python3.6/site-packages/leapp/actors/__init__.py", line 289, in run
          self.process(*args)
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/actor.py", line 20, in process
          rpmscanner.process()
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 111, in process
          rpm_streams = map_modular_rpms_to_modules()
        File "/etc/leapp/repos.d/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 87, in map_modular_rpms_to_modules
          modules = module_lib.get_modules()
        File "/etc/leapp/repos.d/system_upgrade/common/libraries/module.py", line 58, in get_modules
          base = _create_or_get_dnf_base(base)
        File "/etc/leapp/repos.d/system_upgrade/common/libraries/module.py", line 48, in _create_or_get_dnf_base
          base.fill_sack()
        File "/usr/lib/python3.6/site-packages/dnf/base.py", line 405, in fill_sack
          self._add_repo_to_sack(r)
        File "/usr/lib/python3.6/site-packages/dnf/base.py", line 140, in _add_repo_to_sack
          repo.load()
        File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 580, in load
          raise dnf.exceptions.RepoError(str(e))
      dnf.exceptions.RepoError: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
       :
      ============================================================================================
      Actor rpm_scanner unexpectedly terminated with exit code: 1 - Please check the above details
      ============================================================================================
      

       

              kkula@redhat.com Karolina Kula
              rhn-support-cbesson Christophe Besson
              leapp-notifications leapp-notifications
              Anna Dupliak Anna Dupliak
              Miriam Portman Miriam Portman
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated: