diff --git a/repos/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py b/repos/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py index d1eeb28cdc..10a198da11 100644 --- a/repos/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py +++ b/repos/system_upgrade/common/actors/systemfacts/libraries/systemfacts.py @@ -217,7 +217,22 @@ def get_sysctls_status(): def get_repositories_status(): """ Get a basic information about YUM repositories installed in the system """ - return RepositoriesFacts(repositories=repofileutils.get_parsed_repofiles()) + try: + return RepositoriesFacts(repositories=repofileutils.get_parsed_repofiles()) + except repofileutils.InvalidRepoDefinition as e: + raise StopActorExecutionError( + message='Invalid repository definition', + details={ + 'details': str(e), + 'file': e.repofile, + 'repoid': e.repoid, + 'hint': 'To resolve this issue, please visit: {url}' + .format( + url='https://access.redhat.com/solutions/3185891' + ) + } + ) + def get_selinux_status(): diff --git a/repos/system_upgrade/common/libraries/repofileutils.py b/repos/system_upgrade/common/libraries/repofileutils.py index a563be5204..ed996cada7 100644 --- a/repos/system_upgrade/common/libraries/repofileutils.py +++ b/repos/system_upgrade/common/libraries/repofileutils.py @@ -11,6 +11,13 @@ api.current_logger().warning('repofileutils.py: failed to import dnf') +class InvalidRepoDefinition(Exception): + def __init__(self, message, repofile=None, repoid=None): + super().__init__(message) + self.repofile = repofile + self.repoid = repoid + + def _parse_repository(repoid, repo_data): def asbool(x): return x == '1' @@ -38,7 +45,10 @@ def parse_repofile(repofile): with open(repofile, mode='r') as fp: cp = utils.parse_config(fp, strict=False) for repoid in cp.sections(): - data.append(_parse_repository(repoid, dict(cp.items(repoid)))) + try: + data.append(_parse_repository(repoid, dict(cp.items(repoid)))) + except Exception as e: + raise InvalidRepoDefinition(e, repofile=repofile, repoid=repoid) return RepositoryFile(file=repofile, data=data)