Avoid crash when loading pickle file failed

The pickle files are used for reusing results from old compose and the
failure should not block the compose process.

JIRA: RHELCMP-9494
Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
Haibo Lin 2022-07-01 10:14:29 +08:00
parent 960c85efde
commit da336f75f8
3 changed files with 29 additions and 10 deletions

View File

@ -669,9 +669,16 @@ class BuildinstallThread(WorkerThread):
return None
compose.log_info("Loading old BUILDINSTALL phase metadata: %s", old_metadata)
with open(old_metadata, "rb") as f:
old_result = pickle.load(f)
return old_result
try:
with open(old_metadata, "rb") as f:
old_result = pickle.load(f)
return old_result
except Exception as e:
compose.log_debug(
"Failed to load old BUILDINSTALL phase metadata %s : %s"
% (old_metadata, str(e))
)
return None
def _reuse_old_buildinstall_result(self, compose, arch, variant, cmd, pkgset_phase):
"""

View File

@ -193,9 +193,16 @@ def load_old_gather_result(compose, arch, variant):
return None
compose.log_info("Loading old GATHER phase results: %s", old_gather_result)
with open(old_gather_result, "rb") as f:
old_result = pickle.load(f)
return old_result
try:
with open(old_gather_result, "rb") as f:
old_result = pickle.load(f)
return old_result
except Exception as e:
compose.log_debug(
"Failed to load old GATHER phase results %s : %s"
% (old_gather_result, str(e))
)
return None
def reuse_old_gather_packages(compose, arch, variant, package_sets, methods):

View File

@ -819,11 +819,16 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event):
compose.paths.work.pkgset_file_cache(compose_tag)
)
if old_cache_path:
pkgset.set_old_file_cache(
pungi.phases.pkgset.pkgsets.KojiPackageSet.load_old_file_cache(
old_cache_path
try:
pkgset.set_old_file_cache(
pungi.phases.pkgset.pkgsets.KojiPackageSet.load_old_file_cache(
old_cache_path
)
)
except Exception as e:
compose.log_debug(
"Failed to load old cache file %s : %s" % (old_cache_path, str(e))
)
)
is_traditional = compose_tag in compose.conf.get("pkgset_koji_tag", [])
should_inherit = inherit if is_traditional else inherit_modules