From 8a62a3f9b69830341479b25edbecc5929203e964 Mon Sep 17 00:00:00 2001 From: Alexander Graul Date: Thu, 25 Jul 2024 12:47:18 +0200 Subject: [PATCH] Fix `AttributeError: ENABLE_NVREA` for reposync Co-authored-by: Dominik Gedon --- ...changes.nodeg.context_manager_fix_reposync | 1 + python/spacewalk/server/importlib/backend.py | 28 ++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 python/spacewalk.changes.nodeg.context_manager_fix_reposync diff --git a/python/spacewalk.changes.nodeg.context_manager_fix_reposync b/python/spacewalk.changes.nodeg.context_manager_fix_reposync new file mode 100644 index 000000000000..7e242809fb16 --- /dev/null +++ b/python/spacewalk.changes.nodeg.context_manager_fix_reposync @@ -0,0 +1 @@ +- fix `AttributeError: ENABLE_NVREA` for reposyncing (bsc#1226273) diff --git a/python/spacewalk/server/importlib/backend.py b/python/spacewalk/server/importlib/backend.py index a7f576536fbd..1d2ad6044cbc 100644 --- a/python/spacewalk/server/importlib/backend.py +++ b/python/spacewalk/server/importlib/backend.py @@ -26,7 +26,7 @@ from uyuni.common.usix import raise_with_tb from uyuni.common import rhn_rpm -from spacewalk.common.rhnConfig import CFG +from spacewalk.common.rhnConfig import cfg_component from spacewalk.common.rhnException import rhnFault from spacewalk.common.rhnLog import log_debug from spacewalk.satellite_tools import syncLib @@ -171,11 +171,9 @@ def processCapabilities(self, capabilityHash): # pylint: disable-next=invalid-name def processChangeLog(self, changelogHash): - if ( - CFG.has_key("package_import_skip_changelog") - and CFG.package_import_skip_changelog - ): - return + with cfg_component(None) as cfg: + if cfg.get("package_import_skip_changelog"): + return None if not changelogHash: return @@ -1123,12 +1121,9 @@ def processPackages( "susePackageEula": "package_id", "rhnPackageExtraTag": "package_id", } - - if ( - CFG.has_key("package_import_skip_changelog") - and CFG.package_import_skip_changelog - ): - del childTables["rhnPackageChangeLogRec"] + with cfg_component(None) as cfg: + if cfg.get("package_import_skip_changelog"): + del childTables["rhnPackageChangeLogRec"] for package in packages: if not isinstance(package, Package): @@ -3295,10 +3290,11 @@ def _do_diff(self, data, table_name, uq_fields, fields): def validate_pks(self): # If nevra is enabled use checksum as primary key tbs = self.tables["rhnPackage"] - if not CFG.ENABLE_NVREA: - # remove checksum from a primary key if nevra is disabled. - if "checksum_id" in tbs.pk: - tbs.pk.remove("checksum_id") + with cfg_component("server") as cfg: + if not cfg.ENABLE_NVREA: + # remove checksum from a primary key if nevra is disabled. + if "checksum_id" in tbs.pk: + tbs.pk.remove("checksum_id") # Returns a tuple for the hash's values