Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError: ENABLE_NVREA for reposync #8916

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- fix `AttributeError: ENABLE_NVREA` for reposyncing (bsc#1226273)
32 changes: 15 additions & 17 deletions python/spacewalk/server/importlib/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from uyuni.common.usix import raise_with_tb
from uyuni.common import rhn_rpm
from spacewalk.common.rhnConfig import CFG
agraul marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -1206,11 +1201,13 @@ def update_channels_affected_by_errata(self, dml):
affected_errata_ids = {}
for op_type in ["insert", "update", "delete"]:
op_values = getattr(dml, op_type)
for table_name, values_hash in list(op_values.items()):
for table_name, values_hash in op_values.items():
if table_name == "rhnErrata":
field = "id"
elif "errata_id" in values_hash:
field = "errata_id"
else:
continue

# Now we know in which field to look for changes
for erratum_id in values_hash[field]:
Expand Down Expand Up @@ -3295,10 +3292,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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me looks like AttributeError: ENABLE_NVREA is still possible here if it's missing in rhn.conf or default configs for some reason.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have it in our default rhn_server.conf, if there is an AttributeError there is a bigger problem (default configs missing or modified), IMO it's okay to show a backtrace in that situation.

# 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
Expand Down