b4aed63dad
- Enable new upgrade path RHEL 8.10 -> 9.5 - Minor updates in reports - Add information about leapp invocation to leapp.db - Resolves: RHEL-27847
79 lines
3.8 KiB
Diff
79 lines
3.8 KiB
Diff
From 35e667c33dc186292a27efe2dceb2f71a20a5e13 Mon Sep 17 00:00:00 2001
|
|
From: Petr Stodulka <pstodulk@redhat.com>
|
|
Date: Tue, 14 May 2024 16:14:20 +0200
|
|
Subject: [PATCH 39/49] Fix W0135 reported by pylint
|
|
|
|
W0135 -> contextmanager-generator-missing-cleanup
|
|
|
|
Expects try-finally around `yield`. Checked reported functions,
|
|
usually it's FP. In one case I changed the code to make it clear.
|
|
---
|
|
repos/system_upgrade/common/libraries/dnfplugin.py | 3 +++
|
|
.../system_upgrade/common/libraries/overlaygen.py | 14 ++++++++++----
|
|
2 files changed, 13 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/common/libraries/dnfplugin.py b/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
index fbd58246..e59168ef 100644
|
|
--- a/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
+++ b/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
@@ -460,6 +460,9 @@ def perform_transaction_install(target_userspace_info, storage_info, used_repos,
|
|
|
|
@contextlib.contextmanager
|
|
def _prepare_perform(used_repos, target_userspace_info, xfs_info, storage_info, target_iso=None):
|
|
+ # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
+ # implicitly
|
|
reserve_space = overlaygen.get_recommended_leapp_free_space(target_userspace_info.path)
|
|
with _prepare_transaction(used_repos=used_repos,
|
|
target_userspace_info=target_userspace_info
|
|
diff --git a/repos/system_upgrade/common/libraries/overlaygen.py b/repos/system_upgrade/common/libraries/overlaygen.py
|
|
index 6b0ff97d..4bcbf32b 100644
|
|
--- a/repos/system_upgrade/common/libraries/overlaygen.py
|
|
+++ b/repos/system_upgrade/common/libraries/overlaygen.py
|
|
@@ -296,6 +296,9 @@ def _prepare_required_mounts(scratch_dir, mounts_dir, storage_info, scratch_rese
|
|
|
|
@contextlib.contextmanager
|
|
def _build_overlay_mount(root_mount, mounts):
|
|
+ # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
+ # implicitly
|
|
if not root_mount:
|
|
raise StopActorExecutionError('Root mount point has not been prepared for overlayfs.')
|
|
if not mounts:
|
|
@@ -519,6 +522,9 @@ def _mount_dnf_cache(overlay_target):
|
|
"""
|
|
Convenience context manager to ensure bind mounted /var/cache/dnf and removal of the mount.
|
|
"""
|
|
+ # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
+ # implicitly
|
|
with mounting.BindMount(
|
|
source='/var/cache/dnf',
|
|
target=os.path.join(overlay_target, 'var', 'cache', 'dnf')) as cache_mount:
|
|
@@ -570,6 +576,9 @@ def create_source_overlay(mounts_dir, scratch_dir, xfs_info, storage_info, mount
|
|
:type scratch_reserve: Optional[int]
|
|
:rtype: mounting.BindMount or mounting.NullMount
|
|
"""
|
|
+ # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
+ # implicitly
|
|
api.current_logger().debug('Creating source overlay in {scratch_dir} with mounts in {mounts_dir}'.format(
|
|
scratch_dir=scratch_dir, mounts_dir=mounts_dir))
|
|
try:
|
|
@@ -589,11 +598,8 @@ def create_source_overlay(mounts_dir, scratch_dir, xfs_info, storage_info, mount
|
|
with _build_overlay_mount(root_overlay, mounts) as overlay:
|
|
with _mount_dnf_cache(overlay.target):
|
|
yield overlay
|
|
- except Exception:
|
|
+ finally:
|
|
cleanup_scratch(scratch_dir, mounts_dir)
|
|
- raise
|
|
- # cleanup always now
|
|
- cleanup_scratch(scratch_dir, mounts_dir)
|
|
|
|
|
|
# #############################################################################
|
|
--
|
|
2.44.0
|
|
|