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

[ModelViolationError] leapp fails when .repo files are not fully configured/missing syntax

    • None
    • Moderate
    • 1
    • rhel-sst-upgrades
    • 20
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • Leapp: 9.6 & 10.0
    • None
    • None
    • None

      Trying upgrade system with leapp. Due to some misconfigured file in system it failed with traceback of 'ModelViolationError'

      Please provide the package NVR for which bug is seen:

      Affects all leapp versions of leapp-repository

      How reproducible:

      100%

      Steps to reproduce

      1. Create a 'test.repo' file as follows:
      [test-rpms-repo]                       <---- Keep this uncommented 
      #name=Test Repo
      #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
      #baseurl=https://10.85.92.77/repos/test-rpms-repo
      #enabled=1
      #gpgcheck=1
       # Run leapp preupgrade
       # It will fail with traceback that looks like this(taken from RHEL 7 reproducer):
      
      ====================== ERRO ====================
      
      
      ==> * pam_modules_scanner
              Scan the pam directory for services and modules used in them
      ====> * system_facts
              Provides data about many facts from system.
      Process Process-230:
      Traceback (most recent call last):
        File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
          self.run()
        File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
          self._target(*self._args, **self._kwargs)
        File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 74, in _do_run
          actor_instance.run(*args, **kwargs)
        File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 289, in run
          self.process(*args)
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/actor.py", line 57, in process
          self.produce(systemfacts.get_repositories_status())
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py", line 220, in get_repositories_status
          return 
      
      RepositoriesFacts(repositories=repofileutils.get_parsed_repofiles())
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/repofileutils.py", line 77, in get_parsed_repofiles
          repofile = parse_repofile(context.full_path(repofile_path))
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/repofileutils.py", line 41, in parse_repofile
          data.append(_parse_repository(repoid, dict(cp.items(repoid))))
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/libraries/repofileutils.py", line 26, in _parse_repository
          return RepositoryData(**prepared)
        File "/usr/lib/python2.7/site-packages/leapp/models/__init__.py", line 90, in __init__
          getattr(defined_fields[field], init_method)(kwargs, field, self)
        File "/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.py", line 111, in from_initialization
          self._validate_model_value(value=source_value, name=name)
        File "/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.py", line 180, in _validate_model_value
          super(BuiltinField, self)._validate_model_value(value, name)
        File "/usr/lib/python2.7/site-packages/leapp/models/fields/__init__.py", line 61, in _validate_model_value
          raise ModelViolationError('The value of "\{name}" field is None, but this is not allowed'.format(name=name))
      ModelViolationError: The value of "name" field is None, but this is not allowed
      
      
      =============================================================================================
      Actor system_facts unexpectedly terminated with exit code: 1 - Please check the above details
      =============================================================================================
      

      Expected results

       ModelViolationError should be handled better instead of traceback.

       If the 'name' parameter can be passed along the traceback , the filename test.repo should also be passed along.

      Actual results

      The test.repo file is not reported by traceback. 

       

      Additional information

      Reading following line we have to check all possible configs related to repository to find a single typo or sometimes missing key-value pair:

       

      repository/repositories/system_upgrade/common/libraries/repofileutils.py", line 26, in _parse_repository

       

      If you add a `name = test`, then your hit with an even bigger erro bc the baseurl is missing.

       

      Traceback (most recent call last):
        File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
          self.run()
        File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
          self._target(*self._args, **self._kwargs)
        File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 74, in _do_run
          actor_instance.run(*args, **kwargs)
        File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 289, in run
          self.process(*args)
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/actor.py", line 20, in process
          rpmscanner.process()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 110, in process
          pkg_repos = get_package_repository_data()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 77, in get_package_repository_data
          return _get_package_repository_data_yum()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 31, in _get_package_repository_data_yum
          for pkg in yum_base.doPackageLists().installed:
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 2981, in doPackageLists
          avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1075, in <lambda>
          pkgSack = property(fget=lambda self: self._getSacks(),
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 778, in _getSacks
          self.repos.populateSack(which=repos)
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 347, in populateSack
          self.doSetup()
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 157, in doSetup
          self.retrieveAllMD()
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 88, in retrieveAllMD
          dl = repo._async and repo._commonLoadRepoXML(repo)
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1482, in _commonLoadRepoXML
          result = self._getFileRepoXML(local, text)
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1259, in _getFileRepoXML
          size=102400) # setting max size as 100K
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1025, in _getFile
          result = self.grab.urlgrab(misc.to_utf8(relative), local,
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 703, in <lambda>
          grab = property(lambda self: self._getgrab())
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 698, in _getgrab
          self._setupGrab()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 635, in _setupGrab
          urls = self.urls
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 881, in <lambda>
          urls = property(fget=lambda self: self._geturls(),
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 878, in _geturls
          self._baseurlSetup()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 844, in _baseurlSetup
          self.check()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 562, in check
          'Cannot find a valid baseurl for repo: %s' % self.ui_id
      RepoError: Cannot find a valid baseurl for repo: test
      2023-12-12 10:52:41.198 ERROR    PID: 18109 leapp.workflow.FactsCollection: Actor rpm_scanner has crashed: Traceback (most recent call last):
        File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 74, in _do_run
          actor_instance.run(*args, **kwargs)
        File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 289, in run
          self.process(*args)
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/actor.py", line 20, in process
          rpmscanner.process()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 110, in process
          pkg_repos = get_package_repository_data()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 77, in get_package_repository_data
          return _get_package_repository_data_yum()
        File "/usr/share/leapp-repository/repositories/system_upgrade/common/actors/rpmscanner/libraries/rpmscanner.py", line 31, in _get_package_repository_data_yum
          for pkg in yum_base.doPackageLists().installed:
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 2981, in doPackageLists
          avail = self.pkgSack.returnNewestByNameArch(patterns=patterns,
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1075, in <lambda>
          pkgSack = property(fget=lambda self: self._getSacks(),
        File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 778, in _getSacks
          self.repos.populateSack(which=repos)
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 347, in populateSack
          self.doSetup()
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 157, in doSetup
          self.retrieveAllMD()
        File "/usr/lib/python2.7/site-packages/yum/repos.py", line 88, in retrieveAllMD
          dl = repo._async and repo._commonLoadRepoXML(repo)
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1482, in _commonLoadRepoXML
          result = self._getFileRepoXML(local, text)
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1259, in _getFileRepoXML
          size=102400) # setting max size as 100K
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 1025, in _getFile
          result = self.grab.urlgrab(misc.to_utf8(relative), local,
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 703, in <lambda>
          grab = property(lambda self: self._getgrab())
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 698, in _getgrab
          self._setupGrab()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 635, in _setupGrab
          urls = self.urls
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 881, in <lambda>
          urls = property(fget=lambda self: self._geturls(),
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 878, in _geturls
          self._baseurlSetup()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 844, in _baseurlSetup
          self.check()
        File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 562, in check
          'Cannot find a valid baseurl for repo: %s' % self.ui_id
      RepoError: Cannot find a valid baseurl for repo: test 

              leapp-notifications leapp-notifications
              rhn-support-jcastran John Castranio
              Tomas Fratrik Tomas Fratrik
              RHEL Upgrades QE Team RHEL Upgrades QE Team
              Miriam Portman Miriam Portman
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: