Description of problem: Customer clones channels with - channel.software.clone(from_channel, to_channel, original_state=false) The from_channel is a clone of rhel-i386-server-5. This gets the initial channel made with the current set of packages/errata. Now when they want to push updates into the channel they use the mergeErrata and mergePackages calls. mergePackages seems to work just fine - it only pushes in changes to the channel. mergeErrata on the other hand seems to merge all of the errata whether or not it already associated with the channel. Internally reproduced: if I run API call mergePackages twice on the same source and target channels (the latter being a clone of the former), without any pkg/errata change in the source channel - the 2nd time the return value (array of merged pkgs) will return empty []. Whereas for mergeErrata, no matter how many times I run it the returned array will be the same list of errata. Version-Release number of selected component (if applicable): Red Hat Network (RHN) Satellite 5.3.0 How reproducible: Always. Steps to Reproduce: 1. Clone a channel, say "rhel-i386-server-5" (for simplication, use "original state") and call it "rhel-i386-server-5-clone-1". 2. Run API script calling server.channel.software.mergeErrata(rhnSession, "rhel-i386-server-5", "rhel-i386-server-5-clone-1") to merge all errata and print out return value (an array of errata). 3. Once all errata have been merged, and without any changes in "rhel-i386-server-5", repeat step 2 a few times more, and print out return value. Actual results: The same array of errata is returned always (appears to be all errata in the original channel), even though they had already been merged before (already associated w/ the target channel). Expected results: Similar to mergePackages, mergeErrata should return null the subsequent times in step 3, since all errata had already been merged. Additional info:
Looking at the code, it looks like mergeErrata and mergePackages are almost identical except one is Channel.getErrata the other is Channel.getPackages, not sure why the former would return the same set of errata to merge every time (even though they've already been merged) whereas the latter - correctly - does not find anything to merge when packages had already been merged. spacewalk-java-0.5.44/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java ... public Object[] mergeErrata(String sessionKey, String mergeFromLabel, String mergeToLabel) { User loggedInUser = getLoggedInUser(sessionKey); channelAdminPermCheck(loggedInUser); Channel mergeFrom = lookupChannelByLabel(loggedInUser, mergeFromLabel); Channel mergeTo = lookupChannelByLabel(loggedInUser, mergeToLabel); try { ChannelManager.verifyChannelAdmin(loggedInUser, mergeTo.getId()); } catch (InvalidChannelRoleException e) { LocalizationService ls = LocalizationService.getInstance(); throw new PermissionException(ls.getMessage( "frontend.xmlrpc.channels.software.merge.permsfailure", mergeTo.getLabel())); } List<Errata> differentErrata = new ArrayList<Errata>(); Set<Errata> toErrata = mergeTo.getErratas(); Set<Errata> fromErrata = mergeFrom.getErratas(); for (Errata errata : fromErrata) { if (!toErrata.contains(errata)) { differentErrata.add(errata); } } mergeTo.getErratas().addAll(differentErrata); ChannelFactory.save(mergeTo); return differentErrata.toArray(); } ... public Object[] mergePackages(String sessionKey, String mergeFromLabel, String mergeToLabel) { User loggedInUser = getLoggedInUser(sessionKey); channelAdminPermCheck(loggedInUser); Channel mergeFrom = lookupChannelByLabel(loggedInUser, mergeFromLabel); Channel mergeTo = lookupChannelByLabel(loggedInUser, mergeToLabel); try { ChannelManager.verifyChannelAdmin(loggedInUser, mergeTo.getId()); } catch (InvalidChannelRoleException e) { LocalizationService ls = LocalizationService.getInstance(); throw new PermissionException(ls.getMessage( "frontend.xmlrpc.channels.software.merge.permsfailure", mergeTo.getLabel())); } List<Package> differentPackages = new ArrayList<Package>(); Set<Package> toPacks = mergeTo.getPackages(); Set<Package> fromPacks = mergeFrom.getPackages(); for (Package pack : fromPacks) { if (!toPacks.contains(pack)) { differentPackages.add(pack); } } mergeTo.getPackages().addAll(differentPackages); ChannelFactory.save(mergeTo); ChannelManager.refreshWithNewestPackages(mergeTo, "api"); // Mark the affected channel to have it's metadata evaluated, where necessary // (RHEL5+, mostly) ChannelManager.queueChannelChange(mergeTo.getLabel(), "java::mergePackages", loggedInUser.getLogin()); return differentPackages.toArray(); } ... spacewalk-java-0.5.44/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml ... <set name="erratas" lazy="true" table="rhnChannelErrata" cascade="save-update"> <key column="channel_id"/> <many-to-many class="com.redhat.rhn.domain.errata.impl.PublishedErrata" column="errata_id"/> </set> ...
Fixed errata set comparison. spacewalk.git: 78d901926272372b63c24e38636b690aba131c35
Verified in stage with Satellite-5.4.0-RHEL5-re20101025.0.
The 5.4.0 RHN Satellite and RHN Proxy release has occurred. This issue has been resolved with this release. RHEA-2010:0801 - RHN Satellite Server 5.4.0 Upgrade https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10332 RHEA-2010:0803 - RHN Tools enhancement update https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10333 RHEA-2010:0802 - RHN Proxy Server 5.4.0 bug fix update https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10334 RHEA-2010:0800 - RHN Satellite Server 5.4.0 https://rhn.redhat.com/rhn/errata/details/Details.do?eid=10335 Docs are available: http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html Regards, Clifford