+++ This bug was initially created as a clone of Bug #804782 +++ Description of problem: configchannel.deployAllSystems() API method deploy files for all configuration channel and not only the given configuration channel. Version-Release number of selected component (if applicable): RHN Satellite 5.4 spacewalk-java-1.2.39-115.el6sat rhncfg-client-5.9.27-18.el5 How reproducible: 100% Steps to Reproduce: 1. Create 2 configuration channels 2. Subscribe the both channels on a box 3. Modify the files present on both channels 4. Deploy the files for channelA using the RHN API Actual results: all the files present on the both config channel were deployed Expected results: only the files present on channelA should be deployed Additional info: My reproducer steps: [root@dhcp41 ~]# rhncfg-client elist Mode Owner Group Size Rev Config Channel File -rw-r--r-- root root 258 3 global_cfgs_mmello /etc/motd -rw-r--r-- root root 20 1 test-channel /etc/test-file drwx------ root root *0 1 global_cfgs_mmello /root/.ssh -rw------- root root 412 4 global_cfgs_mmello /root/.ssh/authorized_keys ** Making sure that every file were deployed as expected [root@dhcp41 ~]# rhncfg-client verify /etc/motd /etc/test-file /root/.ssh /root/.ssh/authorized_keys ** Forcing a change on files present on the both different channels [root@dhcp41 ~]# echo "test test" >> /etc/motd [root@dhcp41 ~]# echo "test test" >> /etc/test-file ** Showing that the files now are different than files available on the repo [root@dhcp41 ~]# rhncfg-client verify modified /etc/motd modified /etc/test-file /root/.ssh /root/.ssh/authorized_keys ** Executing the RHN API script to deploy the files present only on the "test-channel" [root@dhcp41 ~]# python deployAll-configchannel.py Enter the channel name: test-channel Files in channel test-channel (1) ------------------------------ /etc/test-file (file) Systems subscribed into channel test-channel (1) ------------------------------ dhcp41.gsslab.rdu.redhat.com (1000010005) Configuration deployment for all systems subscribed into the channel test-channel were scheduled successfully. ** Executing rhn_check to pick up and execute the scheduled job [root@dhcp41 ~]# rhn_check -vv {...SNIP...} D: do_call configfiles.deploy ({'files': [{'config_channel': 'global_cfgs_mmello', 'username': 'root', 'encoding': '', 'checksum': '', 'filetype': 'directory', 'delim_start': '', 'delim_end': '', 'symlink': '', 'groupname': 'root', 'file_contents': '', 'selinux_ctx': '', 'filemode': 700, 'path': '/root/.ssh', 'checksum_type': '', 'revision': 1}, {'config_channel': 'global_cfgs_mmello', 'username': 'root', 'encoding': 'base64', 'checksum': '309106610bc2ef9d85662e178bd272dd', 'filetype': 'file', 'delim_start': '{|', 'delim_end': '|}', 'symlink': '', 'groupname': 'root', 'file_contents': 'IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjCiMgICAgICAgICAgICAg\nICAgU0VHL0dTUyAgICAgICAgICAgICAgICAgIwojLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t\nLS0tLS0tLS0tLS0tLSMKIyBPd25lcjogTWFyY2VsbyBNZWxsbyAgICAgICAgICAgICAgICAgICAj\nCiMgICAgICAgICAgICAgICAgICAgIDxtbWVsbG9AcmVkaGF0LmNvbT4gIwojIyMjIyMjIyMjIyMj\nIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMK\n', 'selinux_ctx': '', 'filemode': 644, 'path': '/etc/motd', 'checksum_type': 'md5', 'revision': 3}, {'config_channel': 'global_cfgs_mmello', 'username': 'root', 'encoding': 'base64', 'checksum': 'ee64e72a1c85e339a12b24988457c0c9', 'filetype': 'file', 'delim_start': '{|', 'delim_end': '|}', 'symlink': '', 'groupname': 'root', 'file_contents': 'c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBQkl3QUFBUUVBcUhuSkJ4ZnVTcWlSa05jbWFrVnlq\na0FIWkY5QmdjUVZlUE9NNDh2WHpKenJPVXFydy9hZVRRbm51dXBjL2libzJPM1QxUjBXZjNLekRN\nKzBUQTJQYndHd2l1cVNsMDF2ZW1tOTR3UnV2bGxlUTd6TnFrTWlEZGt3REtua0ppRVd3TXhqcXNj\ndFhkdEpsU2xXK1NpdlFNUHVYQlVCcmJRZ1lOUVhndGlOUXdmT2h6U1gxUmV6S0Z6QmQ0WVg5OFpN\neGpOaXlQUTZMS0Y4c2trS3k4SEoxRFFpWUZlVjR6dXZSc3FJZ2wwTVBHMmREK0JsR0VBU0ZzKzNZ\nZkpXYitpcjFsMTV0dXp3RjIvU3p6Ui85dnJIVG1DZGNXdVdEM3F1dGVTT1FTN0hXNU13SGJvTEtH\nSkNjRGFWZlV1VXhheHZwQ3NGZEpFQXZ4YkRRbDR0UlduNFB3PT0gbWRlbWVsbG9AbW1lbGxvLmdy\ndS5yZWRoYXQuY29tCg==\n', 'selinux_ctx': '', 'filemode': 600, 'path': '/root/.ssh/authorized_keys', 'checksum_type': 'md5', 'revision': 4}, {'config_channel': 'test-channel', 'username': 'root', 'encoding': 'base64', 'checksum': '4221d002ceb5d3c9e9137e495ceaa647', 'filetype': 'file', 'delim_start': '{|', 'delim_end': '|}', 'symlink': '', 'groupname': 'root', 'file_contents': 'dGhpcyBpcyBhIHRlc3QgZmlsZQo=\n', 'selinux_ctx': '', 'filemode': 644, 'path': '/etc/test-file', 'checksum_type': 'md5', 'revision': 1}]},) {'cache_only': None} D: Sending back response (0, 'Files successfully deployed', {}) Note: as we can see above, the both files were deployed ** Verifying the deployed files [root@dhcp41 ~]# rhncfg-client verify /etc/motd /etc/test-file /root/.ssh /root/.ssh/authorized_keys --- Additional comment from mmello on 2012-03-20 10:36:30 EDT --- java/code/src/com/redhat/rhn/frontend/xmlrpc/configchannel/ConfigChannelHandler.java ---------------------------- 482 /** 483 * Schedule a configuration deployment for all systems in a config channel immediately 484 * @param sessionKey the session key 485 * @param channelLabel the channel to remove the files from.. 486 * @return 1 if successful with the operation errors out otherwise. 487 * 488 * 489 * @xmlrpc.doc Schedule an immediate configuration deployment for all systems 490 * subscribed to a particular configuration channel. 491 * @xmlrpc.param #session_key() 492 * @xmlrpc.param #param_desc("string","channelLabel", 493 * "The configuration channel's label.") 494 * @xmlrpc.returntype #return_int_success() 495 */ 496 public int deployAllSystems(String sessionKey, String channelLabel) { 497 return deployAllSystems(sessionKey, channelLabel, new Date()); 498 } 501 /** 502 * Schedule a configuration deployment for all systems in a config channel 503 * @param sessionKey the session key 504 * @param channelLabel the channel to remove the files from.. 505 * @param date the date to schedule 506 * @return 1 if successful with the operation errors out otherwise. 507 * 508 * 509 * @xmlrpc.doc Schedule a configuration deployment for all systems 510 * subscribed to a particular configuration channel. 511 * @xmlrpc.param #session_key() 512 * @xmlrpc.param #param_desc("string","channelLabel", 513 * "The configuration channel's label.") 514 * @xmlrpc.param #param_desc($date, "The date to schedule the action") 515 * @xmlrpc.returntype #return_int_success() 516 */ 517 public int deployAllSystems(String sessionKey, String channelLabel, Date date) { 518 User loggedInUser = getLoggedInUser(sessionKey); 519 XmlRpcConfigChannelHelper configHelper = XmlRpcConfigChannelHelper.getInstance(); 520 ConfigurationManager manager = ConfigurationManager.getInstance(); 521 522 ConfigChannel channel = configHelper.lookupGlobal(loggedInUser, 523 channelLabel); 524 List<ConfigSystemDto> dtos = manager.listChannelSystems(loggedInUser, 525 channel, null); 526 List<Server> servers = new ArrayList<Server>(); 527 for (ConfigSystemDto m : dtos) { 528 Server s = SystemManager.lookupByIdAndUser((Long) m.getId(), loggedInUser); 529 if (s != null) { 530 servers.add(s); 531 } 532 } 533 534 try { 535 manager.deployConfiguration(loggedInUser, servers, date); 536 } 537 catch (MissingCapabilityException e) { 538 throw new com.redhat.rhn.frontend.xmlrpc.MissingCapabilityException( 539 e.getCapability(), e.getServer()); 540 } 541 return 1; 542 543 } 544 } --- Additional comment from mmello on 2012-03-20 14:01:49 EDT --- Hello, After compiling a test package with a patch provided by Shannon, we were able to deploy the files to the configuration channel specified only. Look below: Spacewalk packages on the RHN Satellite server: Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=4173228 [root@sun-x4200-1 ~]# rpm -q spacewalk-java spacewalk-java-1.2.39-115.3.el6sat.test.noarch [root@sun-x4200-1 ~]# rpm -q spacewalk-java --changelog | head * Tue Mar 20 2012 Marcelo Moreira de Mello <mmello> 1.2.39-115.3.test - 804782 - fixed API method deployallSystems() for the given configchannel (shughes) * Mon Mar 19 2012 Marcelo Moreira de Mello <mmello> 1.2.39-115.2.test - 804706 - fixed api doc for method deployAllSystems() Reproducer: ** Showing files and configuration channels [root@dhcp41 ~]# rhncfg-client elist Mode Owner Group Size Rev Config Channel File -rw-r--r-- root root 258 3 global_cfgs_mmello /etc/motd -rw-r--r-- root root 20 1 test-channel /etc/test-file drwx------ root root *0 1 global_cfgs_mmello /root/.ssh -rw------- root root 412 4 global_cfgs_mmello /root/.ssh/authorized_keys [root@dhcp41 ~]# rhncfg-client verify /etc/motd /etc/test-file /root/.ssh /root/.ssh/authorized_keys ** Modifing the files [root@dhcp41 ~]# echo "lalal" >> /etc/test-file [root@dhcp41 ~]# echo "lalal" >> /etc/motd [root@dhcp41 ~]# rhncfg-client verify modified /etc/motd modified /etc/test-file /root/.ssh /root/.ssh/authorized_keys ** Executing the API deployAllSystems() method sophie Desktop$> python deployAll-configchannel.py Enter the channel name: test-channel Files in channel test-channel (1) ------------------------------ /etc/test-file (file) Systems subscribed into channel test-channel (1) ------------------------------ dhcp41.gsslab.rdu.redhat.com (1000010005) Configuration deployment for all systems subscribed into the channel test-channel were scheduled successfully ** Polling the rhn_check for pick up the task [root@dhcp41 ~]# rhn_check -vv {..SNIP..} D: handle_action actionid = 145, version = 2 D: do_call configfiles.deploy ({'files': [{'config_channel': 'test-channel', 'username': 'root', 'encoding': 'base64', 'checksum': '4221d002ceb5d3c9e9137e495ceaa647', 'filetype': 'file', 'delim_start': '{|', 'delim_end': '|}', 'symlink': '', 'groupname': 'root', 'file_contents': 'dGhpcyBpcyBhIHRlc3QgZmlsZQo=\n', 'selinux_ctx': '', 'filemode': 644, 'path': '/etc/test-file', 'checksum_type': 'md5', 'revision': 1}]},) {'cache_only': None} D: Sending back response (0, 'Files successfully deployed', {}) ** Checking the files deployed. Only the expected file were updated. [root@dhcp41 ~]# rhncfg-client verify modified /etc/motd /etc/test-file /root/.ssh /root/.ssh/authorized_keys The patch provided by Shannon addressed the issue. shughes++ Best Regards, mmello
Created attachment 571504 [details] deployallsystems patch for specific config channel attaching a patch for review. patch will allow the deployAllSystems API call to only deploy config files from the channel specified. Noticed the webui is using methods in the ConfigurationManager so created a new method and query to handle channel specific calls from the API vs modifying existing listFileNamesForSystem method. One concern is the language that is used in our apidocs for deployAllSystems API call. Its a bit vague and leans toward deploying all files from a specific config channel to which a system is subsribed which is the goal of this patch to address. But I imagine there is the possibility that existing users that might be using this API call are accustomed to all config files being deployed. If this is a issue, then maybe a separate API call can be created using the query in this patch.
Thanks Shannon, patch applied with together with checkstyle fixes ... spacewalk.git: 1d8fa162998bbafec1dfc5c702b7580080f9834a
The trouble is, the API call fails with a SQLException. So, the patch was probably never tested. spacewalk.git: acfd4be1ffdd104c4235307c57b1978c51c8b60b
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