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
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???
my guess: https://github.com/spacewalkproject/spacewalk/pull/574
I've tested the PR and I can confirm that it works: spacewalk.git(master): d60097a2cab0ce8fdc441124b145860e7406143a
Could you please also fix it for spacewalk-2.7?
(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.
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
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