Bug 1493143 - channel.software.mergeErrata deletes errata from source channel if it exists in destination channel
Summary: channel.software.mergeErrata deletes errata from source channel if it exists ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: API
Version: 580
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
Assignee: Tomáš Kašpárek
QA Contact: Radovan Drazny
URL:
Whiteboard:
Depends On:
Blocks: sat58-errata
TreeView+ depends on / blocked
 
Reported: 2017-09-19 13:19 UTC by Tomáš Kašpárek
Modified: 2021-06-10 13:04 UTC (History)
8 users (show)

Fixed In Version: spacewalk-java-2.5.14-102-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-12-13 07:59:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:3445 0 normal SHIPPED_LIVE Red Hat Satellite 5.8.0 bug fix update 2017-12-12 19:00:37 UTC

Description Tomáš Kašpárek 2017-09-19 13:19:54 UTC
Description of problem:
channel.software.mergeErrata deletes errata from source channel if it exists in destination channel, even if the channel is in NULL organization.

Version-Release number of selected component (if applicable):
Satellite 5.8
Spacewalk nightly

How reproducible:
always

Steps to Reproduce:
1. sync some channel (e.g. rhel-x86_64-server-6)
2. spacewalk-clone-by-date -l rhel-x86_64-server-6  testing-rhel-6 --to_date 2015-01-01 -u admin -p xxxxx --assumeyes
3.
#!/usr/bin/python
import xmlrpclib

SATELLITE_URL = "http://localhost/rpc/api"
SATELLITE_LOGIN = "admin"
SATELLITE_PASSWORD = "xxxxx"

client = xmlrpclib.Server(SATELLITE_URL, verbose=0)

key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)

client.channel.software.mergeErrata(key, 'rhel-x86_64-server-6', 'testing-rhel-6')

client.auth.logout(key)


Results:
A lot of erratas is missing from rhel-x86_64-server-6 channel
situation prior to mergeErrata API call:
channel                          errata
rhel-x86_64-server-6     4079
testing-rhel-6                2580

Situation after merge errata API call:
channel                          errata
rhel-x86_64-server-6     1229
testing-rhel-6                4079

rhel-x86_64-server-6 is missing 2580 errata (4079-2580=1229). Packages are present, but the 2580 erratas are not linked to them anymore.

Another weird issue is that all errata is copied into destination channel, even if there are no packages linked to the erratum. We also need to investigate this.


Additional info:
Also reported in https://www.redhat.com/archives/spacewalk-list/2017-August/msg00089.html

Comment 2 bernhard.lichtinger 2017-09-20 14:44:33 UTC
I had a look into the code and I have a wild guess (I am not familiar with java and hibernate) that the bug might be triggered here:

https://github.com/spacewalkproject/spacewalk/blob/master/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java#L2191

private Set<Errata> mergeErrataToChannel(User user, Set<Errata> errataToMerge,
            Channel toChannel, Channel fromChannel) {

        // find errata that we do not need to merge
        List<Errata> same = ErrataManager.listSamePublishedInChannels(
                user, fromChannel, toChannel);
        List<Errata> brothers = ErrataManager.listPublishedBrothersInChannels(
                user, fromChannel, toChannel);
        List<Errata> clones = ErrataManager.listPublishedClonesInChannels(
                user, fromChannel, toChannel);
        // and remove them
        errataToMerge.removeAll(same);
        errataToMerge.removeAll(brothers);
        errataToMerge.removeAll(clones);

        ErrataManager.publishErrataToChannelAsync(toChannel,
                getErrataIds(errataToMerge), user);

        // no need to regenerate errata cache, because we didn't touch any packages

        return errataToMerge;
    }

Perhaps the "errataToMerge.removeAll" somehow also deletes the errata from the fromChannel because this are lists of hibernate objects and not only lists of errata ids???

Comment 3 Tomas Lestach 2017-09-20 16:03:49 UTC
my guess: https://github.com/spacewalkproject/spacewalk/pull/574

Comment 4 Tomáš Kašpárek 2017-09-21 08:48:12 UTC
I've tested the PR and I can confirm that it works:

spacewalk.git(master): d60097a2cab0ce8fdc441124b145860e7406143a

Comment 5 bernhard.lichtinger 2017-09-21 12:28:36 UTC
Could you please also fix it for spacewalk-2.7?

Comment 6 Tomáš Kašpárek 2017-09-22 06:49:58 UTC
(In reply to bernhard.lichtinger from comment #5)
> Could you please also fix it for spacewalk-2.7?

Yes the fix will be in Spacewalk 2.7.

Comment 16 Radovan Drazny 2017-11-15 11:35:35 UTC
Reproduced on spacewalk-java-2.5.14-101.el6sat, verified on spacewalk-java-2.5.14-105.el6sat.

I have tested both scenarios - the initial report in comment 0, and spacewalk-manage-channel-lifecycle use described in https://www.redhat.com/archives/spacewalk-list/2017-August/msg00089.html. Both scenarios passed - at the end of the merge, new errata was correctly merged into a cloned channel, and no errata was deleted from the source channel.

VERIFIED

Comment 22 errata-xmlrpc 2017-12-13 07:59:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:3445


Note You need to log in before you can comment on or make changes to this bug.