Skip to content

Commit af6d7ef

Browse files
pirat89MichalHe
andcommitted
load data files: update hints in error messages and prepare for the download drop
As the leapp upgrade data files are nowadays part of the install rpm, there is no need to download them anymore. Also, we plan to drop the service providing the data files online in future. For that reason, update all texts and related error messages so people are not instructed to visit obsoleted article and do not try to apply invalid (obsoleted) data files anymore. Right now, we are keeping the functionality for the data files download, but the fetch functino is already updated and prepared to stop trying to download the files if not present. As we have the functionality already present, I think we should keep a possibility of the download for additional custom data files (not provided by us) in custom actors, but for the official data files we will require them in future to be present locally only. NOTE: regarding another planned changes soon, skipping update of unit-tests Co-authored-by: Michal Hečko <[email protected]>
1 parent 4fc0d0b commit af6d7ef

File tree

4 files changed

+49
-24
lines changed

4 files changed

+49
-24
lines changed

repos/system_upgrade/common/actors/loaddevicedriverdeprecationdata/libraries/deviceanddriverdeprecationdataload.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ def process():
1616
deprecation_data = fetch.load_data_asset(api.current_actor(),
1717
data_file_name,
1818
asset_fulltext_name='Device driver deprecation data',
19-
docs_url='https://access.redhat.com/articles/3664871',
20-
docs_title=('Leapp utility metadata in-place upgrades of RHEL '
21-
'for disconnected upgrades (including Satellite)'))
19+
docs_url='',
20+
docs_title='')
2221

2322
api.produce(
2423
DeviceDriverDeprecationData(

repos/system_upgrade/common/actors/peseventsscanner/libraries/pes_event_parsing.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from leapp.exceptions import StopActorExecution
99
from leapp.libraries.common import fetch
1010
from leapp.libraries.common.config import architecture
11+
from leapp.libraries.common.config.version import get_source_major_version, get_target_major_version
1112
from leapp.libraries.stdlib import api
1213

1314
# 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):
6970
events_data = fetch.load_data_asset(api.current_actor(),
7071
pes_json_filename,
7172
asset_fulltext_name='PES events file',
72-
docs_url='https://access.redhat.com/articles/3664871',
73-
docs_title=('Leapp utility metadata in-place upgrades of RHEL '
74-
'for disconnected upgrades (including Satellite)'))
73+
docs_url='',
74+
docs_title='')
7575
if not events_data:
7676
return None
7777

@@ -83,9 +83,16 @@ def get_pes_events(pes_json_directory, pes_json_filename):
8383
events_matching_arch = [e for e in all_events if not e.architectures or arch in e.architectures]
8484
return events_matching_arch
8585
except (ValueError, KeyError):
86+
rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version())
8687
title = 'Missing/Invalid PES data file ({}/{})'.format(pes_json_directory, pes_json_filename)
87-
summary = ('Read documentation at: https://access.redhat.com/articles/3664871 for more information '
88-
'about how to retrieve the files')
88+
summary = (
89+
'All official data files are nowadays part of the installed rpms.'
90+
' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed'
91+
' (e.g. by custom scripts).'
92+
' In case you want to recover the original file, remove it (if still exists)'
93+
' and reinstall the {} rpm.'
94+
.format(rpmname)
95+
)
8996
reporting.create_report([
9097
reporting.Title(title),
9198
reporting.Summary(summary),

repos/system_upgrade/common/actors/repositoriesmapping/libraries/repositoriesmapping.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ def load_from_dict(data):
130130

131131

132132
def _inhibit_upgrade(msg):
133-
raise StopActorExecutionError(
134-
msg,
135-
details={'hint': ('Read documentation at the following link for more'
136-
' information about how to retrieve the valid file:'
137-
' https://access.redhat.com/articles/3664871')})
133+
rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version())
134+
hint = (
135+
'All official data files are nowadays part of the installed rpms.'
136+
' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed'
137+
' (e.g. by custom scripts).'
138+
' In case you want to recover the original file, remove it (if still exists)'
139+
' and reinstall the {} rpm.'
140+
.format(rpmname)
141+
)
142+
raise StopActorExecutionError(msg, details={'hint': hint})
138143

139144

140145
def _read_repofile(repofile):
@@ -145,9 +150,8 @@ def _read_repofile(repofile):
145150
repofile_data = load_data_asset(api.current_actor(),
146151
repofile,
147152
asset_fulltext_name='Repositories mapping',
148-
docs_url='https://access.redhat.com/articles/3664871',
149-
docs_title=('Leapp utility metadata in-place upgrades of RHEL '
150-
'for disconnected upgrades (including Satellite)'))
153+
docs_url='',
154+
docs_title='')
151155
return repofile_data # If the file does not contain a valid json then load_asset will do a stop actor execution
152156

