+++ This bug was initially created as a clone of Bug #805714 +++ Description of problem: If clone channel A is cloned to channel B, then the errata.cloneAsOriginal API (or spacewalk-clone-by-date) is used to clone Red Hat errata into channel B that are not also in channel A, then the errata will end up in channel B but none of the associated packages. Version-Release number of selected component (if applicable): spacewalk-java-1.2.39-115 spacewalk-utils-1.2.1-16 How reproducible: 100% Steps to Reproduce: 1.) Clone rhel-x86_64-server-5 with no errata, as clone-rhel-x86_64-server-5. 2.) Clone some errata into clone-rhel-x86_64-server-5: *** # spacewalk-clone-by-date -u admin -p redhat -l rhel-x86_64-server-5 clone-rhel-x86_64-server-5 --to_date 2007-03-14 By continuing the following will be cloned: rhel-x86_64-server-5 -> clone-rhel-x86_64-server-5 (19/2385 Errata) Continue with clone (y/n)?y Cloning Errata into clone-rhel-x86_64-server-5 (19): ________________________________________ ######################################## - complete Copying repodata, please wait. Solving Dependencies (149): ________________________________________ ######################################## - complete Processing Dependencies: ________________________________________ ######################################## - complete *** 3.) Confirm that these errata and their associated packages are now in clone-rhel-x86_64-server-5. Packages: 2969 Errata: 19 4.) In the web UI, clone clone-rhel-x86_64-server-5 with all errata, as clone-clone-rhel-x86_64-server-5. Confirm that the package and errata counts match those of clone-rhel-x86_64-server-5: Packages: 2969 Errata: 19 5.) Add more errata to clone-clone-rhel-x86_64-server-5, via spacewalk-clone-by-date or errata.cloneAsOriginal: # spacewalk-clone-by-date -u admin -p redhat -l rhel-x86_64-server-5 clone-clone-rhel-x86_64-server-5 --to_date 2007-03-23 Reading repository information. By continuing the following will be cloned: rhel-x86_64-server-5 -> clone-clone-rhel-x86_64-server-5 (2/2366 Errata) Continue with clone (y/n)?y Cloning Errata into clone-clone-rhel-x86_64-server-5 (2): ________________________________________ ######################################## - complete 6.) In the web UI, confirm that clone-clone-rhel-x86_64-server-5 now has 2 more errata, but the package count has not changed: Packages: 2969 Errata: 21 7.) Look at the two new errata, and confirm that they are linked to the channel, but the packages are not: CLA-2007:0128 - Product Enhancement Advisory Clone of Clone of Red Hat Enterprise Linux (v. 5 for 64-bit x86_64) (none) CLA-2007:0124 - Security Advisory Clone of Clone of Red Hat Enterprise Linux (v. 5 for 64-bit x86_64) (none) 8.) In the web UI, delete the two errata from clone-clone-rhel-x86_64-server-5, then add them both to the first channel clone-rhel-x86_64-server-5. 9.) Verify that you can now push the errata and the packages successfully into clone-clone-rhel-x86_64-server-5, now that they are present in clone-rhel-x86_64-server-5: spacewalk-clone-by-date -u admin -p redhat -l rhel-x86_64-server-5 clone-clone-rhel-x86_64-server-5 --to_date 2007-03-23 Actual results: The errata.cloneAsOriginal API (and spacewalk-clone-by-date, which uses this API) does not link the packages associated with errata into a channel, if that channel is a clone of a clone, and the originating clone channel does not already have those packages. Expected results: The errata and the relevant packages are linked to the target channel. Additional info: The relevant code is: *** ./code/src/com/redhat/rhn/frontend/xmlrpc/errata/ErrataHandler.java: public Object[] cloneAsOriginal(String sessionKey, String channelLabel, List advisoryNames) throws InvalidChannelRoleException { [...] publishedClone = ErrataFactory.publishToChannel(publishedClone, channel, loggedInUser, true); *** ./code/src/com/redhat/rhn/domain/errata/ErrataFactory.java: public static Errata publishToChannel(Errata errata, Channel chan, User user, boolean inheritPackages) { if (!errata.isPublished()) { errata = publish(errata); } errata.addChannel(chan); [...] if (inheritPackages) { if (!chan.isCloned()) { throw new InvalidChannelException("Cloned channel expected: " + chan.getLabel()); } Channel original = ((ClonedChannel) chan).getOriginal(); packs = ErrataManager.listErrataChannelPacks(original, errata, user); } else { packs = ErrataManager.lookupPacksFromErrataForChannel(chan, errata, user); } *** So, because the API calls ErrataFactory.publishToChannel with boolean inheritPackages = true, only packages in the 'original' clone channel are considered for adding to the clone-of-a-clone channel. If you are trying to add errata that are not already linked to the 'original' clone channel, then you end up with the problem described above. A possible resolution would be to modify the API to check whether the 'original' channel is also a clone, and use the actual original Red Hat channel instead of this cloned channel when using the inheritPackages option.
Committed fix to Spacewalk master: 35ab17cba1d6dfa85e2c2417c11a3f7c8fcf028d
I've tested the upstream fix (spacewalk-nightly), and can verify the problem now seems to be fixed: Output from re-running my original reproducer (from 805714): $ ./clone_reproducer.py Connecting to http://fedora_satellite/rpc/api Cloned rhel-x86_64-server-5 -> clone-rhel-x86_64-server-5-27290 (original state) clone-rhel-x86_64-server-5-27290 contains 2820 packages 0 errata Cloned RHBA-2007:0574 into clone-rhel-x86_64-server-5-27290 clone-rhel-x86_64-server-5-27290 contains 2824 packages 1 errata ------------------------------------ Cloned clone-rhel-x86_64-server-5-27290 -> clone-clone-rhel-x86_64-server-5-27290 (current state) clone-clone-rhel-x86_64-server-5-27290 contains 2824 packages 1 errata Cloned RHSA-2007:0131 into clone-clone-rhel-x86_64-server-5-27290 clone-clone-rhel-x86_64-server-5-27290 contains 2825 packages 2 errata So we can see that now the clone-clone-rhel-x86_64-server-5-27290 channel contains one additional package after cloning RHSA-2007:0131 into the channel :) So fix verified in spacewalk-java-1.8.37-1.fc16.noarch
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18