Skip to content

Address error if errata is already present#27

Merged
stevemeier merged 1 commit into
stevemeier:masterfrom
moio:fix_issue_20
Aug 7, 2020
Merged

Address error if errata is already present#27
stevemeier merged 1 commit into
stevemeier:masterfrom
moio:fix_issue_20

Conversation

@moio

@moio moio commented Jul 10, 2020

Copy link
Copy Markdown
Contributor

Problem description

This patch prevents the following error:

INFO: Creating errata for CEBA-2019:1331 (CentOS accountsservice BugFix Update) (5 of 22)
Fault returned from XML RPC Server, fault code 2601: redstone.xmlrpc.XmlRpcFault: Errata already exists with advisory CEBA-2019:1331

This happens in case errataImport.pl is trying to add an errata where a published errata that is not linked to any channel already exists.

This can happen, for example, after a channel is deleted - published errata that was only in that channel are not cleaned up.

Such published errata can be found via this one-liner:

spacewalk-sql --select-mode - <<<"SELECT advisory_name FROM rhnErrata e WHERE id NOT IN (SELECT errata_id FROM rhnChannelErrata)"

Solution details

As there is currently no API to get a full list of errata including those not in channels, this patch makes errataImport.pl fail gracefully at errata creation time when the errata already exists by catching the exception and ignoring it selectively.

I am no Perl expert, but my understanding is that the previous code did not really work as intended, as following the condition was always met:

if (defined($result->{faultCode})) {

In case of fault, Frontier would in fact die prior this condition was hit and not return a $result hash at all. So here I am using eval to catch the exceptional case.

HTH!

Fixes #20

@moio

moio commented Jul 10, 2020

Copy link
Copy Markdown
Contributor Author

CC @dvosburg this addresses the error 500 you also saw, it's the same reported as #20

@moio

moio commented Jul 10, 2020

Copy link
Copy Markdown
Contributor Author

@stevemeier this is best reviewed by ignoring whitespace changes 😅

@stevemeier stevemeier merged commit f4fbef1 into stevemeier:master Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trying to update errata db and fails with existing CVE.

2 participants