153157

repos/system_upgrade/common/libraries/fetch.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from leapp import models
88
from leapp.exceptions import StopActorExecutionError
99
from leapp.libraries.common.config import get_consumed_data_stream_id, get_env
10+
from leapp.libraries.common.config.version import get_source_major_version, get_target_major_version
1011
from leapp.libraries.stdlib import api
1112

1213
SERVICE_HOST_DEFAULT = "https://cert.cloud.redhat.com"
@@ -15,15 +16,25 @@
1516
ASSET_PROVIDED_DATA_STREAMS_FIELD = 'provided_data_streams'
1617

1718

19+
def _get_hint():
20+
rpmname = 'leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version())
21+
hint = (
22+
'All official data files are nowadays part of the installed rpms.'
23+
' This issue is usually encountered when the data files are incorrectly customized, replaced, or removed'
24+
' (e.g. by custom scripts).'
25+
' In case you want to recover the original file, remove it (if still exists)'
26+
' and reinstall the {} rpm.'
27+
.format(rpmname)
28+
)
29+
return hint
30+
31+
1832
def _raise_error(local_path, details):
1933
"""
2034
If the file acquisition fails in any way, throw an informative error to stop the actor.
2135
"""
22-
summary = "Data file {lp} is invalid or could not be retrieved.".format(lp=local_path)
23-
hint = ("Read documentation at: https://access.redhat.com/articles/3664871"
24-
" for more information about how to retrieve the file.")
25-
26-
raise StopActorExecutionError(summary, details={'details': details, 'hint': hint})
36+
summary = 'Data file {lp} is missing or invalid.'.format(lp=local_path)
37+
raise StopActorExecutionError(summary, details={'details': details, 'hint': _get_hint()})
2738

2839

2940
def _request_data(service_path, cert, proxies, timeout=REQUEST_TIMEOUT):
@@ -57,7 +68,8 @@ def read_or_fetch(filename,
5768
service=None,
5869
allow_empty=False,
5970
encoding='utf-8',
60-
data_stream=None):
71+
data_stream=None,
72+
allow_download=True):
6173
"""
6274
Return the contents of a text file or fetch them from an online service if the file does not exist.
6375
@@ -67,6 +79,7 @@ def read_or_fetch(filename,
6779
:param Optional[str] with_leapp_version: Inject the given leapp version when fetching from a service.
6880
:param bool allow_empty: Raise an error if the resulting data are empty.
6981
:param str encoding: Encoding to use when decoding the raw binary data.
82+
:param bool allow_download: Allow the fallback to download the data file if not present.
7083
:returns: Text contents of the file. Text is decoded using the provided encoding.
7184
:rtype: str
7285
"""
@@ -75,7 +88,9 @@ def read_or_fetch(filename,
7588

7689
# try to get the data locally
7790
if not os.path.exists(local_path):
78-
logger.warning("File {lp} does not exist, falling back to online service".format(lp=local_path))
91+
if not allow_download:
92+
_raise_error(local_path, "File {lp} does not exist.".format(lp=local_path))
93+
logger.warning("File {lp} does not exist, falling back to online service)".format(lp=local_path))
7994
else:
8095
try:
8196
with io.open(local_path, encoding=encoding) as f:
@@ -149,7 +164,7 @@ def load_data_asset(actor_requesting_asset,
149164
error_hint = {'hint': ('Read documentation at the following link for more information about how to retrieve '
150165
'the valid file: {0}'.format(docs_url))}
151166
else:
152-
error_hint = {}
167+
error_hint = {'hint': _get_hint()}
153168

154169
data_stream_id = get_consumed_data_stream_id()
155170
data_stream_major = data_stream_id.split('.', 1)[0]

0 commit comments

Comments
 (0)