diff --git a/repos/system_upgrade/common/actors/loaddevicedriverdeprecationdata/libraries/deviceanddriverdeprecationdataload.py b/repos/system_upgrade/common/actors/loaddevicedriverdeprecationdata/libraries/deviceanddriverdeprecationdataload.py index 7d41aa0842..3caa4e0ac0 100644 --- a/repos/system_upgrade/common/actors/loaddevicedriverdeprecationdata/libraries/deviceanddriverdeprecationdataload.py +++ b/repos/system_upgrade/common/actors/loaddevicedriverdeprecationdata/libraries/deviceanddriverdeprecationdataload.py @@ -16,9 +16,8 @@ def process(): deprecation_data = fetch.load_data_asset(api.current_actor(), data_file_name, asset_fulltext_name='Device driver deprecation data', - docs_url='https://access.redhat.com/articles/3664871', - docs_title=('Leapp utility metadata in-place upgrades of RHEL ' - 'for disconnected upgrades (including Satellite)')) + docs_url='', + docs_title='') api.produce( DeviceDriverDeprecationData( diff --git a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_event_parsing.py b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_event_parsing.py index bac2015e5b..35bcec73f7 100644 --- a/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_event_parsing.py +++ b/repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_event_parsing.py @@ -8,6 +8,7 @@ from leapp.exceptions import StopActorExecution from leapp.libraries.common import fetch from leapp.libraries.common.config import architecture +from leapp.libraries.common.config.version import get_source_major_version, get_target_major_version from leapp.libraries.stdlib import api # NOTE(mhecko): The modulestream field contains a set of modulestreams until the very end when we generate a Package @@ -69,9 +70,8 @@ def get_pes_events(pes_json_directory, pes_json_filename): events_data = fetch.load_data_asset(api.current_actor(), pes_json_filename, asset_fulltext_name='PES events file', - docs_url='https://access.redhat.com/articles/3664871', - docs_title=('Leapp utility metadata in-place upgrades of RHEL ' - 'for disconnected upgrades (including Satellite)')) + docs_url='', + docs_title='') if not events_data: return None @@ -83,9 +83,16 @@ def get_pes_events(pes_json_directory, pes_json_filename): events_matching_arch = [e for e in all_events if not e.architectures or arch in e.architectures] return events_matching_arch except (ValueError, KeyError): + rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version()) title = 'Missing/Invalid PES data file ({}/{})'.format(pes_json_directory, pes_json_filename) - summary = ('Read documentation at: https://access.redhat.com/articles/3664871 for more information ' - 'about how to retrieve the files') + summary = ( + 'All official data files are nowadays part of the installed rpms.' + ' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed' + ' (e.g. by custom scripts).' + ' In case you want to recover the original file, remove it (if still exists)' + ' and reinstall the {} rpm.' + .format(rpmname) + ) reporting.create_report([ reporting.Title(title), reporting.Summary(summary), diff --git a/repos/system_upgrade/common/actors/repositoriesmapping/libraries/repositoriesmapping.py b/repos/system_upgrade/common/actors/repositoriesmapping/libraries/repositoriesmapping.py index 9692e2c03c..416034ace3 100644 --- a/repos/system_upgrade/common/actors/repositoriesmapping/libraries/repositoriesmapping.py +++ b/repos/system_upgrade/common/actors/repositoriesmapping/libraries/repositoriesmapping.py @@ -130,11 +130,16 @@ def load_from_dict(data): def _inhibit_upgrade(msg): - raise StopActorExecutionError( - msg, - details={'hint': ('Read documentation at the following link for more' - ' information about how to retrieve the valid file:' - ' https://access.redhat.com/articles/3664871')}) + rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version()) + hint = ( + 'All official data files are nowadays part of the installed rpms.' + ' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed' + ' (e.g. by custom scripts).' + ' In case you want to recover the original file, remove it (if still exists)' + ' and reinstall the {} rpm.' + .format(rpmname) + ) + raise StopActorExecutionError(msg, details={'hint': hint}) def _read_repofile(repofile): @@ -145,9 +150,8 @@ def _read_repofile(repofile): repofile_data = load_data_asset(api.current_actor(), repofile, asset_fulltext_name='Repositories mapping', - docs_url='https://access.redhat.com/articles/3664871', - docs_title=('Leapp utility metadata in-place upgrades of RHEL ' - 'for disconnected upgrades (including Satellite)')) + docs_url='', + docs_title='') return repofile_data # If the file does not contain a valid json then load_asset will do a stop actor execution diff --git a/repos/system_upgrade/common/libraries/fetch.py b/repos/system_upgrade/common/libraries/fetch.py index b501e3bb92..1ca26170dd 100644 --- a/repos/system_upgrade/common/libraries/fetch.py +++ b/repos/system_upgrade/common/libraries/fetch.py @@ -7,6 +7,7 @@ from leapp import models from leapp.exceptions import StopActorExecutionError from leapp.libraries.common.config import get_consumed_data_stream_id, get_env +from leapp.libraries.common.config.version import get_source_major_version, get_target_major_version from leapp.libraries.stdlib import api SERVICE_HOST_DEFAULT = "https://cert.cloud.redhat.com" @@ -15,15 +16,25 @@ ASSET_PROVIDED_DATA_STREAMS_FIELD = 'provided_data_streams' +def _get_hint(): + rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version()) + hint = ( + 'All official data files are nowadays part of the installed rpms.' + ' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed' + ' (e.g. by custom scripts).' + ' In case you want to recover the original file, remove it (if still exists)' + ' and reinstall the {} rpm.' + .format(rpmname) + ) + return hint + + def _raise_error(local_path, details): """ If the file acquisition fails in any way, throw an informative error to stop the actor. """ - summary = "Data file {lp} is invalid or could not be retrieved.".format(lp=local_path) - hint = ("Read documentation at: https://access.redhat.com/articles/3664871" - " for more information about how to retrieve the file.") - - raise StopActorExecutionError(summary, details={'details': details, 'hint': hint}) + summary = 'Data file {lp} is missing or invalid.'.format(lp=local_path) + raise StopActorExecutionError(summary, details={'details': details, 'hint': _get_hint()}) def _request_data(service_path, cert, proxies, timeout=REQUEST_TIMEOUT): @@ -57,7 +68,8 @@ def read_or_fetch(filename, service=None, allow_empty=False, encoding='utf-8', - data_stream=None): + data_stream=None, + allow_download=True): """ Return the contents of a text file or fetch them from an online service if the file does not exist. @@ -67,6 +79,7 @@ def read_or_fetch(filename, :param Optional[str] with_leapp_version: Inject the given leapp version when fetching from a service. :param bool allow_empty: Raise an error if the resulting data are empty. :param str encoding: Encoding to use when decoding the raw binary data. + :param bool allow_download: Allow the fallback to download the data file if not present. :returns: Text contents of the file. Text is decoded using the provided encoding. :rtype: str """ @@ -75,7 +88,9 @@ def read_or_fetch(filename, # try to get the data locally if not os.path.exists(local_path): - logger.warning("File {lp} does not exist, falling back to online service".format(lp=local_path)) + if not allow_download: + _raise_error(local_path, "File {lp} does not exist.".format(lp=local_path)) + logger.warning("File {lp} does not exist, falling back to online service)".format(lp=local_path)) else: try: with io.open(local_path, encoding=encoding) as f: @@ -149,7 +164,7 @@ def load_data_asset(actor_requesting_asset, error_hint = {'hint': ('Read documentation at the following link for more information about how to retrieve ' 'the valid file: {0}'.format(docs_url))} else: - error_hint = {} + error_hint = {'hint': _get_hint()} data_stream_id = get_consumed_data_stream_id() data_stream_major = data_stream_id.split('.', 1)[0]